1--TEST--
2Test round() function : usage variations - different data types as $val argument
3--INI--
4precision=14
5--FILE--
6<?php
7echo "*** Testing round() : usage variations ***\n";
8
9//get an unset variable
10$unset_var = 10;
11unset ($unset_var);
12
13// heredoc string
14$heredoc = <<<EOT
15abc
16xyz
17EOT;
18
19// get a class
20class classA
21{
22}
23
24// get a resource variable
25$fp = fopen(__FILE__, "r");
26
27$inputs = array(
28       // int data
29/*1*/  0,
30       1,
31       12345,
32       -2345,
33       2147483647,
34
35       // float data
36/*6*/  10.5,
37       -10.5,
38       12.3456789000e10,
39       12.3456789000E-10,
40       .5,
41
42       // null data
43/*11*/ NULL,
44       null,
45
46       // boolean data
47/*13*/ true,
48       false,
49       TRUE,
50       FALSE,
51
52       // empty data
53/*17*/ "",
54       '',
55       array(),
56
57       // string data
58/*20*/ "abcxyz",
59       'abcxyz',
60       $heredoc,
61
62       // object data
63/*23*/ new classA(),
64
65       // undefined data
66/*24*/ @$undefined_var,
67
68       // unset data
69/*25*/ @$unset_var,
70
71       // resource variable
72/*26*/ $fp
73);
74
75// loop through each element of $inputs to check the behaviour of round()
76$iterator = 1;
77foreach($inputs as $input) {
78    echo "\n-- Iteration $iterator --\n";
79    try {
80        var_dump(round($input, 14));
81    } catch (TypeError $e) {
82        echo $e->getMessage(), "\n";
83    }
84    $iterator++;
85};
86fclose($fp);
87?>
88--EXPECTF--
89*** Testing round() : usage variations ***
90
91-- Iteration 1 --
92float(0)
93
94-- Iteration 2 --
95float(1)
96
97-- Iteration 3 --
98float(12345)
99
100-- Iteration 4 --
101float(-2345)
102
103-- Iteration 5 --
104float(2147483647)
105
106-- Iteration 6 --
107float(10.5)
108
109-- Iteration 7 --
110float(-10.5)
111
112-- Iteration 8 --
113float(123456789000)
114
115-- Iteration 9 --
116float(1.23457E-9)
117
118-- Iteration 10 --
119float(0.5)
120
121-- Iteration 11 --
122
123Deprecated: round(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
124float(0)
125
126-- Iteration 12 --
127
128Deprecated: round(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
129float(0)
130
131-- Iteration 13 --
132float(1)
133
134-- Iteration 14 --
135float(0)
136
137-- Iteration 15 --
138float(1)
139
140-- Iteration 16 --
141float(0)
142
143-- Iteration 17 --
144round(): Argument #1 ($num) must be of type int|float, string given
145
146-- Iteration 18 --
147round(): Argument #1 ($num) must be of type int|float, string given
148
149-- Iteration 19 --
150round(): Argument #1 ($num) must be of type int|float, array given
151
152-- Iteration 20 --
153round(): Argument #1 ($num) must be of type int|float, string given
154
155-- Iteration 21 --
156round(): Argument #1 ($num) must be of type int|float, string given
157
158-- Iteration 22 --
159round(): Argument #1 ($num) must be of type int|float, string given
160
161-- Iteration 23 --
162round(): Argument #1 ($num) must be of type int|float, classA given
163
164-- Iteration 24 --
165
166Deprecated: round(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
167float(0)
168
169-- Iteration 25 --
170
171Deprecated: round(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
172float(0)
173
174-- Iteration 26 --
175round(): Argument #1 ($num) must be of type int|float, resource given
176