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