1--TEST--
2BcMath\Number powmod()
3--EXTENSIONS--
4bcmath
5--FILE--
6<?php
7
8$values = ['12', '-12'];
9
10$exponents = [
11    [2, 'int'],
12    ['0', 'string'],
13    ['3', 'string'],
14    [new BcMath\Number('2'), 'object'],
15    [new BcMath\Number('0'), 'object'],
16];
17
18$mods = [
19    [2, 'int'],
20    ['3', 'string'],
21    [new BcMath\Number('2'), 'object'],
22];
23
24foreach ($values as $value) {
25    $num = new BcMath\Number($value);
26
27    foreach ($exponents as [$exponent, $type_ex]) {
28        foreach ($mods as [$mod, $type_mod]) {
29            echo "{$value}, expo is {$exponent}({$type_ex}), mod is {$mod}({$type_mod}):\n";
30            $ret = $num->powmod($exponent, $mod);
31            var_dump($ret);
32            echo "\n";
33        }
34    }
35}
36?>
37--EXPECT--
3812, expo is 2(int), mod is 2(int):
39object(BcMath\Number)#5 (2) {
40  ["value"]=>
41  string(1) "0"
42  ["scale"]=>
43  int(0)
44}
45
4612, expo is 2(int), mod is 3(string):
47object(BcMath\Number)#6 (2) {
48  ["value"]=>
49  string(1) "0"
50  ["scale"]=>
51  int(0)
52}
53
5412, expo is 2(int), mod is 2(object):
55object(BcMath\Number)#5 (2) {
56  ["value"]=>
57  string(1) "0"
58  ["scale"]=>
59  int(0)
60}
61
6212, expo is 0(string), mod is 2(int):
63object(BcMath\Number)#6 (2) {
64  ["value"]=>
65  string(1) "1"
66  ["scale"]=>
67  int(0)
68}
69
7012, expo is 0(string), mod is 3(string):
71object(BcMath\Number)#5 (2) {
72  ["value"]=>
73  string(1) "1"
74  ["scale"]=>
75  int(0)
76}
77
7812, expo is 0(string), mod is 2(object):
79object(BcMath\Number)#6 (2) {
80  ["value"]=>
81  string(1) "1"
82  ["scale"]=>
83  int(0)
84}
85
8612, expo is 3(string), mod is 2(int):
87object(BcMath\Number)#5 (2) {
88  ["value"]=>
89  string(1) "0"
90  ["scale"]=>
91  int(0)
92}
93
9412, expo is 3(string), mod is 3(string):
95object(BcMath\Number)#6 (2) {
96  ["value"]=>
97  string(1) "0"
98  ["scale"]=>
99  int(0)
100}
101
10212, expo is 3(string), mod is 2(object):
103object(BcMath\Number)#5 (2) {
104  ["value"]=>
105  string(1) "0"
106  ["scale"]=>
107  int(0)
108}
109
11012, expo is 2(object), mod is 2(int):
111object(BcMath\Number)#6 (2) {
112  ["value"]=>
113  string(1) "0"
114  ["scale"]=>
115  int(0)
116}
117
11812, expo is 2(object), mod is 3(string):
119object(BcMath\Number)#5 (2) {
120  ["value"]=>
121  string(1) "0"
122  ["scale"]=>
123  int(0)
124}
125
12612, expo is 2(object), mod is 2(object):
127object(BcMath\Number)#6 (2) {
128  ["value"]=>
129  string(1) "0"
130  ["scale"]=>
131  int(0)
132}
133
13412, expo is 0(object), mod is 2(int):
135object(BcMath\Number)#5 (2) {
136  ["value"]=>
137  string(1) "1"
138  ["scale"]=>
139  int(0)
140}
141
14212, expo is 0(object), mod is 3(string):
143object(BcMath\Number)#6 (2) {
144  ["value"]=>
145  string(1) "1"
146  ["scale"]=>
147  int(0)
148}
149
15012, expo is 0(object), mod is 2(object):
151object(BcMath\Number)#5 (2) {
152  ["value"]=>
153  string(1) "1"
154  ["scale"]=>
155  int(0)
156}
157
158-12, expo is 2(int), mod is 2(int):
159object(BcMath\Number)#4 (2) {
160  ["value"]=>
161  string(1) "0"
162  ["scale"]=>
163  int(0)
164}
165
166-12, expo is 2(int), mod is 3(string):
167object(BcMath\Number)#5 (2) {
168  ["value"]=>
169  string(1) "0"
170  ["scale"]=>
171  int(0)
172}
173
174-12, expo is 2(int), mod is 2(object):
175object(BcMath\Number)#4 (2) {
176  ["value"]=>
177  string(1) "0"
178  ["scale"]=>
179  int(0)
180}
181
182-12, expo is 0(string), mod is 2(int):
183object(BcMath\Number)#5 (2) {
184  ["value"]=>
185  string(1) "1"
186  ["scale"]=>
187  int(0)
188}
189
190-12, expo is 0(string), mod is 3(string):
191object(BcMath\Number)#4 (2) {
192  ["value"]=>
193  string(1) "1"
194  ["scale"]=>
195  int(0)
196}
197
198-12, expo is 0(string), mod is 2(object):
199object(BcMath\Number)#5 (2) {
200  ["value"]=>
201  string(1) "1"
202  ["scale"]=>
203  int(0)
204}
205
206-12, expo is 3(string), mod is 2(int):
207object(BcMath\Number)#4 (2) {
208  ["value"]=>
209  string(1) "0"
210  ["scale"]=>
211  int(0)
212}
213
214-12, expo is 3(string), mod is 3(string):
215object(BcMath\Number)#5 (2) {
216  ["value"]=>
217  string(1) "0"
218  ["scale"]=>
219  int(0)
220}
221
222-12, expo is 3(string), mod is 2(object):
223object(BcMath\Number)#4 (2) {
224  ["value"]=>
225  string(1) "0"
226  ["scale"]=>
227  int(0)
228}
229
230-12, expo is 2(object), mod is 2(int):
231object(BcMath\Number)#5 (2) {
232  ["value"]=>
233  string(1) "0"
234  ["scale"]=>
235  int(0)
236}
237
238-12, expo is 2(object), mod is 3(string):
239object(BcMath\Number)#4 (2) {
240  ["value"]=>
241  string(1) "0"
242  ["scale"]=>
243  int(0)
244}
245
246-12, expo is 2(object), mod is 2(object):
247object(BcMath\Number)#5 (2) {
248  ["value"]=>
249  string(1) "0"
250  ["scale"]=>
251  int(0)
252}
253
254-12, expo is 0(object), mod is 2(int):
255object(BcMath\Number)#4 (2) {
256  ["value"]=>
257  string(1) "1"
258  ["scale"]=>
259  int(0)
260}
261
262-12, expo is 0(object), mod is 3(string):
263object(BcMath\Number)#5 (2) {
264  ["value"]=>
265  string(1) "1"
266  ["scale"]=>
267  int(0)
268}
269
270-12, expo is 0(object), mod is 2(object):
271object(BcMath\Number)#4 (2) {
272  ["value"]=>
273  string(1) "1"
274  ["scale"]=>
275  int(0)
276}
277