xref: /PHP-8.0/ext/gmp/tests/bug32773.phpt (revision e208cb23)
1--TEST--
2Bug #32773 (binary GMP functions returns unexpected value, when second parameter is int(0))
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
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