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--EXPECT--
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 --
122float(0)
123
124-- Iteration 12 --
125float(0)
126
127-- Iteration 13 --
128float(1)
129
130-- Iteration 14 --
131float(0)
132
133-- Iteration 15 --
134float(1)
135
136-- Iteration 16 --
137float(0)
138
139-- Iteration 17 --
140round(): Argument #1 ($num) must be of type int|float, string given
141
142-- Iteration 18 --
143round(): Argument #1 ($num) must be of type int|float, string given
144
145-- Iteration 19 --
146round(): Argument #1 ($num) must be of type int|float, array given
147
148-- Iteration 20 --
149round(): Argument #1 ($num) must be of type int|float, string given
150
151-- Iteration 21 --
152round(): Argument #1 ($num) must be of type int|float, string given
153
154-- Iteration 22 --
155round(): Argument #1 ($num) must be of type int|float, string given
156
157-- Iteration 23 --
158round(): Argument #1 ($num) must be of type int|float, classA given
159
160-- Iteration 24 --
161float(0)
162
163-- Iteration 25 --
164float(0)
165
166-- Iteration 26 --
167round(): Argument #1 ($num) must be of type int|float, resource given
168