xref: /php-src/ext/gmp/tests/construct.phpt (revision 4719ef25)
1--TEST--
2Constructor for GMP
3--EXTENSIONS--
4gmp
5--FILE--
6<?php
7var_dump(new GMP);
8var_dump(new GMP(0));
9var_dump(new GMP(123));
10var_dump(new GMP("0xAA"));
11var_dump(new GMP("12", 4));
12try {
13    var_dump(new GMP("12", 999));
14} catch (ValueError $e) {
15    echo $e->getMessage() . "\n";
16}
17try {
18    var_dump(new GMP("", 10));
19} catch (ValueError $e) {
20    echo $e->getMessage() . "\n";
21}
22try {
23    var_dump(new GMP("hello"));
24} catch (ValueError $e) {
25    echo $e->getMessage() . "\n";
26}
27?>
28--EXPECT--
29object(GMP)#1 (1) {
30  ["num"]=>
31  string(1) "0"
32}
33object(GMP)#1 (1) {
34  ["num"]=>
35  string(1) "0"
36}
37object(GMP)#1 (1) {
38  ["num"]=>
39  string(3) "123"
40}
41object(GMP)#1 (1) {
42  ["num"]=>
43  string(3) "170"
44}
45object(GMP)#1 (1) {
46  ["num"]=>
47  string(1) "6"
48}
49GMP::__construct(): Argument #2 ($base) must be 0 or between 2 and 62
50GMP::__construct(): Argument #1 ($num) is not an integer string
51GMP::__construct(): Argument #1 ($num) is not an integer string
52