michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: File Name: 15.8.2.13.js michael@0: ECMA Section: 15.8.2.13 Math.pow(x, y) michael@0: Description: return an approximation to the result of x michael@0: to the power of y. there are many special cases; michael@0: refer to the spec. michael@0: Author: christine@netscape.com michael@0: Date: 9 july 1997 michael@0: */ michael@0: michael@0: var SECTION = "15.8.2.13"; michael@0: var VERSION = "ECMA_1"; michael@0: var TITLE = "Math.pow(x, y)"; michael@0: var BUGNUMBER="77141"; michael@0: michael@0: startTest(); michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow.length", michael@0: 2, michael@0: Math.pow.length ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow()", michael@0: Number.NaN, michael@0: Math.pow() ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(null, null)", michael@0: 1, michael@0: Math.pow(null,null) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(void 0, void 0)", michael@0: Number.NaN, michael@0: Math.pow(void 0, void 0)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(true, false)", michael@0: 1, michael@0: Math.pow(true, false) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(false,true)", michael@0: 0, michael@0: Math.pow(false,true) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow('2','32')", michael@0: 4294967296, michael@0: Math.pow('2','32') ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(1,NaN)", michael@0: Number.NaN, michael@0: Math.pow(1,Number.NaN) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(0,NaN)", michael@0: Number.NaN, michael@0: Math.pow(0,Number.NaN) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(NaN,0)", michael@0: 1, michael@0: Math.pow(Number.NaN,0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(NaN,-0)", michael@0: 1, michael@0: Math.pow(Number.NaN,-0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(NaN,1)", michael@0: Number.NaN, michael@0: Math.pow(Number.NaN, 1) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(NaN,.5)", michael@0: Number.NaN, michael@0: Math.pow(Number.NaN, .5) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(1.00000001, Infinity)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.pow(1.00000001, Number.POSITIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(1.00000001, -Infinity)", michael@0: 0, michael@0: Math.pow(1.00000001, Number.NEGATIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-1.00000001, Infinity)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.pow(-1.00000001,Number.POSITIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-1.00000001, -Infinity)", michael@0: 0, michael@0: Math.pow(-1.00000001,Number.NEGATIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(1, Infinity)", michael@0: Number.NaN, michael@0: Math.pow(1, Number.POSITIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(1, -Infinity)", michael@0: Number.NaN, michael@0: Math.pow(1, Number.NEGATIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-1, Infinity)", michael@0: Number.NaN, michael@0: Math.pow(-1, Number.POSITIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-1, -Infinity)", michael@0: Number.NaN, michael@0: Math.pow(-1, Number.NEGATIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(.0000000009, Infinity)", michael@0: 0, michael@0: Math.pow(.0000000009, Number.POSITIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-.0000000009, Infinity)", michael@0: 0, michael@0: Math.pow(-.0000000009, Number.POSITIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(.0000000009, -Infinity)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.pow(-.0000000009, Number.NEGATIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(Infinity, .00000000001)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.pow(Number.POSITIVE_INFINITY,.00000000001) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(Infinity, 1)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.pow(Number.POSITIVE_INFINITY, 1) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(Infinity, -.00000000001)", michael@0: 0, michael@0: Math.pow(Number.POSITIVE_INFINITY, -.00000000001) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(Infinity, -1)", michael@0: 0, michael@0: Math.pow(Number.POSITIVE_INFINITY, -1) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-Infinity, 1)", michael@0: Number.NEGATIVE_INFINITY, michael@0: Math.pow(Number.NEGATIVE_INFINITY, 1) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-Infinity, 333)", michael@0: Number.NEGATIVE_INFINITY, michael@0: Math.pow(Number.NEGATIVE_INFINITY, 333) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(Infinity, 2)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.pow(Number.POSITIVE_INFINITY, 2) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-Infinity, 666)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.pow(Number.NEGATIVE_INFINITY, 666) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-Infinity, 0.5)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.pow(Number.NEGATIVE_INFINITY, 0.5) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-Infinity, Infinity)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.pow(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-Infinity, -1)", michael@0: -0, michael@0: Math.pow(Number.NEGATIVE_INFINITY, -1) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Infinity/Math.pow(-Infinity, -1)", michael@0: -Infinity, michael@0: Infinity/Math.pow(Number.NEGATIVE_INFINITY, -1) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-Infinity, -3)", michael@0: -0, michael@0: Math.pow(Number.NEGATIVE_INFINITY, -3) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-Infinity, -2)", michael@0: 0, michael@0: Math.pow(Number.NEGATIVE_INFINITY, -2) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-Infinity, -0.5)", michael@0: 0, michael@0: Math.pow(Number.NEGATIVE_INFINITY,-0.5) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-Infinity, -Infinity)", michael@0: 0, michael@0: Math.pow(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(0, 1)", michael@0: 0, michael@0: Math.pow(0,1) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(0, 0)", michael@0: 1, michael@0: Math.pow(0,0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(1, 0)", michael@0: 1, michael@0: Math.pow(1,0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-1, 0)", michael@0: 1, michael@0: Math.pow(-1,0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(0, 0.5)", michael@0: 0, michael@0: Math.pow(0,0.5) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(0, 1000)", michael@0: 0, michael@0: Math.pow(0,1000) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(0, Infinity)", michael@0: 0, michael@0: Math.pow(0, Number.POSITIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(0, -1)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.pow(0, -1) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(0, -0.5)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.pow(0, -0.5) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(0, -1000)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.pow(0, -1000) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(0, -Infinity)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.pow(0, Number.NEGATIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-0, 1)", michael@0: -0, michael@0: Math.pow(-0, 1) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-0, 3)", michael@0: -0, michael@0: Math.pow(-0,3) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Infinity/Math.pow(-0, 1)", michael@0: -Infinity, michael@0: Infinity/Math.pow(-0, 1) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Infinity/Math.pow(-0, 3)", michael@0: -Infinity, michael@0: Infinity/Math.pow(-0,3) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-0, 2)", michael@0: 0, michael@0: Math.pow(-0,2) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-0, Infinity)", michael@0: 0, michael@0: Math.pow(-0, Number.POSITIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-0, -1)", michael@0: Number.NEGATIVE_INFINITY, michael@0: Math.pow(-0, -1) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-0, -10001)", michael@0: Number.NEGATIVE_INFINITY, michael@0: Math.pow(-0, -10001) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-0, -2)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.pow(-0, -2) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-0, 0.5)", michael@0: 0, michael@0: Math.pow(-0, 0.5) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-0, Infinity)", michael@0: 0, michael@0: Math.pow(-0, Number.POSITIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-1, 0.5)", michael@0: Number.NaN, michael@0: Math.pow(-1, 0.5) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-1, NaN)", michael@0: Number.NaN, michael@0: Math.pow(-1, Number.NaN) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.pow(-1, -0.5)", michael@0: Number.NaN, michael@0: Math.pow(-1, -0.5) ); michael@0: michael@0: test();