diff options
Diffstat (limited to 'ext/bcmath/tests')
31 files changed, 443 insertions, 0 deletions
diff --git a/ext/bcmath/tests/bcadd.phpt b/ext/bcmath/tests/bcadd.phpt new file mode 100644 index 0000000..61552ee --- /dev/null +++ b/ext/bcmath/tests/bcadd.phpt @@ -0,0 +1,16 @@ +--TEST-- +bcadd() function +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcadd("1", "2"),"\n"; +echo bcadd("-1", "5", 4),"\n"; +echo bcadd("1928372132132819737213", "8728932001983192837219398127471", 2),"\n"; +?> +--EXPECT-- +3 +4.0000 +8728932003911564969352217864684.00 diff --git a/ext/bcmath/tests/bcadd_error1.phpt b/ext/bcmath/tests/bcadd_error1.phpt new file mode 100644 index 0000000..c7d526e --- /dev/null +++ b/ext/bcmath/tests/bcadd_error1.phpt @@ -0,0 +1,12 @@ +--TEST-- +bcadd() incorrect argument count +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcadd(); +?> +--EXPECTF-- +Warning: bcadd() expects at least 2 parameters, 0 given in %s on line %d
\ No newline at end of file diff --git a/ext/bcmath/tests/bcadd_variation001.phpt b/ext/bcmath/tests/bcadd_variation001.phpt new file mode 100644 index 0000000..a0a64f6 --- /dev/null +++ b/ext/bcmath/tests/bcadd_variation001.phpt @@ -0,0 +1,16 @@ +--TEST-- +bcadd() with non-integers +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=5 +--FILE-- +<?php +echo bcadd("2.2", "4.3", "2")."\n"; +echo bcadd("2.2", "-7.3", "1")."\n"; +echo bcadd("-4.27", "7.3"); +?> +--EXPECTF-- +6.50 +-5.1 +3.03000
\ No newline at end of file diff --git a/ext/bcmath/tests/bccomp.phpt b/ext/bcmath/tests/bccomp.phpt new file mode 100644 index 0000000..b2bf9f4 --- /dev/null +++ b/ext/bcmath/tests/bccomp.phpt @@ -0,0 +1,18 @@ +--TEST-- +bccomp() function +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bccomp("-1", "5", 4),"\n"; +echo bccomp("1928372132132819737213", "8728932001983192837219398127471"),"\n"; +echo bccomp("1.00000000000000000001", "1", 2),"\n"; +echo bccomp("97321", "2321"),"\n"; +?> +--EXPECT-- +-1 +-1 +0 +1 diff --git a/ext/bcmath/tests/bccomp_variation001.phpt b/ext/bcmath/tests/bccomp_variation001.phpt new file mode 100644 index 0000000..456f235 --- /dev/null +++ b/ext/bcmath/tests/bccomp_variation001.phpt @@ -0,0 +1,16 @@ +--TEST-- +bccomp() with non-integers +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bccomp("2.2", "2.2", "2")."\n"; +echo bccomp("2.32", "2.2", "2")."\n"; +echo bccomp("2.29", "2.3", "2"); +?> +--EXPECTF-- +0 +1 +-1
\ No newline at end of file diff --git a/ext/bcmath/tests/bccomp_variation002.phpt b/ext/bcmath/tests/bccomp_variation002.phpt new file mode 100644 index 0000000..73fbc82 --- /dev/null +++ b/ext/bcmath/tests/bccomp_variation002.phpt @@ -0,0 +1,16 @@ +--TEST-- +bccomp() with negative value +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bccomp("-2", "-2")."\n"; +echo bccomp("-2", "2", "1")."\n"; +echo bccomp("-2.29", "-2.3", "2"); +?> +--EXPECTF-- +0 +-1 +1
\ No newline at end of file diff --git a/ext/bcmath/tests/bcdiv.phpt b/ext/bcmath/tests/bcdiv.phpt new file mode 100644 index 0000000..cda1949 --- /dev/null +++ b/ext/bcmath/tests/bcdiv.phpt @@ -0,0 +1,18 @@ +--TEST-- +bcdiv() function +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcdiv("1", "2"),"\n"; +echo bcdiv("1", "2", 2),"\n"; +echo bcdiv("-1", "5", 4),"\n"; +echo bcdiv("8728932001983192837219398127471", "1928372132132819737213", 2),"\n"; +?> +--EXPECT-- +0 +0.50 +-0.2000 +4526580661.75 diff --git a/ext/bcmath/tests/bcdiv_error1.phpt b/ext/bcmath/tests/bcdiv_error1.phpt new file mode 100644 index 0000000..c69d36b --- /dev/null +++ b/ext/bcmath/tests/bcdiv_error1.phpt @@ -0,0 +1,14 @@ +--TEST-- +bcdiv — Divide two arbitrary precision numbers +--CREDITS-- +TestFest2009 +Antoni Torrents +antoni@solucionsinternet.com +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--FILE-- +<?php +echo bcdiv('10.99', '0'); +?> +--EXPECTF-- +Warning: bcdiv(): Division by zero in %s.php on line %d diff --git a/ext/bcmath/tests/bcdiv_error2.phpt b/ext/bcmath/tests/bcdiv_error2.phpt new file mode 100644 index 0000000..a90c79e --- /dev/null +++ b/ext/bcmath/tests/bcdiv_error2.phpt @@ -0,0 +1,13 @@ +--TEST-- +bcdiv — Divide two arbitrary precision numbers +--CREDITS-- +Antoni Torrents +antoni@solucionsinternet.com +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--FILE-- +<?php +echo bcdiv('1', '2', '3', '4'); +?> +--EXPECTF-- +Warning: bcdiv() expects at most 3 parameters, 4 given in %s.php on line %d diff --git a/ext/bcmath/tests/bcmod.phpt b/ext/bcmath/tests/bcmod.phpt new file mode 100644 index 0000000..1d7be48 --- /dev/null +++ b/ext/bcmath/tests/bcmod.phpt @@ -0,0 +1,16 @@ +--TEST-- +bcmod() function +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcmod("11", "2"),"\n"; +echo bcmod("-1", "5"),"\n"; +echo bcmod("8728932001983192837219398127471", "1928372132132819737213"),"\n"; +?> +--EXPECT-- +1 +-1 +1459434331351930289678 diff --git a/ext/bcmath/tests/bcmod_error1.phpt b/ext/bcmath/tests/bcmod_error1.phpt new file mode 100644 index 0000000..e36dce2 --- /dev/null +++ b/ext/bcmath/tests/bcmod_error1.phpt @@ -0,0 +1,13 @@ +--TEST-- +bcmod — Get modulus of an arbitrary precision number +--CREDITS-- +Antoni Torrents +antoni@solucionsinternet.com +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--FILE-- +<?php +echo bcmod('1', '2', '3'); +?> +--EXPECTF-- +Warning: bcmod() expects exactly 2 parameters, 3 given in %s.php on line %d diff --git a/ext/bcmath/tests/bcmod_error2.phpt b/ext/bcmath/tests/bcmod_error2.phpt new file mode 100644 index 0000000..bac49c8 --- /dev/null +++ b/ext/bcmath/tests/bcmod_error2.phpt @@ -0,0 +1,12 @@ +--TEST-- +bcmod() - mod by 0 +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcmod("10", "0"); +?> +--EXPECTF-- +Warning: bcmod(): Division by zero in %s on line %d
\ No newline at end of file diff --git a/ext/bcmath/tests/bcmul.phpt b/ext/bcmath/tests/bcmul.phpt new file mode 100644 index 0000000..0ff322f --- /dev/null +++ b/ext/bcmath/tests/bcmul.phpt @@ -0,0 +1,18 @@ +--TEST-- +bcmul() function +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcmul("1", "2"),"\n"; +echo bcmul("-3", "5"),"\n"; +echo bcmul("1234567890", "9876543210"),"\n"; +echo bcmul("2.5", "1.5", 2),"\n"; +?> +--EXPECT-- +2 +-15 +12193263111263526900 +3.75 diff --git a/ext/bcmath/tests/bcmul_error1.phpt b/ext/bcmath/tests/bcmul_error1.phpt new file mode 100644 index 0000000..ec36633 --- /dev/null +++ b/ext/bcmath/tests/bcmul_error1.phpt @@ -0,0 +1,12 @@ +--TEST-- +bcmul() incorrect argument count +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcmul(); +?> +--EXPECTF-- +Warning: bcmul() expects at least 2 parameters, 0 given in %s on line %d
\ No newline at end of file diff --git a/ext/bcmath/tests/bcpow.phpt b/ext/bcmath/tests/bcpow.phpt new file mode 100644 index 0000000..bdd4e08 --- /dev/null +++ b/ext/bcmath/tests/bcpow.phpt @@ -0,0 +1,16 @@ +--TEST-- +bcpow() function +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcpow("1", "2"),"\n"; +echo bcpow("-2", "5", 4),"\n"; +echo bcpow("2", "64"),"\n"; +?> +--EXPECT-- +1 +-32 +18446744073709551616 diff --git a/ext/bcmath/tests/bcpow_error3.phpt b/ext/bcmath/tests/bcpow_error3.phpt new file mode 100644 index 0000000..4b937a1 --- /dev/null +++ b/ext/bcmath/tests/bcpow_error3.phpt @@ -0,0 +1,12 @@ +--TEST-- +bcpow() incorrect argument count +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcpow(); +?> +--EXPECTF-- +Warning: bcpow() expects at least 2 parameters, 0 given in %s on line %d
\ No newline at end of file diff --git a/ext/bcmath/tests/bcpow_variation001.phpt b/ext/bcmath/tests/bcpow_variation001.phpt new file mode 100644 index 0000000..58e96b3 --- /dev/null +++ b/ext/bcmath/tests/bcpow_variation001.phpt @@ -0,0 +1,12 @@ +--TEST-- +bcpow() with a negative exponent +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcpow("2", "-4"); +?> +--EXPECTF-- +0
\ No newline at end of file diff --git a/ext/bcmath/tests/bcpowmod.phpt b/ext/bcmath/tests/bcpowmod.phpt new file mode 100644 index 0000000..6b1f30e --- /dev/null +++ b/ext/bcmath/tests/bcpowmod.phpt @@ -0,0 +1,16 @@ +--TEST-- +bcpowmod() - Raise an arbitrary precision number to another, reduced by a specified modulus +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcpowmod("5", "2", "7") . "\n"; +echo bcpowmod("-2", "5", "7") . "\n"; +echo bcpowmod("10", "2147483648", "2047"); +?> +--EXPECT-- +4 +-4 +790
\ No newline at end of file diff --git a/ext/bcmath/tests/bcpowmod_error1.phpt b/ext/bcmath/tests/bcpowmod_error1.phpt new file mode 100644 index 0000000..2dc292e --- /dev/null +++ b/ext/bcmath/tests/bcpowmod_error1.phpt @@ -0,0 +1,13 @@ +--TEST-- +bcpowmod — Raise an arbitrary precision number to another, reduced by a specified modulus +--CREDITS-- +Antoni Torrents +antoni@solucionsinternet.com +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--FILE-- +<?php +echo bcpowmod('1'); +?> +--EXPECTF-- +Warning: bcpowmod() expects at least 3 parameters, 1 given in %s.php on line %d diff --git a/ext/bcmath/tests/bcpowmod_error2.phpt b/ext/bcmath/tests/bcpowmod_error2.phpt new file mode 100644 index 0000000..e0a9963 --- /dev/null +++ b/ext/bcmath/tests/bcpowmod_error2.phpt @@ -0,0 +1,13 @@ +--TEST-- +bcpowmod — Raise an arbitrary precision number to another, reduced by a specified modulus +--CREDITS-- +Antoni Torrents +antoni@solucionsinternet.com +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--FILE-- +<?php +echo bcpowmod('1', '2'); +?> +--EXPECTF-- +Warning: bcpowmod() expects at least 3 parameters, 2 given in %s.php on line %d diff --git a/ext/bcmath/tests/bcpowmod_error3.phpt b/ext/bcmath/tests/bcpowmod_error3.phpt new file mode 100644 index 0000000..c3f8df8 --- /dev/null +++ b/ext/bcmath/tests/bcpowmod_error3.phpt @@ -0,0 +1,13 @@ +--TEST-- +bcpowmod — Raise an arbitrary precision number to another, reduced by a specified modulus +--CREDITS-- +Antoni Torrents +antoni@solucionsinternet.com +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--FILE-- +<?php +echo bcpowmod('1', '2', '3', '4', '5'); +?> +--EXPECTF-- +Warning: bcpowmod() expects at most 4 parameters, 5 given in %s.php on line %d diff --git a/ext/bcmath/tests/bcscale.phpt b/ext/bcmath/tests/bcscale.phpt new file mode 100644 index 0000000..4fc2f85 --- /dev/null +++ b/ext/bcmath/tests/bcscale.phpt @@ -0,0 +1,21 @@ +--TEST-- +bcscale() function +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcadd("1", "2"),"\n"; +bcscale(2); +echo bcadd("1", "2"),"\n"; +bcscale(10); +echo bcadd("1", "2"),"\n"; +bcscale(0); +echo bcadd("1", "2"),"\n"; +?> +--EXPECT-- +3 +3.00 +3.0000000000 +3 diff --git a/ext/bcmath/tests/bcscale_variation001.phpt b/ext/bcmath/tests/bcscale_variation001.phpt new file mode 100644 index 0000000..2a7b8db --- /dev/null +++ b/ext/bcmath/tests/bcscale_variation001.phpt @@ -0,0 +1,13 @@ +--TEST-- +bcscale() with negative argument +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +bcscale(-4); +echo bcdiv("20.56", "4"); +?> +--EXPECTF-- +5
\ No newline at end of file diff --git a/ext/bcmath/tests/bcscale_variation002.phpt b/ext/bcmath/tests/bcscale_variation002.phpt new file mode 100644 index 0000000..0db6cff --- /dev/null +++ b/ext/bcmath/tests/bcscale_variation002.phpt @@ -0,0 +1,12 @@ +--TEST-- +bcadd() incorrect argument count +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=-2 +--FILE-- +<?php +echo bcadd("-4.27", "7.3"); +?> +--EXPECTF-- +3
\ No newline at end of file diff --git a/ext/bcmath/tests/bcsqrt.phpt b/ext/bcmath/tests/bcsqrt.phpt new file mode 100644 index 0000000..46d92fd --- /dev/null +++ b/ext/bcmath/tests/bcsqrt.phpt @@ -0,0 +1,14 @@ +--TEST-- +bcsqrt() function +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcsqrt("9"),"\n"; +echo bcsqrt("1928372132132819737213", 5),"\n"; +?> +--EXPECT-- +3 +43913234134.28826 diff --git a/ext/bcmath/tests/bcsqrt_error1.phpt b/ext/bcmath/tests/bcsqrt_error1.phpt new file mode 100644 index 0000000..1f213db --- /dev/null +++ b/ext/bcmath/tests/bcsqrt_error1.phpt @@ -0,0 +1,13 @@ +--TEST-- +bcsqrt — Get the square root of an arbitrary precision number +--CREDITS-- +Antoni Torrents +antoni@solucionsinternet.com +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--FILE-- +<?php +echo bcsqrt('-9'); +?> +--EXPECTF-- +Warning: bcsqrt(): Square root of negative number in %s.php on line %d diff --git a/ext/bcmath/tests/bcsqrt_error2.phpt b/ext/bcmath/tests/bcsqrt_error2.phpt new file mode 100644 index 0000000..c52e2f3 --- /dev/null +++ b/ext/bcmath/tests/bcsqrt_error2.phpt @@ -0,0 +1,12 @@ +--TEST-- +bcsqrt() incorrect argument count +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcsqrt(); +?> +--EXPECTF-- +Warning: bcsqrt() expects at least 1 parameter, 0 given in %s on line %d
\ No newline at end of file diff --git a/ext/bcmath/tests/bcsqrt_variation001.phpt b/ext/bcmath/tests/bcsqrt_variation001.phpt new file mode 100644 index 0000000..5e9ec1e --- /dev/null +++ b/ext/bcmath/tests/bcsqrt_variation001.phpt @@ -0,0 +1,12 @@ +--TEST-- +bcsqrt() with argument of 0 +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcsqrt("0"); +?> +--EXPECTF-- +0
\ No newline at end of file diff --git a/ext/bcmath/tests/bcsub.phpt b/ext/bcmath/tests/bcsub.phpt new file mode 100644 index 0000000..7172649 --- /dev/null +++ b/ext/bcmath/tests/bcsub.phpt @@ -0,0 +1,16 @@ +--TEST-- +bcsub() function +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcsub("1", "2"),"\n"; +echo bcsub("-1", "5", 4),"\n"; +echo bcsub("8728932001983192837219398127471", "1928372132132819737213", 2),"\n"; +?> +--EXPECT-- +-1 +-6.0000 +8728932000054820705086578390258.00 diff --git a/ext/bcmath/tests/bcsub_error1.phpt b/ext/bcmath/tests/bcsub_error1.phpt new file mode 100644 index 0000000..51c020e --- /dev/null +++ b/ext/bcmath/tests/bcsub_error1.phpt @@ -0,0 +1,12 @@ +--TEST-- +bcsub() incorrect argument count +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--INI-- +bcmath.scale=0 +--FILE-- +<?php +echo bcsub(); +?> +--EXPECTF-- +Warning: bcsub() expects at least 2 parameters, 0 given in %s on line %d
\ No newline at end of file diff --git a/ext/bcmath/tests/bug60377.phpt b/ext/bcmath/tests/bug60377.phpt new file mode 100644 index 0000000..7c42002 --- /dev/null +++ b/ext/bcmath/tests/bug60377.phpt @@ -0,0 +1,13 @@ +--TEST-- +bcscale related problem on 64bits platforms +--SKIPIF-- +<?php if(!extension_loaded("bcmath")) print "skip"; ?> +--FILE-- +<?php +$var48 = bcscale(634314234334311); +$var67 = bcsqrt(false); +$var414 = bcadd(false,null,10); +die('ALIVE'); +?> +--EXPECTF-- +ALIVE |