1--TEST-- 2gmp_div_r() tests 3--SKIPIF-- 4<?php if (!extension_loaded("gmp")) print "skip"; ?> 5--FILE-- 6<?php 7 8var_dump($r = gmp_div_r(0,1)); 9 10try { 11 var_dump($r = gmp_div_r(1,0)); 12} catch (\DivisionByZeroError $e) { 13 echo $e->getMessage() . \PHP_EOL; 14} 15 16var_dump($r = gmp_div_r(12653,23482734)); 17try { 18 var_dump($r = gmp_div_r(12653,23482734, 10)); 19} catch (\ValueError $e) { 20 echo $e->getMessage() . \PHP_EOL; 21} 22var_dump($r = gmp_div_r(1123123,123)); 23var_dump($r = gmp_div_r(1123123,123, 1)); 24var_dump($r = gmp_div_r(1123123,123, 2)); 25var_dump($r = gmp_div_r(1123123,123, GMP_ROUND_ZERO)); 26var_dump($r = gmp_div_r(1123123,123, GMP_ROUND_PLUSINF)); 27var_dump($r = gmp_div_r(1123123,123, GMP_ROUND_MINUSINF)); 28 29$fp = fopen(__FILE__, 'r'); 30 31try { 32 var_dump(gmp_div_r($fp, $fp)); 33} catch (\TypeError $e) { 34 echo $e->getMessage() . \PHP_EOL; 35} 36try { 37 var_dump(gmp_div_r(array(), array())); 38} catch (\TypeError $e) { 39 echo $e->getMessage() . \PHP_EOL; 40} 41 42echo "Done\n"; 43?> 44--EXPECT-- 45object(GMP)#1 (1) { 46 ["num"]=> 47 string(1) "0" 48} 49Division by zero 50object(GMP)#3 (1) { 51 ["num"]=> 52 string(5) "12653" 53} 54gmp_div_r(): Argument #3 ($rounding_mode) must be one of GMP_ROUND_ZERO, GMP_ROUND_PLUSINF, or GMP_ROUND_MINUSINF 55object(GMP)#2 (1) { 56 ["num"]=> 57 string(2) "10" 58} 59object(GMP)#3 (1) { 60 ["num"]=> 61 string(4) "-113" 62} 63object(GMP)#2 (1) { 64 ["num"]=> 65 string(2) "10" 66} 67object(GMP)#3 (1) { 68 ["num"]=> 69 string(2) "10" 70} 71object(GMP)#2 (1) { 72 ["num"]=> 73 string(4) "-113" 74} 75object(GMP)#3 (1) { 76 ["num"]=> 77 string(2) "10" 78} 79gmp_div_r(): Argument #1 ($num1) must be of type GMP|string|int, resource given 80gmp_div_r(): Argument #1 ($num1) must be of type GMP|string|int, array given 81Done 82