diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2017-09-18 15:04:44 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2017-09-18 15:21:22 +0200 |
commit | 73af7a847c5f08d32802d41fc45ed4b01ec9fb9c (patch) | |
tree | 528ea68ade394772d0640509eab2104cefb24efe /ext/bcmath/tests | |
parent | f63bfea105cd2d1285a1189c197d8371cad5f403 (diff) | |
parent | 870ed5106d6274905b5aa4341429deef12c92e55 (diff) | |
download | php-git-73af7a847c5f08d32802d41fc45ed4b01ec9fb9c.tar.gz |
Merge branch 'pull-request/2742'
* pull-request/2742:
Fixed bug #66364 (BCMath bcmul ignores scale parameter)
Diffstat (limited to 'ext/bcmath/tests')
-rw-r--r-- | ext/bcmath/tests/bcpow.phpt | 2 | ||||
-rw-r--r-- | ext/bcmath/tests/bcpow_error1.phpt | 2 | ||||
-rw-r--r-- | ext/bcmath/tests/bcpow_error2.phpt | 2 | ||||
-rw-r--r-- | ext/bcmath/tests/bug.66364.phpt | 14 | ||||
-rw-r--r-- | ext/bcmath/tests/scale.phpt | 27 | ||||
-rw-r--r-- | ext/bcmath/tests/scale_ini.phpt | 29 |
6 files changed, 73 insertions, 3 deletions
diff --git a/ext/bcmath/tests/bcpow.phpt b/ext/bcmath/tests/bcpow.phpt index 141ec61d92..ad642a57be 100644 --- a/ext/bcmath/tests/bcpow.phpt +++ b/ext/bcmath/tests/bcpow.phpt @@ -13,6 +13,6 @@ echo bcpow("-2.555", "5", 2),"\n"; ?> --EXPECT-- 1 --32 +-32.0000 18446744073709551616 -108.88 diff --git a/ext/bcmath/tests/bcpow_error1.phpt b/ext/bcmath/tests/bcpow_error1.phpt index 1075986587..d3189f062a 100644 --- a/ext/bcmath/tests/bcpow_error1.phpt +++ b/ext/bcmath/tests/bcpow_error1.phpt @@ -11,5 +11,5 @@ var_dump(bcpow('1', '1.1', 2)); ===DONE=== --EXPECTF-- Warning: bcpow(): non-zero scale in exponent in %s on line %d -string(1) "1" +string(4) "1.00" ===DONE=== diff --git a/ext/bcmath/tests/bcpow_error2.phpt b/ext/bcmath/tests/bcpow_error2.phpt index c58a737087..49fd0b88d3 100644 --- a/ext/bcmath/tests/bcpow_error2.phpt +++ b/ext/bcmath/tests/bcpow_error2.phpt @@ -11,5 +11,5 @@ var_dump(bcpow('0', '9223372036854775808', 2)); ===DONE=== --EXPECTF-- Warning: bcpow(): exponent too large in %s on line %d -string(1) "1" +string(4) "1.00" ===DONE=== diff --git a/ext/bcmath/tests/bug.66364.phpt b/ext/bcmath/tests/bug.66364.phpt new file mode 100644 index 0000000000..564f40e6da --- /dev/null +++ b/ext/bcmath/tests/bug.66364.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #66364 (BCMath bcmul ignores scale parameter) +--SKIPIF-- +<?php +if (!extension_loaded('bcmath')) die('skip bcmath extension not available'); +?> +--FILE-- +<?php +var_dump(bcmul('0.3', '0.2', 4)); +?> +===DONE=== +--EXPECT-- +string(6) "0.0600" +===DONE=== diff --git a/ext/bcmath/tests/scale.phpt b/ext/bcmath/tests/scale.phpt new file mode 100644 index 0000000000..d49e530511 --- /dev/null +++ b/ext/bcmath/tests/scale.phpt @@ -0,0 +1,27 @@ +--TEST-- +BCMath functions return result with requested scale +--SKIPIF-- +<?php +if (!extension_loaded('bcmath')) die('skip bcmath extension not available'); +?> +--FILE-- +<?php +echo + 'bcadd: ', bcadd('2', '1', 5), PHP_EOL, + 'bcdiv: ', bcdiv('2', '1', 5), PHP_EOL, + 'bcmul: ', bcmul('2', '1', 5), PHP_EOL, + 'bcpow: ', bcpow('2', '1', 5), PHP_EOL, + 'bcpowmod: ', bcpowmod('2', '1', '3', 5), PHP_EOL, + 'bcsqrt: ', bcsqrt('4', 5), PHP_EOL, + 'bcsub: ', bcsub('2', '1', 5), PHP_EOL; +?> +===DONE=== +--EXPECT-- +bcadd: 3.00000 +bcdiv: 2.00000 +bcmul: 2.00000 +bcpow: 2.00000 +bcpowmod: 2.00000 +bcsqrt: 2.00000 +bcsub: 1.00000 +===DONE=== diff --git a/ext/bcmath/tests/scale_ini.phpt b/ext/bcmath/tests/scale_ini.phpt new file mode 100644 index 0000000000..66d9d482bf --- /dev/null +++ b/ext/bcmath/tests/scale_ini.phpt @@ -0,0 +1,29 @@ +--TEST-- +BCMath functions return result with default scale +--SKIPIF-- +<?php +if (!extension_loaded('bcmath')) die('skip bcmath extension not available'); +?> +--INI-- +bcmath.scale = 5 +--FILE-- +<?php +echo + 'bcadd: ', bcadd('2', '1'), PHP_EOL, + 'bcdiv: ', bcdiv('2', '1'), PHP_EOL, + 'bcmul: ', bcmul('2', '1'), PHP_EOL, + 'bcpow: ', bcpow('2', '1'), PHP_EOL, + 'bcpowmod: ', bcpowmod('2', '1', '3'), PHP_EOL, + 'bcsqrt: ', bcsqrt('4'), PHP_EOL, + 'bcsub: ', bcsub('2', '1'), PHP_EOL; +?> +===DONE=== +--EXPECT-- +bcadd: 3.00000 +bcdiv: 2.00000 +bcmul: 2.00000 +bcpow: 2.00000 +bcpowmod: 2.00000 +bcsqrt: 2.00000 +bcsub: 1.00000 +===DONE=== |