1--TEST-- 2Test hypot() function : usage variations - different data types as $y 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 10echo "*** Testing hypot() : usage variations ***\n"; 11 12//get an unset variable 13$unset_var = 10; 14unset ($unset_var); 15 16// heredoc string 17$heredoc = <<<EOT 18abc 19xyz 20EOT; 21 22// get a class 23class 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; 81foreach($inputs as $input) { 82 echo "\n-- Iteration $iterator --\n"; 83 var_dump(hypot(3, $input)); 84 $iterator++; 85}; 86fclose($fp); 87?> 88===Done=== 89--EXPECTF-- 90*** Testing hypot() : usage variations *** 91 92-- Iteration 1 -- 93float(3) 94 95-- Iteration 2 -- 96float(3.1622776601684) 97 98-- Iteration 3 -- 99float(12345.00036452) 100 101-- Iteration 4 -- 102float(2345.0019189758) 103 104-- Iteration 5 -- 105float(2147483647) 106 107-- Iteration 6 -- 108float(10.920164833921) 109 110-- Iteration 7 -- 111float(10.920164833921) 112 113-- Iteration 8 -- 114float(123456789000) 115 116-- Iteration 9 -- 117float(3) 118 119-- Iteration 10 -- 120float(3.0413812651491) 121 122-- Iteration 11 -- 123float(3) 124 125-- Iteration 12 -- 126float(3) 127 128-- Iteration 13 -- 129float(3.1622776601684) 130 131-- Iteration 14 -- 132float(3) 133 134-- Iteration 15 -- 135float(3.1622776601684) 136 137-- Iteration 16 -- 138float(3) 139 140-- Iteration 17 -- 141 142Warning: hypot() expects parameter 2 to be float, string given in %s on line %d 143NULL 144 145-- Iteration 18 -- 146 147Warning: hypot() expects parameter 2 to be float, string given in %s on line %d 148NULL 149 150-- Iteration 19 -- 151 152Warning: hypot() expects parameter 2 to be float, array given in %s on line %d 153NULL 154 155-- Iteration 20 -- 156 157Warning: hypot() expects parameter 2 to be float, string given in %s on line %d 158NULL 159 160-- Iteration 21 -- 161 162Warning: hypot() expects parameter 2 to be float, string given in %s on line %d 163NULL 164 165-- Iteration 22 -- 166 167Warning: hypot() expects parameter 2 to be float, string given in %s on line %d 168NULL 169 170-- Iteration 23 -- 171 172Warning: hypot() expects parameter 2 to be float, object given in %s on line %d 173NULL 174 175-- Iteration 24 -- 176float(3) 177 178-- Iteration 25 -- 179float(3) 180 181-- Iteration 26 -- 182 183Warning: hypot() expects parameter 2 to be float, resource given in %s on line %d 184NULL 185===Done===