Return to pow_variation2.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / math |
1.1 misho 1: --TEST-- 2: Test pow() function : usage variations - different data types as $exp argument 3: --INI-- 4: precision = 14 5: --FILE-- 6: <?php 7: /* Prototype : number pow ( number $base , number $exp ) 8: * Description: Exponential expression. 9: * Source code: ext/standard/math.c 10: */ 11: 12: echo "*** Testing pow() : 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: 12345, 37: -2345, 38: 2147483647, 39: 40: // float data 41: /*6*/ 2.5, 42: -2.5, 43: 12.3456789000e10, 44: 12.3456789000E-10, 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 pow() 81: $iterator = 1; 82: foreach($inputs as $input) { 83: echo "\n-- Iteration $iterator --\n"; 84: var_dump(pow(20.3, $input)); 85: $iterator++; 86: }; 87: fclose($fp); 88: ?> 89: ===Done=== 90: --EXPECTF-- 91: *** Testing pow() : usage variations *** 92: 93: -- Iteration 1 -- 94: float(1) 95: 96: -- Iteration 2 -- 97: float(20.3) 98: 99: -- Iteration 3 -- 100: float(INF) 101: 102: -- Iteration 4 -- 103: float(0) 104: 105: -- Iteration 5 -- 106: float(INF) 107: 108: -- Iteration 6 -- 109: float(1856.6929774279) 110: 111: -- Iteration 7 -- 112: float(0.00053859200856424) 113: 114: -- Iteration 8 -- 115: float(INF) 116: 117: -- Iteration 9 -- 118: float(1.0000000037168) 119: 120: -- Iteration 10 -- 121: float(4.5055521304275) 122: 123: -- Iteration 11 -- 124: float(1) 125: 126: -- Iteration 12 -- 127: float(1) 128: 129: -- Iteration 13 -- 130: float(20.3) 131: 132: -- Iteration 14 -- 133: float(1) 134: 135: -- Iteration 15 -- 136: float(20.3) 137: 138: -- Iteration 16 -- 139: float(1) 140: 141: -- Iteration 17 -- 142: float(1) 143: 144: -- Iteration 18 -- 145: float(1) 146: 147: -- Iteration 19 -- 148: float(1) 149: 150: -- Iteration 20 -- 151: float(1) 152: 153: -- Iteration 21 -- 154: float(1) 155: 156: -- Iteration 22 -- 157: float(1) 158: 159: -- Iteration 23 -- 160: 161: Notice: Object of class classA could not be converted to int in %s on line %d 162: float(20.3) 163: 164: -- Iteration 24 -- 165: float(1) 166: 167: -- Iteration 25 -- 168: float(1) 169: 170: -- Iteration 26 -- 171: %s 172: ===Done===