ext/gmp: Add behavioural tests for operator overloading

This commit is contained in:
Gina Peter Banyard 2024-09-23 20:24:01 +01:00
parent f9453a889d
commit fe02fd5095
No known key found for this signature in database
GPG key ID: 3306078E3194AEBD
11 changed files with 1073 additions and 0 deletions

View file

@ -0,0 +1,53 @@
--TEST--
GMP comparison operator overloading supports null
--EXTENSIONS--
gmp
--FILE--
<?php
$num = gmp_init(42);
try {
var_dump($num < null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num > null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num <= null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num >= null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num == null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num <=> null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
int(1)

View file

@ -0,0 +1,93 @@
--TEST--
GMP operator overloading does not support []
--EXTENSIONS--
gmp
--FILE--
<?php
$num = gmp_init(42);
try {
var_dump($num + []);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num - []);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num * []);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num / []);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num % []);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ** []);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num | []);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num & []);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ^ []);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num << []);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num >> []);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
TypeError: Number must be of type GMP|string|int, array given
TypeError: Number must be of type GMP|string|int, array given
TypeError: Number must be of type GMP|string|int, array given
TypeError: Number must be of type GMP|string|int, array given
TypeError: Number must be of type GMP|string|int, array given
object(GMP)#3 (1) {
["num"]=>
string(1) "1"
}
TypeError: Number must be of type GMP|string|int, array given
TypeError: Number must be of type GMP|string|int, array given
TypeError: Number must be of type GMP|string|int, array given
object(GMP)#2 (1) {
["num"]=>
string(2) "42"
}
object(GMP)#2 (1) {
["num"]=>
string(2) "42"
}

View file

@ -0,0 +1,117 @@
--TEST--
GMP operator overloading does support float with no fractional
--EXTENSIONS--
gmp
--FILE--
<?php
$num = gmp_init(42);
try {
var_dump($num + 42.0);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num - 42.0);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num * 42.0);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num / 42.0);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num % 42.0);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ** 42.0);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num | 42.0);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num & 42.0);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ^ 42.0);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num << 42.0);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num >> 42.0);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
object(GMP)#2 (1) {
["num"]=>
string(2) "84"
}
object(GMP)#2 (1) {
["num"]=>
string(1) "0"
}
object(GMP)#2 (1) {
["num"]=>
string(4) "1764"
}
object(GMP)#2 (1) {
["num"]=>
string(1) "1"
}
object(GMP)#2 (1) {
["num"]=>
string(1) "0"
}
object(GMP)#2 (1) {
["num"]=>
string(69) "150130937545296572356771972164254457814047970568738777235893533016064"
}
object(GMP)#2 (1) {
["num"]=>
string(2) "42"
}
object(GMP)#2 (1) {
["num"]=>
string(2) "42"
}
object(GMP)#2 (1) {
["num"]=>
string(1) "0"
}
object(GMP)#2 (1) {
["num"]=>
string(15) "184717953466368"
}
object(GMP)#2 (1) {
["num"]=>
string(1) "0"
}

View file

@ -0,0 +1,132 @@
--TEST--
GMP operator overloading support for float with fractional is deprecated
--EXTENSIONS--
gmp
--FILE--
<?php
$num = gmp_init(42);
try {
var_dump($num + 42.5);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num - 42.5);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num * 42.5);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num / 42.5);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num % 42.5);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ** 42.5);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num | 42.5);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num & 42.5);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ^ 42.5);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num << 42.5);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num >> 42.5);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d
object(GMP)#2 (1) {
["num"]=>
string(2) "84"
}
Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d
object(GMP)#2 (1) {
["num"]=>
string(1) "0"
}
Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d
object(GMP)#2 (1) {
["num"]=>
string(4) "1764"
}
Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d
object(GMP)#2 (1) {
["num"]=>
string(1) "1"
}
Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d
object(GMP)#2 (1) {
["num"]=>
string(1) "0"
}
object(GMP)#2 (1) {
["num"]=>
string(69) "150130937545296572356771972164254457814047970568738777235893533016064"
}
Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d
object(GMP)#2 (1) {
["num"]=>
string(2) "42"
}
Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d
object(GMP)#2 (1) {
["num"]=>
string(2) "42"
}
Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d
object(GMP)#2 (1) {
["num"]=>
string(1) "0"
}
object(GMP)#2 (1) {
["num"]=>
string(15) "184717953466368"
}
object(GMP)#2 (1) {
["num"]=>
string(1) "0"
}

View file

@ -0,0 +1,93 @@
--TEST--
GMP operator overloading does not support float strings
--EXTENSIONS--
gmp
--FILE--
<?php
$num = gmp_init(42);
try {
var_dump($num + "2.0");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num - "2.0");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num * "2.0");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num / "2.0");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num % "2.0");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ** "2.0");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num | "2.0");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num & "2.0");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ^ "2.0");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num << "2.0");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num >> "2.0");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
ValueError: Number is not an integer string
ValueError: Number is not an integer string
ValueError: Number is not an integer string
ValueError: Number is not an integer string
ValueError: Number is not an integer string
object(GMP)#3 (1) {
["num"]=>
string(4) "1764"
}
ValueError: Number is not an integer string
ValueError: Number is not an integer string
ValueError: Number is not an integer string
object(GMP)#2 (1) {
["num"]=>
string(3) "168"
}
object(GMP)#2 (1) {
["num"]=>
string(2) "10"
}

View file

@ -0,0 +1,117 @@
--TEST--
GMP operator overloading does support int strings
--EXTENSIONS--
gmp
--FILE--
<?php
$num = gmp_init(42);
try {
var_dump($num + "2");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num - "2");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num * "2");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num / "2");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num % "2");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ** "2");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num | "2");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num & "2");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ^ "2");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num << "2");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num >> "2");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
object(GMP)#2 (1) {
["num"]=>
string(2) "44"
}
object(GMP)#2 (1) {
["num"]=>
string(2) "40"
}
object(GMP)#2 (1) {
["num"]=>
string(2) "84"
}
object(GMP)#2 (1) {
["num"]=>
string(2) "21"
}
object(GMP)#2 (1) {
["num"]=>
string(1) "0"
}
object(GMP)#2 (1) {
["num"]=>
string(4) "1764"
}
object(GMP)#2 (1) {
["num"]=>
string(2) "42"
}
object(GMP)#2 (1) {
["num"]=>
string(1) "2"
}
object(GMP)#2 (1) {
["num"]=>
string(2) "40"
}
object(GMP)#2 (1) {
["num"]=>
string(3) "168"
}
object(GMP)#2 (1) {
["num"]=>
string(2) "10"
}

View file

@ -0,0 +1,93 @@
--TEST--
GMP operator overloading does not support non-numeric strings
--EXTENSIONS--
gmp
--FILE--
<?php
$num = gmp_init(42);
try {
var_dump($num + "string");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num - "string");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num * "string");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num / "string");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num % "string");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ** "string");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num | "string");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num & "string");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ^ "string");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num << "string");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num >> "string");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
ValueError: Number is not an integer string
ValueError: Number is not an integer string
ValueError: Number is not an integer string
ValueError: Number is not an integer string
ValueError: Number is not an integer string
object(GMP)#3 (1) {
["num"]=>
string(1) "1"
}
ValueError: Number is not an integer string
ValueError: Number is not an integer string
ValueError: Number is not an integer string
object(GMP)#2 (1) {
["num"]=>
string(2) "42"
}
object(GMP)#2 (1) {
["num"]=>
string(2) "42"
}

View file

@ -0,0 +1,76 @@
--TEST--
GMP operator overloading does not support null
--EXTENSIONS--
gmp
--XFAIL--
Test showcasing segfaulting behaviour
--FILE--
<?php
$num = gmp_init(42);
try {
var_dump($num + null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num - null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num * null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num / null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num % null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ** null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num | null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num & null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ^ null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num << null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num >> null);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
SEGFAULT

View file

@ -0,0 +1,100 @@
--TEST--
GMP operator overloading does not support non-stringable objects
--EXTENSIONS--
gmp
--FILE--
<?php
$num = gmp_init(42);
$o = new stdClass();
try {
var_dump($num + $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num - $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num * $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num / $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num % $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ** $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num | $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num & $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ^ $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num << $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num >> $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
TypeError: Number must be of type GMP|string|int, stdClass given
TypeError: Number must be of type GMP|string|int, stdClass given
TypeError: Number must be of type GMP|string|int, stdClass given
TypeError: Number must be of type GMP|string|int, stdClass given
TypeError: Number must be of type GMP|string|int, stdClass given
Warning: Object of class stdClass could not be converted to int in %s on line %d
object(GMP)#4 (1) {
["num"]=>
string(2) "42"
}
TypeError: Number must be of type GMP|string|int, stdClass given
TypeError: Number must be of type GMP|string|int, stdClass given
TypeError: Number must be of type GMP|string|int, stdClass given
Warning: Object of class stdClass could not be converted to int in %s on line %d
object(GMP)#3 (1) {
["num"]=>
string(2) "84"
}
Warning: Object of class stdClass could not be converted to int in %s on line %d
object(GMP)#3 (1) {
["num"]=>
string(2) "21"
}

View file

@ -0,0 +1,106 @@
--TEST--
GMP operator overloading does not support stringable objects
--EXTENSIONS--
gmp
--FILE--
<?php
class T {
public function __toString() {
return "42";
}
}
$num = gmp_init(42);
$o = new T();
try {
var_dump($num + $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num - $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num * $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num / $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num % $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ** $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num | $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num & $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ^ $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num << $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num >> $o);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
TypeError: Number must be of type GMP|string|int, T given
TypeError: Number must be of type GMP|string|int, T given
TypeError: Number must be of type GMP|string|int, T given
TypeError: Number must be of type GMP|string|int, T given
TypeError: Number must be of type GMP|string|int, T given
Warning: Object of class T could not be converted to int in %s on line %d
object(GMP)#4 (1) {
["num"]=>
string(2) "42"
}
TypeError: Number must be of type GMP|string|int, T given
TypeError: Number must be of type GMP|string|int, T given
TypeError: Number must be of type GMP|string|int, T given
Warning: Object of class T could not be converted to int in %s on line %d
object(GMP)#3 (1) {
["num"]=>
string(2) "84"
}
Warning: Object of class T could not be converted to int in %s on line %d
object(GMP)#3 (1) {
["num"]=>
string(2) "21"
}

View file

@ -0,0 +1,93 @@
--TEST--
GMP operator overloading does not support resources
--EXTENSIONS--
gmp
--FILE--
<?php
$num = gmp_init(42);
try {
var_dump($num + STDERR);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num - STDERR);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num * STDERR);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num / STDERR);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num % STDERR);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ** STDERR);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num | STDERR);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num & STDERR);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num ^ STDERR);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num << STDERR);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump($num >> STDERR);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
TypeError: Number must be of type GMP|string|int, resource given
TypeError: Number must be of type GMP|string|int, resource given
TypeError: Number must be of type GMP|string|int, resource given
TypeError: Number must be of type GMP|string|int, resource given
TypeError: Number must be of type GMP|string|int, resource given
object(GMP)#3 (1) {
["num"]=>
string(5) "74088"
}
TypeError: Number must be of type GMP|string|int, resource given
TypeError: Number must be of type GMP|string|int, resource given
TypeError: Number must be of type GMP|string|int, resource given
object(GMP)#2 (1) {
["num"]=>
string(3) "336"
}
object(GMP)#2 (1) {
["num"]=>
string(1) "5"
}