mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
4ea85d4044
Implements a proper constructor for GMP as discussed in both GH-10158 and https://externals.io/message/119216. Fixes GH-10155 Closes GH-10225 Signed-off-by: George Peter Banyard <girgias@php.net>
52 lines
945 B
PHP
52 lines
945 B
PHP
--TEST--
|
|
Constructor for GMP
|
|
--EXTENSIONS--
|
|
gmp
|
|
--FILE--
|
|
<?php
|
|
var_dump(new GMP);
|
|
var_dump(new GMP(0));
|
|
var_dump(new GMP(123));
|
|
var_dump(new GMP("0xAA"));
|
|
var_dump(new GMP("12", 4));
|
|
try {
|
|
var_dump(new GMP("12", 999));
|
|
} catch (ValueError $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
try {
|
|
var_dump(new GMP("", 10));
|
|
} catch (ValueError $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
try {
|
|
var_dump(new GMP("hello"));
|
|
} catch (ValueError $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
object(GMP)#1 (1) {
|
|
["num"]=>
|
|
string(1) "0"
|
|
}
|
|
object(GMP)#1 (1) {
|
|
["num"]=>
|
|
string(1) "0"
|
|
}
|
|
object(GMP)#1 (1) {
|
|
["num"]=>
|
|
string(3) "123"
|
|
}
|
|
object(GMP)#1 (1) {
|
|
["num"]=>
|
|
string(3) "170"
|
|
}
|
|
object(GMP)#1 (1) {
|
|
["num"]=>
|
|
string(1) "6"
|
|
}
|
|
GMP::__construct(): Argument #2 ($base) must be between 2 and 62
|
|
GMP::__construct(): Argument #1 ($num) is not an integer string
|
|
GMP::__construct(): Argument #1 ($num) is not an integer string
|