1--TEST--
2BcMath\Number round()
3--EXTENSIONS--
4bcmath
5--FILE--
6<?php
7foreach (RoundingMode::cases() as $mode) {
8    foreach ([
9        '0.1',
10        '-0.1',
11        '1.0',
12        '-1.0',
13        '1.2',
14        '-1.2',
15        '1.7',
16        '-1.7',
17        '1.5',
18        '-1.5',
19        '2.5',
20        '-2.5',
21    ] as $number) {
22        $func_ret = bcround($number, 0, $mode);
23        $method_ret = (new BcMath\Number($number))->round(0, $mode);
24        if ($method_ret->compare($func_ret) !== 0) {
25            echo "Result is incorrect.\n";
26            var_dump($number, $mode, $func_ret, $method_ret);
27        }
28    }
29}
30
31foreach (RoundingMode::cases() as $mode) {
32    foreach ([
33        '1.2345678',
34        '-1.2345678',
35    ] as $number) {
36        $func_ret = bcround($number, 5, $mode);
37        $method_ret = (new BcMath\Number($number))->round(5, $mode);
38        if ($method_ret->compare($func_ret) !== 0) {
39            echo "Result is incorrect.\n";
40            var_dump($number, $mode, $func_ret, $method_ret);
41        }
42    }
43}
44
45echo 'done!';
46?>
47--EXPECT--
48done!
49