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.7.1.js michael@0: ECMA Section: 15.7.1 The Number Constructor Called as a Function michael@0: 15.7.1.1 michael@0: 15.7.1.2 michael@0: michael@0: Description: When Number is called as a function rather than as a michael@0: constructor, it performs a type conversion. michael@0: 15.7.1.1 Return a number value (not a Number object) michael@0: computed by ToNumber( value ) michael@0: 15.7.1.2 Number() returns 0. michael@0: michael@0: need to add more test cases. see the testcases for michael@0: TypeConversion ToNumber. michael@0: michael@0: Author: christine@netscape.com michael@0: Date: 29 september 1997 michael@0: */ michael@0: michael@0: var SECTION = "15.7.1"; michael@0: var VERSION = "ECMA_1"; michael@0: startTest(); michael@0: var TITLE = "The Number Constructor Called as a Function"; michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: new TestCase(SECTION, "Number()", 0, Number() ); michael@0: new TestCase(SECTION, "Number(void 0)", Number.NaN, Number(void 0) ); michael@0: new TestCase(SECTION, "Number(null)", 0, Number(null) ); michael@0: new TestCase(SECTION, "Number()", 0, Number() ); michael@0: new TestCase(SECTION, "Number(new Number())", 0, Number( new Number() ) ); michael@0: new TestCase(SECTION, "Number(0)", 0, Number(0) ); michael@0: new TestCase(SECTION, "Number(1)", 1, Number(1) ); michael@0: new TestCase(SECTION, "Number(-1)", -1, Number(-1) ); michael@0: new TestCase(SECTION, "Number(NaN)", Number.NaN, Number( Number.NaN ) ); michael@0: new TestCase(SECTION, "Number('string')", Number.NaN, Number( "string") ); michael@0: new TestCase(SECTION, "Number(new String())", 0, Number( new String() ) ); michael@0: new TestCase(SECTION, "Number('')", 0, Number( "" ) ); michael@0: new TestCase(SECTION, "Number(Infinity)", Number.POSITIVE_INFINITY, Number("Infinity") ); michael@0: michael@0: new TestCase(SECTION, "Number(new MyObject(100))", 100, Number(new MyObject(100)) ); michael@0: michael@0: test(); michael@0: michael@0: function MyObject( value ) { michael@0: this.value = value; michael@0: this.valueOf = new Function( "return this.value" ); michael@0: }