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.17.js michael@0: ECMA Section: 15.8.2.17 Math.sqrt(x) michael@0: Description: return an approximation to the squareroot of the argument. michael@0: special cases: michael@0: - if x is NaN return NaN michael@0: - if x < 0 return NaN michael@0: - if x == 0 return 0 michael@0: - if x == -0 return -0 michael@0: - if x == Infinity return Infinity michael@0: Author: christine@netscape.com michael@0: Date: 7 july 1997 michael@0: */ michael@0: michael@0: var SECTION = "15.8.2.17"; michael@0: var VERSION = "ECMA_1"; michael@0: startTest(); michael@0: var TITLE = "Math.sqrt(x)"; michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt.length", michael@0: 1, michael@0: Math.sqrt.length ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt()", michael@0: Number.NaN, michael@0: Math.sqrt() ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(void 0)", michael@0: Number.NaN, michael@0: Math.sqrt(void 0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(null)", michael@0: 0, michael@0: Math.sqrt(null) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(true)", michael@0: 1, michael@0: Math.sqrt(1) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(false)", michael@0: 0, michael@0: Math.sqrt(false) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt('225')", michael@0: 15, michael@0: Math.sqrt('225') ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(NaN)", michael@0: Number.NaN, michael@0: Math.sqrt(Number.NaN) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(-Infinity)", michael@0: Number.NaN, michael@0: Math.sqrt(Number.NEGATIVE_INFINITY)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(-1)", michael@0: Number.NaN, michael@0: Math.sqrt(-1)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(-0.5)", michael@0: Number.NaN, michael@0: Math.sqrt(-0.5)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(0)", michael@0: 0, michael@0: Math.sqrt(0)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(-0)", michael@0: -0, michael@0: Math.sqrt(-0)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Infinity/Math.sqrt(-0)", michael@0: -Infinity, michael@0: Infinity/Math.sqrt(-0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(Infinity)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.sqrt(Number.POSITIVE_INFINITY)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(1)", michael@0: 1, michael@0: Math.sqrt(1)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(2)", michael@0: Math.SQRT2, michael@0: Math.sqrt(2)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(0.5)", michael@0: Math.SQRT1_2, michael@0: Math.sqrt(0.5)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(4)", michael@0: 2, michael@0: Math.sqrt(4)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(9)", michael@0: 3, michael@0: Math.sqrt(9)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(16)", michael@0: 4, michael@0: Math.sqrt(16)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(25)", michael@0: 5, michael@0: Math.sqrt(25)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(36)", michael@0: 6, michael@0: Math.sqrt(36)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(49)", michael@0: 7, michael@0: Math.sqrt(49)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(64)", michael@0: 8, michael@0: Math.sqrt(64)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(256)", michael@0: 16, michael@0: Math.sqrt(256)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(10000)", michael@0: 100, michael@0: Math.sqrt(10000)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(65536)", michael@0: 256, michael@0: Math.sqrt(65536)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(0.09)", michael@0: 0.3, michael@0: Math.sqrt(0.09)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(0.01)", michael@0: 0.1, michael@0: Math.sqrt(0.01)); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.sqrt(0.00000001)", michael@0: 0.0001, michael@0: Math.sqrt(0.00000001)); michael@0: michael@0: test();