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.11.js michael@0: ECMA Section: 15.8.2.11 Math.max(x, y) michael@0: Description: return the smaller of the two arguments. michael@0: special cases: michael@0: - if x is NaN or y is NaN return NaN michael@0: - if x < y return x michael@0: - if y > x return y michael@0: - if x is +0 and y is +0 return +0 michael@0: - if x is +0 and y is -0 return -0 michael@0: - if x is -0 and y is +0 return -0 michael@0: - if x is -0 and y is -0 return -0 michael@0: Author: christine@netscape.com michael@0: Date: 7 july 1997 michael@0: */ michael@0: michael@0: var SECTION = "15.8.2.11"; michael@0: var VERSION = "ECMA_1"; michael@0: var TITLE = "Math.max(x, y)"; michael@0: var BUGNUMBER="76439"; michael@0: michael@0: startTest(); michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max.length", michael@0: 2, michael@0: Math.max.length ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max()", michael@0: -Infinity, michael@0: Math.max() ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(void 0, 1)", michael@0: Number.NaN, michael@0: Math.max( void 0, 1 ) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(void 0, void 0)", michael@0: Number.NaN, michael@0: Math.max( void 0, void 0 ) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(null, 1)", michael@0: 1, michael@0: Math.max( null, 1 ) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(-1, null)", michael@0: 0, michael@0: Math.max( -1, null ) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(true, false)", michael@0: 1, michael@0: Math.max(true,false) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max('-99','99')", michael@0: 99, michael@0: Math.max( "-99","99") ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(NaN, Infinity)", michael@0: Number.NaN, michael@0: Math.max(Number.NaN,Number.POSITIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(NaN, 0)", michael@0: Number.NaN, michael@0: Math.max(Number.NaN, 0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max('a string', 0)", michael@0: Number.NaN, michael@0: Math.max("a string", 0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(NaN, 1)", michael@0: Number.NaN, michael@0: Math.max(Number.NaN,1) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max('a string',Infinity)", michael@0: Number.NaN, michael@0: Math.max("a string", Number.POSITIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(Infinity, NaN)", michael@0: Number.NaN, michael@0: Math.max( Number.POSITIVE_INFINITY, Number.NaN) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(NaN, NaN)", michael@0: Number.NaN, michael@0: Math.max(Number.NaN, Number.NaN) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(0,NaN)", michael@0: Number.NaN, michael@0: Math.max(0,Number.NaN) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(1, NaN)", michael@0: Number.NaN, michael@0: Math.max(1, Number.NaN) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(0,0)", michael@0: 0, michael@0: Math.max(0,0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(0,-0)", michael@0: 0, michael@0: Math.max(0,-0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(-0,0)", michael@0: 0, michael@0: Math.max(-0,0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(-0,-0)", michael@0: -0, michael@0: Math.max(-0,-0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Infinity/Math.max(-0,-0)", michael@0: -Infinity, michael@0: Infinity/Math.max(-0,-0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(Infinity, Number.MAX_VALUE)", Number.POSITIVE_INFINITY, michael@0: Math.max(Number.POSITIVE_INFINITY, Number.MAX_VALUE) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(Infinity, Infinity)", michael@0: Number.POSITIVE_INFINITY, michael@0: Math.max(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(-Infinity,-Infinity)", michael@0: Number.NEGATIVE_INFINITY, michael@0: Math.max(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(1,.99999999999999)", michael@0: 1, michael@0: Math.max(1,.99999999999999) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.max(-1,-.99999999999999)", michael@0: -.99999999999999, michael@0: Math.max(-1,-.99999999999999) ); michael@0: michael@0: test();