negative_scale.phpt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. --TEST--
  2. all errors on negative scale
  3. --EXTENSIONS--
  4. bcmath
  5. --INI--
  6. bcmath.scale=0
  7. --FILE--
  8. <?php
  9. try {
  10. bcadd('1','2',-1);
  11. } catch (\ValueError $e) {
  12. echo $e->getMessage() . \PHP_EOL;
  13. }
  14. try {
  15. bcsub('1','2',-1);
  16. } catch (\ValueError $e) {
  17. echo $e->getMessage() . \PHP_EOL;
  18. }
  19. try {
  20. bcmul('1','2',-1);
  21. } catch (\ValueError $e) {
  22. echo $e->getMessage() . \PHP_EOL;
  23. }
  24. try {
  25. bcdiv('1','2',-1);
  26. } catch (\ValueError $e) {
  27. echo $e->getMessage() . \PHP_EOL;
  28. }
  29. try {
  30. bcmod('1','2',-1);
  31. } catch (\ValueError $e) {
  32. echo $e->getMessage() . \PHP_EOL;
  33. }
  34. try {
  35. bcpowmod('1', '2', '3', -9);
  36. } catch (\ValueError $e) {
  37. echo $e->getMessage() . \PHP_EOL;
  38. }
  39. try {
  40. bcpow('1', '2', -1);
  41. } catch (\ValueError $e) {
  42. echo $e->getMessage() . \PHP_EOL;
  43. }
  44. try {
  45. bcsqrt('9', -1);
  46. } catch (\ValueError $e) {
  47. echo $e->getMessage() . \PHP_EOL;
  48. }
  49. try {
  50. bccomp('1', '2', -1);
  51. } catch (\ValueError $e) {
  52. echo $e->getMessage() . \PHP_EOL;
  53. }
  54. try {
  55. bcscale(-1);
  56. } catch (\ValueError $e) {
  57. echo $e->getMessage() . \PHP_EOL;
  58. }
  59. ?>
  60. --EXPECT--
  61. bcadd(): Argument #3 ($scale) must be between 0 and 2147483647
  62. bcsub(): Argument #3 ($scale) must be between 0 and 2147483647
  63. bcmul(): Argument #3 ($scale) must be between 0 and 2147483647
  64. bcdiv(): Argument #3 ($scale) must be between 0 and 2147483647
  65. bcmod(): Argument #3 ($scale) must be between 0 and 2147483647
  66. bcpowmod(): Argument #4 ($scale) must be between 0 and 2147483647
  67. bcpow(): Argument #3 ($scale) must be between 0 and 2147483647
  68. bcsqrt(): Argument #2 ($scale) must be between 0 and 2147483647
  69. bccomp(): Argument #3 ($scale) must be between 0 and 2147483647
  70. bcscale(): Argument #1 ($scale) must be between 0 and 2147483647