Annotation of embedaddon/php/ext/standard/tests/math/hypot_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test hypot() function : usage variations - different data types as $x argument
3: --FILE--
4: <?php
5: /* Prototype : float hypot ( float $x , float $y )
6: * Description: Calculate the length of the hypotenuse of a right-angle triangle
7: * Source code: ext/standard/math.c
8: */
9:
10: echo "*** Testing hypot() : usage variations ***\n";
11:
12: //get an unset variable
13: $unset_var = 10;
14: unset ($unset_var);
15:
16: // heredoc string
17: $heredoc = <<<EOT
18: abc
19: xyz
20: EOT;
21:
22: // get a class
23: class classA
24: {
25: }
26:
27: // get a resource variable
28: $fp = fopen(__FILE__, "r");
29:
30: // unexpected values to be passed to $arg argument
31: $inputs = array(
32: // int data
33: /*1*/ 0,
34: 1,
35: 12345,
36: -2345,
37: 2147483647,
38:
39: // float data
40: /*6*/ 10.5,
41: -10.5,
42: 12.3456789000e10,
43: 12.3456789000E-10,
44: .5,
45:
46: // null data
47: /*11*/ NULL,
48: null,
49:
50: // boolean data
51: /*13*/ true,
52: false,
53: TRUE,
54: FALSE,
55:
56: // empty data
57: /*17*/ "",
58: '',
59: array(),
60:
61: // string data
62: /*20*/ "abcxyz",
63: 'abcxyz',
64: $heredoc,
65:
66: // object data
67: /*23*/ new classA(),
68:
69: // undefined data
70: /*24*/ @$undefined_var,
71:
72: // unset data
73: /*25*/ @$unset_var,
74:
75: // resource variable
76: /*26*/ $fp
77: );
78:
79: // loop through each element of $inputs to check the behaviour of hypot()
80: $iterator = 1;
81: foreach($inputs as $input) {
82: echo "\n-- Iteration $iterator --\n";
83: var_dump(hypot($input, 5));
84: $iterator++;
85: };
86: fclose($fp);
87: ?>
88: ===Done===
89: --EXPECTF--
90: *** Testing hypot() : usage variations ***
91:
92: -- Iteration 1 --
93: float(5)
94:
95: -- Iteration 2 --
96: float(5.0990195135928)
97:
98: -- Iteration 3 --
99: float(12345.001012556)
100:
101: -- Iteration 4 --
102: float(2345.0053304843)
103:
104: -- Iteration 5 --
105: float(2147483647)
106:
107: -- Iteration 6 --
108: float(11.629703349613)
109:
110: -- Iteration 7 --
111: float(11.629703349613)
112:
113: -- Iteration 8 --
114: float(123456789000)
115:
116: -- Iteration 9 --
117: float(5)
118:
119: -- Iteration 10 --
120: float(5.0249378105604)
121:
122: -- Iteration 11 --
123: float(5)
124:
125: -- Iteration 12 --
126: float(5)
127:
128: -- Iteration 13 --
129: float(5.0990195135928)
130:
131: -- Iteration 14 --
132: float(5)
133:
134: -- Iteration 15 --
135: float(5.0990195135928)
136:
137: -- Iteration 16 --
138: float(5)
139:
140: -- Iteration 17 --
141:
142: Warning: hypot() expects parameter 1 to be double, string given in %s on line %d
143: NULL
144:
145: -- Iteration 18 --
146:
147: Warning: hypot() expects parameter 1 to be double, string given in %s on line %d
148: NULL
149:
150: -- Iteration 19 --
151:
152: Warning: hypot() expects parameter 1 to be double, array given in %s on line %d
153: NULL
154:
155: -- Iteration 20 --
156:
157: Warning: hypot() expects parameter 1 to be double, string given in %s on line %d
158: NULL
159:
160: -- Iteration 21 --
161:
162: Warning: hypot() expects parameter 1 to be double, string given in %s on line %d
163: NULL
164:
165: -- Iteration 22 --
166:
167: Warning: hypot() expects parameter 1 to be double, string given in %s on line %d
168: NULL
169:
170: -- Iteration 23 --
171:
172: Warning: hypot() expects parameter 1 to be double, object given in %s on line %d
173: NULL
174:
175: -- Iteration 24 --
176: float(5)
177:
178: -- Iteration 25 --
179: float(5)
180:
181: -- Iteration 26 --
182:
183: Warning: hypot() expects parameter 1 to be double, resource given in %s on line %d
184: NULL
185: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>