1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
24 ECMA Section: 9.3 Type Conversion: ToNumber
25 Description: rules for converting an argument to a number.
26 see 9.3.1 for cases for converting strings to numbers.
30 Boolean 1 if true; +0 if false
31 Number the argument ( no conversion )
35 This tests special cases of ToNumber(string) that are
36 not covered in 9.3.1-1.js.
38 Author: christine@netscape.com
42 var SECTION = "9.3.1-2";
43 var VERSION = "ECMA_1";
45 var TITLE = "ToNumber applied to the String type";
47 writeHeaderToLog( SECTION + " "+ TITLE);
49 var testcases = getTestCases();
54 for ( tc=0; tc < testcases.length; tc++ ) {
55 testcases[tc].passed = writeTestCaseResult(
58 testcases[tc].description +" = "+
59 testcases[tc].actual );
61 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
66 function getTestCases() {
67 var array = new Array();
70 // A StringNumericLiteral may not use octal notation
72 array[item++] = new TestCase( SECTION, "Number(00)", 0, Number("00"));
73 array[item++] = new TestCase( SECTION, "Number(01)", 1, Number("01"));
74 array[item++] = new TestCase( SECTION, "Number(02)", 2, Number("02"));
75 array[item++] = new TestCase( SECTION, "Number(03)", 3, Number("03"));
76 array[item++] = new TestCase( SECTION, "Number(04)", 4, Number("04"));
77 array[item++] = new TestCase( SECTION, "Number(05)", 5, Number("05"));
78 array[item++] = new TestCase( SECTION, "Number(06)", 6, Number("06"));
79 array[item++] = new TestCase( SECTION, "Number(07)", 7, Number("07"));
80 array[item++] = new TestCase( SECTION, "Number(010)", 10, Number("010"));
81 array[item++] = new TestCase( SECTION, "Number(011)", 11, Number("011"));
83 // A StringNumericLIteral may have any number of leading 0 digits
85 array[item++] = new TestCase( SECTION, "Number(001)", 1, Number("001"));
86 array[item++] = new TestCase( SECTION, "Number(0001)", 1, Number("0001"));