15.8.2.13.js (7804B)
1 /* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 7 /** 8 File Name: 15.8.2.13.js 9 ECMA Section: 15.8.2.13 Math.pow(x, y) 10 Description: return an approximation to the result of x 11 to the power of y. there are many special cases; 12 refer to the spec. 13 Author: christine@netscape.com 14 Date: 9 july 1997 15 */ 16 17 var SECTION = "15.8.2.13"; 18 var TITLE = "Math.pow(x, y)"; 19 var BUGNUMBER="77141"; 20 21 printBugNumber(BUGNUMBER); 22 23 writeHeaderToLog( SECTION + " "+ TITLE); 24 25 new TestCase( 26 "Math.pow.length", 27 2, 28 Math.pow.length ); 29 30 new TestCase( 31 "Math.pow()", 32 Number.NaN, 33 Math.pow() ); 34 35 new TestCase( 36 "Math.pow(null, null)", 37 1, 38 Math.pow(null,null) ); 39 40 new TestCase( 41 "Math.pow(void 0, void 0)", 42 Number.NaN, 43 Math.pow(void 0, void 0)); 44 45 new TestCase( 46 "Math.pow(true, false)", 47 1, 48 Math.pow(true, false) ); 49 50 new TestCase( 51 "Math.pow(false,true)", 52 0, 53 Math.pow(false,true) ); 54 55 new TestCase( 56 "Math.pow('2','32')", 57 4294967296, 58 Math.pow('2','32') ); 59 60 new TestCase( 61 "Math.pow(1,NaN)", 62 Number.NaN, 63 Math.pow(1,Number.NaN) ); 64 65 new TestCase( 66 "Math.pow(0,NaN)", 67 Number.NaN, 68 Math.pow(0,Number.NaN) ); 69 70 new TestCase( 71 "Math.pow(NaN,0)", 72 1, 73 Math.pow(Number.NaN,0) ); 74 75 new TestCase( 76 "Math.pow(NaN,-0)", 77 1, 78 Math.pow(Number.NaN,-0) ); 79 80 new TestCase( 81 "Math.pow(NaN,1)", 82 Number.NaN, 83 Math.pow(Number.NaN, 1) ); 84 85 new TestCase( 86 "Math.pow(NaN,.5)", 87 Number.NaN, 88 Math.pow(Number.NaN, .5) ); 89 90 new TestCase( 91 "Math.pow(1.00000001, Infinity)", 92 Number.POSITIVE_INFINITY, 93 Math.pow(1.00000001, Number.POSITIVE_INFINITY) ); 94 95 new TestCase( 96 "Math.pow(1.00000001, -Infinity)", 97 0, 98 Math.pow(1.00000001, Number.NEGATIVE_INFINITY) ); 99 100 new TestCase( 101 "Math.pow(-1.00000001, Infinity)", 102 Number.POSITIVE_INFINITY, 103 Math.pow(-1.00000001,Number.POSITIVE_INFINITY) ); 104 105 new TestCase( 106 "Math.pow(-1.00000001, -Infinity)", 107 0, 108 Math.pow(-1.00000001,Number.NEGATIVE_INFINITY) ); 109 110 new TestCase( 111 "Math.pow(1, Infinity)", 112 Number.NaN, 113 Math.pow(1, Number.POSITIVE_INFINITY) ); 114 115 new TestCase( 116 "Math.pow(1, -Infinity)", 117 Number.NaN, 118 Math.pow(1, Number.NEGATIVE_INFINITY) ); 119 120 new TestCase( 121 "Math.pow(-1, Infinity)", 122 Number.NaN, 123 Math.pow(-1, Number.POSITIVE_INFINITY) ); 124 125 new TestCase( 126 "Math.pow(-1, -Infinity)", 127 Number.NaN, 128 Math.pow(-1, Number.NEGATIVE_INFINITY) ); 129 130 new TestCase( 131 "Math.pow(.0000000009, Infinity)", 132 0, 133 Math.pow(.0000000009, Number.POSITIVE_INFINITY) ); 134 135 new TestCase( 136 "Math.pow(-.0000000009, Infinity)", 137 0, 138 Math.pow(-.0000000009, Number.POSITIVE_INFINITY) ); 139 140 new TestCase( 141 "Math.pow(.0000000009, -Infinity)", 142 Number.POSITIVE_INFINITY, 143 Math.pow(-.0000000009, Number.NEGATIVE_INFINITY) ); 144 145 new TestCase( 146 "Math.pow(Infinity, .00000000001)", 147 Number.POSITIVE_INFINITY, 148 Math.pow(Number.POSITIVE_INFINITY,.00000000001) ); 149 150 new TestCase( 151 "Math.pow(Infinity, 1)", 152 Number.POSITIVE_INFINITY, 153 Math.pow(Number.POSITIVE_INFINITY, 1) ); 154 155 new TestCase( 156 "Math.pow(Infinity, -.00000000001)", 157 0, 158 Math.pow(Number.POSITIVE_INFINITY, -.00000000001) ); 159 160 new TestCase( 161 "Math.pow(Infinity, -1)", 162 0, 163 Math.pow(Number.POSITIVE_INFINITY, -1) ); 164 165 new TestCase( 166 "Math.pow(-Infinity, 1)", 167 Number.NEGATIVE_INFINITY, 168 Math.pow(Number.NEGATIVE_INFINITY, 1) ); 169 170 new TestCase( 171 "Math.pow(-Infinity, 333)", 172 Number.NEGATIVE_INFINITY, 173 Math.pow(Number.NEGATIVE_INFINITY, 333) ); 174 175 new TestCase( 176 "Math.pow(Infinity, 2)", 177 Number.POSITIVE_INFINITY, 178 Math.pow(Number.POSITIVE_INFINITY, 2) ); 179 180 new TestCase( 181 "Math.pow(-Infinity, 666)", 182 Number.POSITIVE_INFINITY, 183 Math.pow(Number.NEGATIVE_INFINITY, 666) ); 184 185 new TestCase( 186 "Math.pow(-Infinity, 0.5)", 187 Number.POSITIVE_INFINITY, 188 Math.pow(Number.NEGATIVE_INFINITY, 0.5) ); 189 190 new TestCase( 191 "Math.pow(-Infinity, Infinity)", 192 Number.POSITIVE_INFINITY, 193 Math.pow(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); 194 195 new TestCase( 196 "Math.pow(-Infinity, -1)", 197 -0, 198 Math.pow(Number.NEGATIVE_INFINITY, -1) ); 199 200 new TestCase( 201 "Infinity/Math.pow(-Infinity, -1)", 202 -Infinity, 203 Infinity/Math.pow(Number.NEGATIVE_INFINITY, -1) ); 204 205 new TestCase( 206 "Math.pow(-Infinity, -3)", 207 -0, 208 Math.pow(Number.NEGATIVE_INFINITY, -3) ); 209 210 new TestCase( 211 "Math.pow(-Infinity, -2)", 212 0, 213 Math.pow(Number.NEGATIVE_INFINITY, -2) ); 214 215 new TestCase( 216 "Math.pow(-Infinity, -0.5)", 217 0, 218 Math.pow(Number.NEGATIVE_INFINITY,-0.5) ); 219 220 new TestCase( 221 "Math.pow(-Infinity, -Infinity)", 222 0, 223 Math.pow(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); 224 225 new TestCase( 226 "Math.pow(0, 1)", 227 0, 228 Math.pow(0,1) ); 229 230 new TestCase( 231 "Math.pow(0, 0)", 232 1, 233 Math.pow(0,0) ); 234 235 new TestCase( 236 "Math.pow(1, 0)", 237 1, 238 Math.pow(1,0) ); 239 240 new TestCase( 241 "Math.pow(-1, 0)", 242 1, 243 Math.pow(-1,0) ); 244 245 new TestCase( 246 "Math.pow(0, 0.5)", 247 0, 248 Math.pow(0,0.5) ); 249 250 new TestCase( 251 "Math.pow(0, 1000)", 252 0, 253 Math.pow(0,1000) ); 254 255 new TestCase( 256 "Math.pow(0, Infinity)", 257 0, 258 Math.pow(0, Number.POSITIVE_INFINITY) ); 259 260 new TestCase( 261 "Math.pow(0, -1)", 262 Number.POSITIVE_INFINITY, 263 Math.pow(0, -1) ); 264 265 new TestCase( 266 "Math.pow(0, -0.5)", 267 Number.POSITIVE_INFINITY, 268 Math.pow(0, -0.5) ); 269 270 new TestCase( 271 "Math.pow(0, -1000)", 272 Number.POSITIVE_INFINITY, 273 Math.pow(0, -1000) ); 274 275 new TestCase( 276 "Math.pow(0, -Infinity)", 277 Number.POSITIVE_INFINITY, 278 Math.pow(0, Number.NEGATIVE_INFINITY) ); 279 280 new TestCase( 281 "Math.pow(-0, 1)", 282 -0, 283 Math.pow(-0, 1) ); 284 285 new TestCase( 286 "Math.pow(-0, 3)", 287 -0, 288 Math.pow(-0,3) ); 289 290 new TestCase( 291 "Infinity/Math.pow(-0, 1)", 292 -Infinity, 293 Infinity/Math.pow(-0, 1) ); 294 295 new TestCase( 296 "Infinity/Math.pow(-0, 3)", 297 -Infinity, 298 Infinity/Math.pow(-0,3) ); 299 300 new TestCase( 301 "Math.pow(-0, 2)", 302 0, 303 Math.pow(-0,2) ); 304 305 new TestCase( 306 "Math.pow(-0, Infinity)", 307 0, 308 Math.pow(-0, Number.POSITIVE_INFINITY) ); 309 310 new TestCase( 311 "Math.pow(-0, -1)", 312 Number.NEGATIVE_INFINITY, 313 Math.pow(-0, -1) ); 314 315 new TestCase( 316 "Math.pow(-0, -10001)", 317 Number.NEGATIVE_INFINITY, 318 Math.pow(-0, -10001) ); 319 320 new TestCase( 321 "Math.pow(-0, -2)", 322 Number.POSITIVE_INFINITY, 323 Math.pow(-0, -2) ); 324 325 new TestCase( 326 "Math.pow(-0, 0.5)", 327 0, 328 Math.pow(-0, 0.5) ); 329 330 new TestCase( 331 "Math.pow(-0, Infinity)", 332 0, 333 Math.pow(-0, Number.POSITIVE_INFINITY) ); 334 335 new TestCase( 336 "Math.pow(-1, 0.5)", 337 Number.NaN, 338 Math.pow(-1, 0.5) ); 339 340 new TestCase( 341 "Math.pow(-1, NaN)", 342 Number.NaN, 343 Math.pow(-1, Number.NaN) ); 344 345 new TestCase( 346 "Math.pow(-1, -0.5)", 347 Number.NaN, 348 Math.pow(-1, -0.5) ); 349 350 test();