xref: /php-src/ext/gmp/tests/bug32773.phpt (revision e9f783fc)
1--TEST--
2Bug #32773 (binary GMP functions returns unexpected value, when second parameter is int(0))
3--EXTENSIONS--
4gmp
5--FILE--
6<?php
7echo '10 + 0 = ', gmp_strval(gmp_add(10, 0)), "\n";
8echo '10 + "0" = ', gmp_strval(gmp_add(10, '0')), "\n";
9
10try {
11    var_dump(gmp_div(10, 0));
12} catch (\DivisionByZeroError $e) {
13    echo $e->getMessage() . \PHP_EOL;
14}
15try {
16    var_dump(gmp_div_qr(10, 0));
17} catch (\DivisionByZeroError $e) {
18    echo $e->getMessage() . \PHP_EOL;
19}
20
21?>
22--EXPECT--
2310 + 0 = 10
2410 + "0" = 10
25Division by zero
26Division by zero
27