Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/gmp/tests/003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ gmp
try {
$test[] = gmp_init("4d2");
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
$test[] = gmp_init("4d2", 16);

Expand All @@ -35,7 +35,7 @@ gmp
}
?>
--EXPECT--
gmp_init(): Argument #1 ($num) is not an integer string
ValueError: gmp_init(): Argument #1 ($num) is not an integer string
1234
1234
10011010010
Expand Down
8 changes: 4 additions & 4 deletions ext/gmp/tests/bug32773.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ echo '10 + "0" = ', gmp_strval(gmp_add(10, '0')), "\n";
try {
var_dump(gmp_div(10, 0));
} catch (\DivisionByZeroError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(gmp_div_qr(10, 0));
} catch (\DivisionByZeroError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
10 + 0 = 10
10 + "0" = 10
gmp_div(): Argument #2 ($num2) Division by zero
gmp_div_qr(): Argument #2 ($num2) Division by zero
DivisionByZeroError: gmp_div(): Argument #2 ($num2) Division by zero
DivisionByZeroError: gmp_div_qr(): Argument #2 ($num2) Division by zero
16 changes: 8 additions & 8 deletions ext/gmp/tests/bug50283.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ printf("Decimal: %s, 36-based: %s\n", gmp_strval($a), gmp_strval($a,36));
try {
printf("Decimal: %s, -1-based: %s\n", gmp_strval($a), gmp_strval($a,-1));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
printf("Decimal: %s, 1-based: %s\n", gmp_strval($a), gmp_strval($a,1));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
printf("Decimal: %s, -37-based: %s\n", gmp_strval($a), gmp_strval($a,-37));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
printf("Decimal: %s, 37-based: %s\n", gmp_strval($a), gmp_strval($a,37));
printf("Decimal: %s, 62-based: %s\n", gmp_strval($a), gmp_strval($a,62));
try {
printf("Decimal: %s, 63-based: %s\n\n", gmp_strval($a), gmp_strval($a,63));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
printf("Base 32 and 62-based: %s\n", gmp_strval(gmp_init("gh82179fbf5", 32), 62));
?>
--EXPECT--
Decimal: 71915494046709, -36-based: PHPISCOOL
Decimal: 71915494046709, 36-based: phpiscool
gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
ValueError: gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
ValueError: gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
ValueError: gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
Decimal: 71915494046709, 37-based: KHKATELJF
Decimal: 71915494046709, 62-based: KQ6yq741
gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
ValueError: gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
Base 32 and 62-based: 1NHkAcdIiD
4 changes: 2 additions & 2 deletions ext/gmp/tests/bug66872.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ gmp
try {
var_dump(gmp_testbit("abc", 1));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
gmp_testbit(): Argument #1 ($num) is not an integer string
ValueError: gmp_testbit(): Argument #1 ($num) is not an integer string
16 changes: 8 additions & 8 deletions ext/gmp/tests/bug80560.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,24 @@ echo 'Hexadecimal', \PHP_EOL;
try {
var_dump(gmp_init('0X', 16));
} catch (\ValueError $e) {
echo $e->getMessage(), \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(gmp_init('0x', 16));
} catch (\ValueError $e) {
echo $e->getMessage(), \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

echo 'Binary', \PHP_EOL;
try {
var_dump(gmp_init('0B', 2));
} catch (\ValueError $e) {
echo $e->getMessage(), \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(gmp_init('0b', 2));
} catch (\ValueError $e) {
echo $e->getMessage(), \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

echo 'Fuzzing gmp functions:', \PHP_EOL;
Expand Down Expand Up @@ -219,10 +219,10 @@ echo "Done\n";
--EXPECT--
Explicit base with gmp_init:
Hexadecimal
gmp_init(): Argument #1 ($num) is not an integer string
gmp_init(): Argument #1 ($num) is not an integer string
ValueError: gmp_init(): Argument #1 ($num) is not an integer string
ValueError: gmp_init(): Argument #1 ($num) is not an integer string
Binary
gmp_init(): Argument #1 ($num) is not an integer string
gmp_init(): Argument #1 ($num) is not an integer string
ValueError: gmp_init(): Argument #1 ($num) is not an integer string
ValueError: gmp_init(): Argument #1 ($num) is not an integer string
Fuzzing gmp functions:
Done
10 changes: 5 additions & 5 deletions ext/gmp/tests/bug81119.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function test($f) {
$f();
echo "No error?\n";
} catch (TypeError|ValueError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
}
test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) < "x");
Expand All @@ -20,7 +20,7 @@ test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) + []);

?>
--EXPECT--
Number is not an integer string
Number must be of type GMP|string|int, array given
Number is not an integer string
Number must be of type GMP|string|int, array given
ValueError: Number is not an integer string
TypeError: Number must be of type GMP|string|int, array given
ValueError: Number is not an integer string
TypeError: Number must be of type GMP|string|int, array given
4 changes: 2 additions & 2 deletions ext/gmp/tests/comparison_invalid.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ gmp
try {
var_dump("hapfegfbu" > gmp_init(0));
} catch (\Error $e) {
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

try {
var_dump((new DateTime()) > gmp_init(0));
} catch (\Error $e) {
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

?>
Expand Down
12 changes: 6 additions & 6 deletions ext/gmp/tests/construct.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ var_dump(new GMP("12", 4));
try {
var_dump(new GMP("12", 999));
} catch (ValueError $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
var_dump(new GMP("", 10));
} catch (ValueError $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
var_dump(new GMP("hello"));
} catch (ValueError $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
Expand All @@ -46,6 +46,6 @@ object(GMP)#1 (1) {
["num"]=>
string(1) "6"
}
GMP::__construct(): Argument #2 ($base) must be 0 or between 2 and 62
GMP::__construct(): Argument #1 ($num) is not an integer string
GMP::__construct(): Argument #1 ($num) is not an integer string
ValueError: GMP::__construct(): Argument #2 ($base) must be 0 or between 2 and 62
ValueError: GMP::__construct(): Argument #1 ($num) is not an integer string
ValueError: GMP::__construct(): Argument #1 ($num) is not an integer string
4 changes: 2 additions & 2 deletions ext/gmp/tests/gh16501.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ gmp
try {
gmp_random_bits(PHP_INT_MAX);
} catch (\ValueError $e) {
echo $e->getMessage();
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
gmp_random_bits(): Argument #1 ($bits) must be between 1 and %d
ValueError: gmp_random_bits(): Argument #1 ($bits) must be between 1 and %d
4 changes: 2 additions & 2 deletions ext/gmp/tests/gh9308.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ declare(strict_types=1);
try {
$gmp = gmp_init(gmp_init(123));
} catch (\TypeError $e) {
echo $e->getMessage(), \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
gmp_init(): Argument #1 ($num) must be of type string|int, GMP given
TypeError: gmp_init(): Argument #1 ($num) must be of type string|int, GMP given
20 changes: 10 additions & 10 deletions ext/gmp/tests/gmp_abs.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ gmp
try {
var_dump(gmp_strval(gmp_abs("")));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
var_dump(gmp_strval(gmp_abs("0")));
var_dump(gmp_strval(gmp_abs(0)));
try {
var_dump(gmp_strval(gmp_abs(-111111111111111111111))); // This is a float
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
var_dump(gmp_strval(gmp_abs("111111111111111111111")));
var_dump(gmp_strval(gmp_abs("-111111111111111111111")));
Expand All @@ -25,33 +25,33 @@ try {
// Base 8
var_dump(gmp_strval(gmp_abs("09876543")));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
// Base 8
var_dump(gmp_strval(gmp_abs("-099987654")));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}


try {
var_dump(gmp_abs(array()));
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

echo "Done\n";
?>
--EXPECT--
gmp_abs(): Argument #1 ($num) is not an integer string
ValueError: gmp_abs(): Argument #1 ($num) is not an integer string
string(1) "0"
string(1) "0"
gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, float given
TypeError: gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, float given
string(21) "111111111111111111111"
string(21) "111111111111111111111"
string(1) "0"
gmp_abs(): Argument #1 ($num) is not an integer string
gmp_abs(): Argument #1 ($num) is not an integer string
gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, array given
ValueError: gmp_abs(): Argument #1 ($num) is not an integer string
ValueError: gmp_abs(): Argument #1 ($num) is not an integer string
TypeError: gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, array given
Done
16 changes: 8 additions & 8 deletions ext/gmp/tests/gmp_and.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var_dump(gmp_strval(gmp_and(4545, -20)));
try {
var_dump(gmp_strval(gmp_and("test", "no test")));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

$n = gmp_init("987657876543456");
Expand All @@ -26,17 +26,17 @@ var_dump(gmp_strval(gmp_and($n, $n1)));
try {
var_dump(gmp_and(array(), 1));
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(gmp_and(1, array()));
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(gmp_and(array(), array()));
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

echo "Done\n";
Expand All @@ -47,10 +47,10 @@ string(5) "40994"
string(3) "515"
string(4) "3333"
string(4) "4544"
gmp_and(): Argument #1 ($num1) is not an integer string
ValueError: gmp_and(): Argument #1 ($num1) is not an integer string
string(4) "1536"
string(15) "424703623692768"
gmp_and(): Argument #1 ($num1) must be of type GMP|string|int, array given
gmp_and(): Argument #2 ($num2) must be of type GMP|string|int, array given
gmp_and(): Argument #1 ($num1) must be of type GMP|string|int, array given
TypeError: gmp_and(): Argument #1 ($num1) must be of type GMP|string|int, array given
TypeError: gmp_and(): Argument #2 ($num2) must be of type GMP|string|int, array given
TypeError: gmp_and(): Argument #1 ($num1) must be of type GMP|string|int, array given
Done
4 changes: 2 additions & 2 deletions ext/gmp/tests/gmp_binomial.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var_dump(gmp_binomial(-2, 6)); // == (2 + 6 - 1 over 6)
try {
var_dump(gmp_binomial(5, -2));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
Expand Down Expand Up @@ -67,4 +67,4 @@ object(GMP)#2 (1) {
["num"]=>
string(1) "7"
}
gmp_binomial(): Argument #2 ($k) must be between 0 and %d
ValueError: gmp_binomial(): Argument #2 ($k) must be between 0 and %d
12 changes: 6 additions & 6 deletions ext/gmp/tests/gmp_clrbit.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ $n = gmp_init(-1);
try {
gmp_clrbit($n, -1);
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
var_dump(gmp_strval($n));

$n = gmp_init("1000000");
try {
gmp_clrbit($n, -1);
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
var_dump(gmp_strval($n));

Expand All @@ -39,18 +39,18 @@ $n = array();
try {
gmp_clrbit($n, 3);
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "Done\n";
?>
--EXPECTF--
string(1) "0"
gmp_clrbit(): Argument #2 ($index) must be between 0 and %d * %d
ValueError: gmp_clrbit(): Argument #2 ($index) must be between 0 and %d * %d
string(2) "-1"
gmp_clrbit(): Argument #2 ($index) must be between 0 and %d * %d
ValueError: gmp_clrbit(): Argument #2 ($index) must be between 0 and %d * %d
string(7) "1000000"
string(7) "1000000"
string(30) "238462734628347239571822592658"
gmp_clrbit(): Argument #1 ($num) must be of type GMP, array given
TypeError: gmp_clrbit(): Argument #1 ($num) must be of type GMP, array given
Done
Loading
Loading