php-src/ext/gmp/tests/overloading_with_array.phpt
Gina Peter Banyard 5253647500
ext/gmp: Fix segfault when null is encountered on an overloaded operator
And various other issues like inconsistent type errors

Closes GH-16015
2024-11-02 17:36:32 +00:00

84 lines
2 KiB
PHP

--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
TypeError: Unsupported operand types: GMP ** array
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: Unsupported operand types: GMP << array
TypeError: Unsupported operand types: GMP >> array