1--TEST--
2BcMath\Number powmod() with scale
3--EXTENSIONS--
4bcmath
5--FILE--
6<?php
7
8$scales = [0, 10];
9
10$values = ['12', '-12'];
11
12$exponents = [
13    [2, 'int'],
14    ['0', 'string'],
15    ['3', 'string'],
16    [new BcMath\Number('2'), 'object'],
17    [new BcMath\Number('0'), 'object'],
18];
19
20$mods = [
21    [2, 'int'],
22    ['3', 'string'],
23    [new BcMath\Number('2'), 'object'],
24];
25
26foreach ($scales as $scale) {
27    foreach ($values as $value) {
28        $num = new BcMath\Number($value);
29
30        foreach ($exponents as [$exponent, $type_ex]) {
31            foreach ($mods as [$mod, $type_mod]) {
32                $func_ret = bcpowmod($value, (string) $exponent, (string) $mod, $scale);
33                $method_ret = $num->powmod($exponent, $mod, $scale);
34                if ($method_ret->compare($func_ret) !== 0) {
35                    echo "Result is incorrect.\n";
36                    var_dump($value, $exponent, $mod, $scale, $func_ret, $method_ret);
37                }
38            }
39        }
40    }
41}
42echo 'done!';
43?>
44--EXPECT--
45done!
46