diff options
Diffstat (limited to 'ext/gmp/tests')
-rw-r--r-- | ext/gmp/tests/001.phpt | 21 | ||||
-rw-r--r-- | ext/gmp/tests/bug50175.phpt | 18 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_abs.phpt (renamed from ext/gmp/tests/013.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_and.phpt (renamed from ext/gmp/tests/029.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_clrbit.phpt (renamed from ext/gmp/tests/034.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_cmp.phpt (renamed from ext/gmp/tests/026.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_com.phpt (renamed from ext/gmp/tests/031.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_div_q.phpt (renamed from ext/gmp/tests/009.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_div_qr.phpt (renamed from ext/gmp/tests/007.phpt) | 17 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_div_r.phpt (renamed from ext/gmp/tests/008.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_divexact.phpt (renamed from ext/gmp/tests/011.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_export.phpt | 80 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_fact.phpt (renamed from ext/gmp/tests/014.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_gcd.phpt (renamed from ext/gmp/tests/021.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_gcdext.phpt (renamed from ext/gmp/tests/022.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_hamdist.phpt (renamed from ext/gmp/tests/036.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_import.phpt | 91 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_init.phpt (renamed from ext/gmp/tests/040.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_intval.phpt (renamed from ext/gmp/tests/004.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_invert.phpt (renamed from ext/gmp/tests/023.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_jacobi.phpt (renamed from ext/gmp/tests/024.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_legendre.phpt (renamed from ext/gmp/tests/025.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_mod.phpt (renamed from ext/gmp/tests/010.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_neg.phpt (renamed from ext/gmp/tests/012.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_or.phpt (renamed from ext/gmp/tests/030.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_perfect_square.phpt (renamed from ext/gmp/tests/019.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_popcount.phpt (renamed from ext/gmp/tests/035.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_pow.phpt (renamed from ext/gmp/tests/015.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_pown.phpt (renamed from ext/gmp/tests/016.phpt) | 9 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_prob_prime.phpt (renamed from ext/gmp/tests/020.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_random.phpt (renamed from ext/gmp/tests/028.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_remroot.phpt (renamed from ext/gmp/tests/041.phpt) | 49 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_root.phpt | 58 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_scan0.phpt (renamed from ext/gmp/tests/037.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_scan1.phpt (renamed from ext/gmp/tests/038.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_setbit.phpt (renamed from ext/gmp/tests/033.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_sign.phpt (renamed from ext/gmp/tests/027.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_sqrt.phpt (renamed from ext/gmp/tests/017.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_sqrtrem.phpt (renamed from ext/gmp/tests/018.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_strval.phpt (renamed from ext/gmp/tests/005.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_sub.phpt (renamed from ext/gmp/tests/006.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_testbit.phpt (renamed from ext/gmp/tests/039.phpt) | 5 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_xor.phpt (renamed from ext/gmp/tests/032.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/overloading.phpt | 60 |
44 files changed, 334 insertions, 74 deletions
diff --git a/ext/gmp/tests/001.phpt b/ext/gmp/tests/001.phpt deleted file mode 100644 index 5126f7314..000000000 --- a/ext/gmp/tests/001.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Check for gmp presence ---SKIPIF-- -<?php if (!extension_loaded("gmp")) print "skip"; ?> ---FILE-- -<?php -echo "gmp extension is available"; -/* - you can add regression tests for your extension here - - the output of your test code has to be equal to the - text in the --EXPECT-- section below for the tests - to pass, differences between the output and the - expected text are interpreted as failure - - see php5/tests/README for further information on - writing regression tests -*/ -?> ---EXPECT-- -gmp extension is available diff --git a/ext/gmp/tests/bug50175.phpt b/ext/gmp/tests/bug50175.phpt new file mode 100644 index 000000000..0998e029c --- /dev/null +++ b/ext/gmp/tests/bug50175.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #50175: gmp_init() results 0 on given base and number starting with 0x or 0b +--FILE-- +<?php + +var_dump(gmp_init('0bcd', 16)); +var_dump(gmp_init('0xyz', 36)); + +?> +--EXPECTF-- +object(GMP)#%d (1) { + ["num"]=> + string(4) "3021" +} +object(GMP)#%d (1) { + ["num"]=> + string(5) "44027" +} diff --git a/ext/gmp/tests/013.phpt b/ext/gmp/tests/gmp_abs.phpt index bb35891f2..bb35891f2 100644 --- a/ext/gmp/tests/013.phpt +++ b/ext/gmp/tests/gmp_abs.phpt diff --git a/ext/gmp/tests/029.phpt b/ext/gmp/tests/gmp_and.phpt index 9bc401031..9bc401031 100644 --- a/ext/gmp/tests/029.phpt +++ b/ext/gmp/tests/gmp_and.phpt diff --git a/ext/gmp/tests/034.phpt b/ext/gmp/tests/gmp_clrbit.phpt index 079d5d669..079d5d669 100644 --- a/ext/gmp/tests/034.phpt +++ b/ext/gmp/tests/gmp_clrbit.phpt diff --git a/ext/gmp/tests/026.phpt b/ext/gmp/tests/gmp_cmp.phpt index 83e7910d1..83e7910d1 100644 --- a/ext/gmp/tests/026.phpt +++ b/ext/gmp/tests/gmp_cmp.phpt diff --git a/ext/gmp/tests/031.phpt b/ext/gmp/tests/gmp_com.phpt index 1e0c1b469..1e0c1b469 100644 --- a/ext/gmp/tests/031.phpt +++ b/ext/gmp/tests/gmp_com.phpt diff --git a/ext/gmp/tests/009.phpt b/ext/gmp/tests/gmp_div_q.phpt index 3b75a48e1..3b75a48e1 100644 --- a/ext/gmp/tests/009.phpt +++ b/ext/gmp/tests/gmp_div_q.phpt diff --git a/ext/gmp/tests/007.phpt b/ext/gmp/tests/gmp_div_qr.phpt index e391c121f..90099249d 100644 --- a/ext/gmp/tests/007.phpt +++ b/ext/gmp/tests/gmp_div_qr.phpt @@ -10,11 +10,13 @@ var_dump(gmp_div_qr("")); var_dump(gmp_div_qr(0,1)); var_dump(gmp_div_qr(1,0)); +var_dump(gmp_div_qr(gmp_init(1), gmp_init(0))); var_dump(gmp_div_qr(12653,23482734)); var_dump(gmp_div_qr(12653,23482734, 10)); var_dump(gmp_div_qr(1123123,123)); var_dump(gmp_div_qr(1123123,123, 1)); var_dump(gmp_div_qr(1123123,123, 2)); +var_dump(gmp_div_qr(gmp_init(1123123), gmp_init(123))); var_dump(gmp_div_qr(1123123,123, GMP_ROUND_ZERO)); var_dump(gmp_div_qr(1123123,123, GMP_ROUND_PLUSINF)); var_dump(gmp_div_qr(1123123,123, GMP_ROUND_MINUSINF)); @@ -47,6 +49,9 @@ array(2) { Warning: gmp_div_qr(): Zero operand not allowed in %s on line %d bool(false) + +Warning: gmp_div_qr(): Zero operand not allowed in %s on line %d +bool(false) array(2) { [0]=> object(GMP)#%d (1) { @@ -114,6 +119,18 @@ array(2) { [0]=> object(GMP)#%d (1) { ["num"]=> + string(4) "9131" + } + [1]=> + object(GMP)#%d (1) { + ["num"]=> + string(2) "10" + } +} +array(2) { + [0]=> + object(GMP)#%d (1) { + ["num"]=> string(4) "9132" } [1]=> diff --git a/ext/gmp/tests/008.phpt b/ext/gmp/tests/gmp_div_r.phpt index c1874c86f..c1874c86f 100644 --- a/ext/gmp/tests/008.phpt +++ b/ext/gmp/tests/gmp_div_r.phpt diff --git a/ext/gmp/tests/011.phpt b/ext/gmp/tests/gmp_divexact.phpt index a42c1b6b4..a42c1b6b4 100644 --- a/ext/gmp/tests/011.phpt +++ b/ext/gmp/tests/gmp_divexact.phpt diff --git a/ext/gmp/tests/gmp_export.phpt b/ext/gmp/tests/gmp_export.phpt new file mode 100644 index 000000000..fbc8901cf --- /dev/null +++ b/ext/gmp/tests/gmp_export.phpt @@ -0,0 +1,80 @@ +--TEST-- +gmp_export() basic tests +--SKIPIF-- +<?php if (!extension_loaded("gmp")) echo "skip"; ?> +--FILE-- +<?php + +// Tests taken from GMPs own test suite. + +// format is [output, size, options, expected] +$export = [ + ['0',1,GMP_BIG_ENDIAN,''], + ['0',2,GMP_BIG_ENDIAN,''], + ['0',3,GMP_BIG_ENDIAN,''], + ['12345678',1,GMP_BIG_ENDIAN,'12345678'], + ['12345678',4,GMP_BIG_ENDIAN,'12345678'], + ['12345678',4,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'12345678'], + ['12345678',1,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'78563412'], + ['12345678',4,GMP_LITTLE_ENDIAN,'78563412'], + ['12345678',4,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'78563412'], + ['123456789ABC',2,GMP_BIG_ENDIAN,'123456789abc'], + ['123456789ABC',2,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'9abc56781234'], + ['123456789ABC',2,GMP_LITTLE_ENDIAN,'34127856bc9a'], + ['123456789ABC',2,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'bc9a78563412'], + ['112233445566778899AABBCC',4,GMP_BIG_ENDIAN,'112233445566778899aabbcc'], + ['112233445566778899AABBCC',4,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'99aabbcc5566778811223344'], + ['112233445566778899AABBCC',4,GMP_LITTLE_ENDIAN,'4433221188776655ccbbaa99'], + ['112233445566778899AABBCC',4,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'ccbbaa998877665544332211'], + ['100120023003400450056006700780089009A00AB00BC00C',8,GMP_BIG_ENDIAN,'100120023003400450056006700780089009a00ab00bc00c'], + ['100120023003400450056006700780089009A00AB00BC00C',8,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'9009a00ab00bc00c50056006700780081001200230034004'], + ['100120023003400450056006700780089009A00AB00BC00C',8,GMP_LITTLE_ENDIAN,'044003300220011008800770066005500cc00bb00aa00990'], + ['100120023003400450056006700780089009A00AB00BC00C',8,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'0cc00bb00aa0099008800770066005500440033002200110'] +]; + +$passed = true; +foreach ($export as $k => $test) { + $gmp = gmp_init($test[0], 16); + $str = gmp_export($gmp, $test[1], $test[2]); + if (is_string($str)) { + $result = bin2hex($str); + if ($result !== $test[3]) { + echo "$k: '$result' !== '{$test[3]}'\n"; + $passed = false; + } + } else { + $type = gettype($str); + echo "$k: $type !== '{$test[3]}'\n"; + } +} + +var_dump($passed); + +// Invalid arguments (zpp failure) +var_dump(gmp_export()); + +// Invalid word sizes +var_dump(gmp_export(123, -1)); +var_dump(gmp_export(123, 0)); + +// Invalid options +var_dump(gmp_export(123, 1, GMP_MSW_FIRST | GMP_LSW_FIRST)); +var_dump(gmp_export(123, 1, GMP_BIG_ENDIAN | GMP_LITTLE_ENDIAN)); + +--EXPECTF-- +bool(true) + +Warning: gmp_export() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Warning: gmp_export(): Word size must be positive, -1 given in %s on line %d +bool(false) + +Warning: gmp_export(): Word size must be positive, 0 given in %s on line %d +bool(false) + +Warning: gmp_export(): Invalid options: Conflicting word orders in %s on line %d +bool(false) + +Warning: gmp_export(): Invalid options: Conflicting word endianness in %s on line %d +bool(false) diff --git a/ext/gmp/tests/014.phpt b/ext/gmp/tests/gmp_fact.phpt index 6afccaf93..6afccaf93 100644 --- a/ext/gmp/tests/014.phpt +++ b/ext/gmp/tests/gmp_fact.phpt diff --git a/ext/gmp/tests/021.phpt b/ext/gmp/tests/gmp_gcd.phpt index 275f0bca3..275f0bca3 100644 --- a/ext/gmp/tests/021.phpt +++ b/ext/gmp/tests/gmp_gcd.phpt diff --git a/ext/gmp/tests/022.phpt b/ext/gmp/tests/gmp_gcdext.phpt index 469aa3013..469aa3013 100644 --- a/ext/gmp/tests/022.phpt +++ b/ext/gmp/tests/gmp_gcdext.phpt diff --git a/ext/gmp/tests/036.phpt b/ext/gmp/tests/gmp_hamdist.phpt index c21e03ccb..c21e03ccb 100644 --- a/ext/gmp/tests/036.phpt +++ b/ext/gmp/tests/gmp_hamdist.phpt diff --git a/ext/gmp/tests/gmp_import.phpt b/ext/gmp/tests/gmp_import.phpt new file mode 100644 index 000000000..b7ae6600e --- /dev/null +++ b/ext/gmp/tests/gmp_import.phpt @@ -0,0 +1,91 @@ +--TEST-- +gmp_import() basic tests +--SKIPIF-- +<?php if (!extension_loaded("gmp")) echo "skip"; ?> +--FILE-- +<?php + +// Tests taken from GMPs own test suite. + +// format is [expected, size, options, input] +$import = [ + ['0',1,GMP_BIG_ENDIAN,''], + ['12345678',1,GMP_BIG_ENDIAN,'12345678'], + ['12345678',4,GMP_BIG_ENDIAN,'12345678'], + ['12345678',4,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'12345678'], + ['12345678',1,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'78563412'], + ['12345678',4,GMP_LITTLE_ENDIAN,'78563412'], + ['12345678',4,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'78563412'], + ['123456789abc',2,GMP_BIG_ENDIAN,'123456789abc'], + ['123456789abc',2,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'9abc56781234'], + ['123456789abc',2,GMP_LITTLE_ENDIAN,'34127856bc9a'], + ['123456789abc',2,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'bc9a78563412'], + ['112233445566778899aabbcc',4,GMP_BIG_ENDIAN,'112233445566778899aabbcc'], + ['112233445566778899aabbcc',4,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'99aabbcc5566778811223344'], + ['112233445566778899aabbcc',4,GMP_LITTLE_ENDIAN,'4433221188776655ccbbaa99'], + ['112233445566778899aabbcc',4,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'ccbbaa998877665544332211'], + ['100120023003400450056006700780089009a00ab00bc00c',8,GMP_BIG_ENDIAN,'100120023003400450056006700780089009a00ab00bc00c'], + ['100120023003400450056006700780089009a00ab00bc00c',8,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'9009a00ab00bc00c50056006700780081001200230034004'], + ['100120023003400450056006700780089009a00ab00bc00c',8,GMP_LITTLE_ENDIAN,'044003300220011008800770066005500cc00bb00aa00990'], + ['100120023003400450056006700780089009a00ab00bc00c',8,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'0cc00bb00aa0099008800770066005500440033002200110'] +]; + +$passed = true; +foreach ($import as $k => $test) { + $gmp = gmp_import(hex2bin($test[3]), $test[1], $test[2]); + if ($gmp instanceof GMP) { + $result = gmp_strval($gmp, 16); + if ($result !== $test[0]) { + echo "$k: '$result' !== '{$test[0]}'\n"; + $passed = false; + } + } else { + $type = gettype($gmp); + echo "$k: $type !== '{$test[0]}'\n"; + } +} + +var_dump($passed); + +// Invalid arguments (zpp failure) +var_dump(gmp_import()); + +// Invalid word sizes +var_dump(gmp_import('a', -1)); +var_dump(gmp_import('a', 0)); + +// Invalid data lengths +var_dump(gmp_import('a', 2)); +var_dump(gmp_import('aa', 3)); +var_dump(gmp_import(str_repeat('a', 100), 64)); + +// Invalid options +var_dump(gmp_import('a', 1, GMP_MSW_FIRST | GMP_LSW_FIRST)); +var_dump(gmp_import('a', 1, GMP_BIG_ENDIAN | GMP_LITTLE_ENDIAN)); + +--EXPECTF-- +bool(true) + +Warning: gmp_import() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Warning: gmp_import(): Word size must be positive, -1 given in %s on line %d +bool(false) + +Warning: gmp_import(): Word size must be positive, 0 given in %s on line %d +bool(false) + +Warning: gmp_import(): Input length must be a multiple of word size in %s on line %d +bool(false) + +Warning: gmp_import(): Input length must be a multiple of word size in %s on line %d +bool(false) + +Warning: gmp_import(): Input length must be a multiple of word size in %s on line %d +bool(false) + +Warning: gmp_import(): Invalid options: Conflicting word orders in %s on line %d +bool(false) + +Warning: gmp_import(): Invalid options: Conflicting word endianness in %s on line %d +bool(false) diff --git a/ext/gmp/tests/040.phpt b/ext/gmp/tests/gmp_init.phpt index 29640ba70..29640ba70 100644 --- a/ext/gmp/tests/040.phpt +++ b/ext/gmp/tests/gmp_init.phpt diff --git a/ext/gmp/tests/004.phpt b/ext/gmp/tests/gmp_intval.phpt index 088dd08fd..088dd08fd 100644 --- a/ext/gmp/tests/004.phpt +++ b/ext/gmp/tests/gmp_intval.phpt diff --git a/ext/gmp/tests/023.phpt b/ext/gmp/tests/gmp_invert.phpt index 81a90fe16..81a90fe16 100644 --- a/ext/gmp/tests/023.phpt +++ b/ext/gmp/tests/gmp_invert.phpt diff --git a/ext/gmp/tests/024.phpt b/ext/gmp/tests/gmp_jacobi.phpt index 04ddba4f0..04ddba4f0 100644 --- a/ext/gmp/tests/024.phpt +++ b/ext/gmp/tests/gmp_jacobi.phpt diff --git a/ext/gmp/tests/025.phpt b/ext/gmp/tests/gmp_legendre.phpt index 6dde34e1e..6dde34e1e 100644 --- a/ext/gmp/tests/025.phpt +++ b/ext/gmp/tests/gmp_legendre.phpt diff --git a/ext/gmp/tests/010.phpt b/ext/gmp/tests/gmp_mod.phpt index 12e7cad2b..12e7cad2b 100644 --- a/ext/gmp/tests/010.phpt +++ b/ext/gmp/tests/gmp_mod.phpt diff --git a/ext/gmp/tests/012.phpt b/ext/gmp/tests/gmp_neg.phpt index 8ca3471cb..8ca3471cb 100644 --- a/ext/gmp/tests/012.phpt +++ b/ext/gmp/tests/gmp_neg.phpt diff --git a/ext/gmp/tests/030.phpt b/ext/gmp/tests/gmp_or.phpt index 035f070bd..035f070bd 100644 --- a/ext/gmp/tests/030.phpt +++ b/ext/gmp/tests/gmp_or.phpt diff --git a/ext/gmp/tests/019.phpt b/ext/gmp/tests/gmp_perfect_square.phpt index aa596ba9c..aa596ba9c 100644 --- a/ext/gmp/tests/019.phpt +++ b/ext/gmp/tests/gmp_perfect_square.phpt diff --git a/ext/gmp/tests/035.phpt b/ext/gmp/tests/gmp_popcount.phpt index 4b45a0448..4b45a0448 100644 --- a/ext/gmp/tests/035.phpt +++ b/ext/gmp/tests/gmp_popcount.phpt diff --git a/ext/gmp/tests/015.phpt b/ext/gmp/tests/gmp_pow.phpt index e17ecc7ba..e17ecc7ba 100644 --- a/ext/gmp/tests/015.phpt +++ b/ext/gmp/tests/gmp_pow.phpt diff --git a/ext/gmp/tests/016.phpt b/ext/gmp/tests/gmp_pown.phpt index 8a0b34458..f5857b699 100644 --- a/ext/gmp/tests/016.phpt +++ b/ext/gmp/tests/gmp_pown.phpt @@ -19,6 +19,9 @@ var_dump(gmp_strval(gmp_powm($n,$e,1000))); $m = gmp_init(900); var_dump(gmp_strval(gmp_powm($n,$e,$m))); +var_dump(gmp_powm(5, 11, 0)); +var_dump(gmp_powm(5, "11", gmp_init(0))); + var_dump(gmp_powm(array(),$e,$m)); var_dump(gmp_powm($n,array(),$m)); var_dump(gmp_powm($n,$e,array())); @@ -46,6 +49,12 @@ string(3) "331" string(3) "171" string(3) "371" +Warning: gmp_powm(): Modulus may not be zero in %s on line %d +bool(false) + +Warning: gmp_powm(): Modulus may not be zero in %s on line %d +bool(false) + Warning: gmp_powm(): Unable to convert variable to GMP - wrong type in %s on line %d bool(false) diff --git a/ext/gmp/tests/020.phpt b/ext/gmp/tests/gmp_prob_prime.phpt index f8f3e6921..f8f3e6921 100644 --- a/ext/gmp/tests/020.phpt +++ b/ext/gmp/tests/gmp_prob_prime.phpt diff --git a/ext/gmp/tests/028.phpt b/ext/gmp/tests/gmp_random.phpt index 3a876aa60..3a876aa60 100644 --- a/ext/gmp/tests/028.phpt +++ b/ext/gmp/tests/gmp_random.phpt diff --git a/ext/gmp/tests/041.phpt b/ext/gmp/tests/gmp_remroot.phpt index 6e6d95928..4a3539d87 100644 --- a/ext/gmp/tests/041.phpt +++ b/ext/gmp/tests/gmp_remroot.phpt @@ -1,21 +1,11 @@ --TEST-- -gmp_root() and gmp_rootrem() basic tests +gmp_rootrem() basic tests --SKIPIF-- <?php if (!extension_loaded("gmp")) print "skip"; ?> --FILE-- <?php -var_dump(gmp_root(1000, 3)); -var_dump(gmp_root(100, 3)); -var_dump(gmp_root(-100, 3)); - -var_dump(gmp_root(1000, 4)); -var_dump(gmp_root(100, 4)); -var_dump(gmp_root(-100, 4)); - -var_dump(gmp_root(0, 3)); -var_dump(gmp_root(100, 0)); -var_dump(gmp_root(100, -3)); +var_dump(gmp_rootrem()); var_dump(gmp_rootrem(1000, 3)); var_dump(gmp_rootrem(100, 3)); @@ -31,39 +21,8 @@ var_dump(gmp_rootrem(100, -3)); ?> --EXPECTF-- -object(GMP)#%d (1) { - ["num"]=> - string(2) "10" -} -object(GMP)#%d (1) { - ["num"]=> - string(1) "4" -} -object(GMP)#%d (1) { - ["num"]=> - string(2) "-4" -} -object(GMP)#%d (1) { - ["num"]=> - string(1) "5" -} -object(GMP)#%d (1) { - ["num"]=> - string(1) "3" -} - -Warning: gmp_root(): Can't take even root of negative number in %s on line %d -bool(false) -object(GMP)#%d (1) { - ["num"]=> - string(1) "0" -} - -Warning: gmp_root(): The root must be positive in %s on line %d -bool(false) - -Warning: gmp_root(): The root must be positive in %s on line %d -bool(false) +Warning: gmp_rootrem() expects exactly 2 parameters, 0 given in %s on line %d +NULL array(2) { [0]=> object(GMP)#%d (1) { diff --git a/ext/gmp/tests/gmp_root.phpt b/ext/gmp/tests/gmp_root.phpt new file mode 100644 index 000000000..70faf2705 --- /dev/null +++ b/ext/gmp/tests/gmp_root.phpt @@ -0,0 +1,58 @@ +--TEST-- +gmp_root() basic tests +--SKIPIF-- +<?php if (!extension_loaded("gmp")) print "skip"; ?> +--FILE-- +<?php + +var_dump(gmp_root()); + +var_dump(gmp_root(1000, 3)); +var_dump(gmp_root(100, 3)); +var_dump(gmp_root(-100, 3)); + +var_dump(gmp_root(1000, 4)); +var_dump(gmp_root(100, 4)); +var_dump(gmp_root(-100, 4)); + +var_dump(gmp_root(0, 3)); +var_dump(gmp_root(100, 0)); +var_dump(gmp_root(100, -3)); + +?> +--EXPECTF-- +Warning: gmp_root() expects exactly 2 parameters, 0 given in %s on line %d +NULL +object(GMP)#%d (1) { + ["num"]=> + string(2) "10" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "4" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "-4" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "5" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "3" +} + +Warning: gmp_root(): Can't take even root of negative number in %s on line %d +bool(false) +object(GMP)#%d (1) { + ["num"]=> + string(1) "0" +} + +Warning: gmp_root(): The root must be positive in %s on line %d +bool(false) + +Warning: gmp_root(): The root must be positive in %s on line %d +bool(false) diff --git a/ext/gmp/tests/037.phpt b/ext/gmp/tests/gmp_scan0.phpt index 2a87a968a..2a87a968a 100644 --- a/ext/gmp/tests/037.phpt +++ b/ext/gmp/tests/gmp_scan0.phpt diff --git a/ext/gmp/tests/038.phpt b/ext/gmp/tests/gmp_scan1.phpt index 7ebce9be7..7ebce9be7 100644 --- a/ext/gmp/tests/038.phpt +++ b/ext/gmp/tests/gmp_scan1.phpt diff --git a/ext/gmp/tests/033.phpt b/ext/gmp/tests/gmp_setbit.phpt index 99848959d..99848959d 100644 --- a/ext/gmp/tests/033.phpt +++ b/ext/gmp/tests/gmp_setbit.phpt diff --git a/ext/gmp/tests/027.phpt b/ext/gmp/tests/gmp_sign.phpt index 1efdc28c6..1efdc28c6 100644 --- a/ext/gmp/tests/027.phpt +++ b/ext/gmp/tests/gmp_sign.phpt diff --git a/ext/gmp/tests/017.phpt b/ext/gmp/tests/gmp_sqrt.phpt index d90f53821..d90f53821 100644 --- a/ext/gmp/tests/017.phpt +++ b/ext/gmp/tests/gmp_sqrt.phpt diff --git a/ext/gmp/tests/018.phpt b/ext/gmp/tests/gmp_sqrtrem.phpt index 2fca463da..2fca463da 100644 --- a/ext/gmp/tests/018.phpt +++ b/ext/gmp/tests/gmp_sqrtrem.phpt diff --git a/ext/gmp/tests/005.phpt b/ext/gmp/tests/gmp_strval.phpt index 79fd73ecf..79fd73ecf 100644 --- a/ext/gmp/tests/005.phpt +++ b/ext/gmp/tests/gmp_strval.phpt diff --git a/ext/gmp/tests/006.phpt b/ext/gmp/tests/gmp_sub.phpt index e1d9df67d..e1d9df67d 100644 --- a/ext/gmp/tests/006.phpt +++ b/ext/gmp/tests/gmp_sub.phpt diff --git a/ext/gmp/tests/039.phpt b/ext/gmp/tests/gmp_testbit.phpt index 399c51137..ab40abed7 100644 --- a/ext/gmp/tests/039.phpt +++ b/ext/gmp/tests/gmp_testbit.phpt @@ -5,6 +5,8 @@ gmp_testbit() basic tests --FILE-- <?php +var_dump(gmp_testbit()); + $n = gmp_init(0); var_dump(gmp_testbit($n, -10)); var_dump(gmp_testbit($n, 0)); @@ -38,6 +40,9 @@ var_dump(gmp_strval($n)); echo "Done\n"; ?> --EXPECTF-- +Warning: gmp_testbit() expects exactly 2 parameters, 0 given in %s on line %d +NULL + Warning: gmp_testbit(): Index must be greater than or equal to zero in %s on line %d bool(false) bool(false) diff --git a/ext/gmp/tests/032.phpt b/ext/gmp/tests/gmp_xor.phpt index 2b0d29a62..2b0d29a62 100644 --- a/ext/gmp/tests/032.phpt +++ b/ext/gmp/tests/gmp_xor.phpt diff --git a/ext/gmp/tests/overloading.phpt b/ext/gmp/tests/overloading.phpt index 0d8f5cfed..3520f58bd 100644 --- a/ext/gmp/tests/overloading.phpt +++ b/ext/gmp/tests/overloading.phpt @@ -16,6 +16,10 @@ var_dump($a - $b); var_dump($a - 17); var_dump(42 - $b); +var_dump($a * $b); +var_dump($a * 17); +var_dump(42 * $b); + var_dump($a / $b); var_dump($a / 17); var_dump(42 / $b); @@ -26,7 +30,9 @@ var_dump($a % 17); var_dump(42 % $b); var_dump($a % 0); -// sl, sr +var_dump($a ** $b); +var_dump($a ** 17); +var_dump(42 ** $b); var_dump($a | $b); var_dump($a | 17); @@ -47,6 +53,9 @@ var_dump(42 << $b); var_dump($a >> 2); var_dump(-$a >> 2); +var_dump($a << -1); +var_dump($a >> -1); + var_dump(~$a); var_dump(-$a); var_dump(+$a); @@ -83,9 +92,14 @@ var_dump(--$a); var_dump($a--); var_dump($a); -$x = gmp_init(3); -$y = gmp_init(2); -var_dump($x ** $y); +// Test operator that was not overloaded + +var_dump($a . $b); +var_dump($a . '17'); +var_dump('42' . $b); + +$a .= '17'; +var_dump($a); ?> --EXPECTF-- @@ -115,6 +129,18 @@ object(GMP)#%d (1) { } object(GMP)#%d (1) { ["num"]=> + string(3) "714" +} +object(GMP)#%d (1) { + ["num"]=> + string(3) "714" +} +object(GMP)#%d (1) { + ["num"]=> + string(3) "714" +} +object(GMP)#%d (1) { + ["num"]=> string(1) "2" } object(GMP)#%d (1) { @@ -145,6 +171,18 @@ Warning: main(): Zero operand not allowed in %s on line %d bool(false) object(GMP)#%d (1) { ["num"]=> + string(28) "3937657486715347520027492352" +} +object(GMP)#%d (1) { + ["num"]=> + string(28) "3937657486715347520027492352" +} +object(GMP)#%d (1) { + ["num"]=> + string(28) "3937657486715347520027492352" +} +object(GMP)#%d (1) { + ["num"]=> string(2) "59" } object(GMP)#%d (1) { @@ -199,6 +237,12 @@ object(GMP)#%d (1) { ["num"]=> string(3) "-11" } + +Warning: main(): Shift cannot be negative in %s on line %d +bool(false) + +Warning: main(): Shift cannot be negative in %s on line %d +bool(false) object(GMP)#%d (1) { ["num"]=> string(3) "-43" @@ -260,7 +304,7 @@ object(GMP)#%d (1) { ["num"]=> string(2) "42" } -object(GMP)#%d (1) { - ["num"]=> - string(1) "9" -} +string(4) "4217" +string(4) "4217" +string(4) "4217" +string(4) "4217" |