js/src/tests/ecma/Math/15.8.2.13.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial