Return to atan2_variation1.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 $y 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() : usage variations ***\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($input, 23)); 85: $iterator++; 86: }; 87: 88: fclose($fp); 89: ?> 90: ===Done=== 91: --EXPECTF-- 92: *** Testing atan2() : usage variations *** 93: 94: -- Iteration 1 -- 95: float(0) 96: 97: -- Iteration 2 -- 98: float(0.04345089539) 99: 100: -- Iteration 3 -- 101: float(0.4808872802) 102: 103: -- Iteration 4 -- 104: float(-0.4808872802) 105: 106: -- Iteration 5 -- 107: float(1.570796316) 108: 109: -- Iteration 6 -- 110: float(0.4282641529) 111: 112: -- Iteration 7 -- 113: float(-0.4282641529) 114: 115: -- Iteration 8 -- 116: float(1.386607742) 117: 118: -- Iteration 9 -- 119: float(0.0005367682093) 120: 121: -- Iteration 10 -- 122: float(0.02173570684) 123: 124: -- Iteration 11 -- 125: float(0) 126: 127: -- Iteration 12 -- 128: float(0) 129: 130: -- Iteration 13 -- 131: float(0.04345089539) 132: 133: -- Iteration 14 -- 134: float(0) 135: 136: -- Iteration 15 -- 137: float(0.04345089539) 138: 139: -- Iteration 16 -- 140: float(0) 141: 142: -- Iteration 17 -- 143: 144: Warning: atan2() expects parameter 1 to be double, string given in %s on line %d 145: NULL 146: 147: -- Iteration 18 -- 148: 149: Warning: atan2() expects parameter 1 to be double, string given in %s on line %d 150: NULL 151: 152: -- Iteration 19 -- 153: 154: Warning: atan2() expects parameter 1 to be double, array given in %s on line %d 155: NULL 156: 157: -- Iteration 20 -- 158: 159: Warning: atan2() expects parameter 1 to be double, string given in %s on line %d 160: NULL 161: 162: -- Iteration 21 -- 163: 164: Warning: atan2() expects parameter 1 to be double, string given in %s on line %d 165: NULL 166: 167: -- Iteration 22 -- 168: 169: Warning: atan2() expects parameter 1 to be double, string given in %s on line %d 170: NULL 171: 172: -- Iteration 23 -- 173: 174: Warning: atan2() expects parameter 1 to be double, object given in %s on line %d 175: NULL 176: 177: -- Iteration 24 -- 178: float(0) 179: 180: -- Iteration 25 -- 181: float(0) 182: 183: -- Iteration 26 -- 184: 185: Warning: atan2() expects parameter 1 to be double, resource given in %s on line %d 186: NULL 187: ===Done===