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