Skip to content

Commit 3efb1eb

Browse files
committed
Add test for numeric int
1 parent 4141ba0 commit 3efb1eb

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
--TEST--
2+
GMP operator overloading does support int strings
3+
--EXTENSIONS--
4+
gmp
5+
--FILE--
6+
<?php
7+
8+
$num = gmp_init(42);
9+
10+
try {
11+
var_dump($num + "2");
12+
} catch (Throwable $e) {
13+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
14+
}
15+
16+
try {
17+
var_dump($num - "2");
18+
} catch (Throwable $e) {
19+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
20+
}
21+
22+
try {
23+
var_dump($num * "2");
24+
} catch (Throwable $e) {
25+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
26+
}
27+
28+
try {
29+
var_dump($num / "2");
30+
} catch (Throwable $e) {
31+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
32+
}
33+
34+
try {
35+
var_dump($num % "2");
36+
} catch (Throwable $e) {
37+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
38+
}
39+
40+
try {
41+
var_dump($num ** "2");
42+
} catch (Throwable $e) {
43+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
44+
}
45+
46+
try {
47+
var_dump($num | "2");
48+
} catch (Throwable $e) {
49+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
50+
}
51+
try {
52+
var_dump($num & "2");
53+
} catch (Throwable $e) {
54+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
55+
}
56+
try {
57+
var_dump($num ^ "2");
58+
} catch (Throwable $e) {
59+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
60+
}
61+
try {
62+
var_dump($num << "2");
63+
} catch (Throwable $e) {
64+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
65+
}
66+
try {
67+
var_dump($num >> "2");
68+
} catch (Throwable $e) {
69+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
70+
}
71+
72+
?>
73+
--EXPECT--
74+
object(GMP)#2 (1) {
75+
["num"]=>
76+
string(2) "44"
77+
}
78+
object(GMP)#2 (1) {
79+
["num"]=>
80+
string(2) "40"
81+
}
82+
object(GMP)#2 (1) {
83+
["num"]=>
84+
string(2) "84"
85+
}
86+
object(GMP)#2 (1) {
87+
["num"]=>
88+
string(2) "21"
89+
}
90+
object(GMP)#2 (1) {
91+
["num"]=>
92+
string(1) "0"
93+
}
94+
object(GMP)#2 (1) {
95+
["num"]=>
96+
string(4) "1764"
97+
}
98+
object(GMP)#2 (1) {
99+
["num"]=>
100+
string(2) "42"
101+
}
102+
object(GMP)#2 (1) {
103+
["num"]=>
104+
string(1) "2"
105+
}
106+
object(GMP)#2 (1) {
107+
["num"]=>
108+
string(2) "40"
109+
}
110+
object(GMP)#2 (1) {
111+
["num"]=>
112+
string(3) "168"
113+
}
114+
object(GMP)#2 (1) {
115+
["num"]=>
116+
string(2) "10"
117+
}

0 commit comments

Comments
 (0)