xref: /php-src/ext/standard/tests/math/abs_basic.phpt (revision b10416a6)
1--TEST--
2Test abs() function : basic functionality
3--INI--
4precision = 14
5--FILE--
6<?php
7echo "*** Testing abs() : basic functionality ***\n";
8
9$values = array(23,
10                -23,
11                2.345e1,
12                -2.345e1,
13                0x17,
14                027,
15                "23",
16                "-23",
17                "23.45",
18                "2.345e1",
19                "-2.345e1",
20                null,
21                true,
22                false);
23
24for ($i = 0; $i < count($values); $i++) {
25    $res = abs($values[$i]);
26    var_dump($res);
27}
28?>
29--EXPECTF--
30*** Testing abs() : basic functionality ***
31int(23)
32int(23)
33float(23.45)
34float(23.45)
35int(23)
36int(23)
37int(23)
38int(23)
39float(23.45)
40float(23.45)
41float(23.45)
42
43Deprecated: abs(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
44int(0)
45int(1)
46int(0)
47