improve un/serialization API
[awesomized/ext-ion] / tests / Decimal / toInt.phpt
1 --TEST--
2 ion\Decimal::toInt
3 --EXTENSIONS--
4 ion
5 --FILE--
6 TEST
7 <?php
8 use ion\Decimal;
9
10 var_dump((new Decimal(1))->toInt());
11 var_dump((new Decimal(-1))->toInt());
12 var_dump((new Decimal(123456789))->toInt());
13 var_dump((new Decimal(-123456789))->toInt());
14 try {
15 var_dump((new Decimal("1.23"))->toInt());
16 } catch (Throwable) {
17 echo "caught 1.23\n";
18 }
19 try {
20 var_dump((new Decimal("-1.23"))->toInt());
21 } catch (Throwable) {
22 echo "caught -1.23\n";
23 }
24 ?>
25 DONE
26 --EXPECT--
27 TEST
28 int(1)
29 int(-1)
30 int(123456789)
31 int(-123456789)
32 caught 1.23
33 caught -1.23
34 DONE