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.1.2.3.js michael@0: ECMA Section: 15.1.2.3 Function properties of the global object: michael@0: parseFloat( string ) michael@0: michael@0: Description: The parseFloat function produces a number value dictated michael@0: by the interpretation of the contents of the string michael@0: argument defined as a decimal literal. michael@0: michael@0: When the parseFloat function is called, the following michael@0: steps are taken: michael@0: michael@0: 1. Call ToString( string ). michael@0: 2. Remove leading whitespace Result(1). michael@0: 3. If neither Result(2) nor any prefix of Result(2) michael@0: satisfies the syntax of a StrDecimalLiteral, michael@0: return NaN. michael@0: 4. Compute the longest prefix of Result(2) which might michael@0: be Resusult(2) itself, that satisfies the syntax of michael@0: a StrDecimalLiteral michael@0: 5. Return the number value for the MV of Result(4). michael@0: michael@0: Note that parseFloate may interpret only a leading michael@0: portion of the string as a number value; it ignores any michael@0: characters that cannot be interpreted as part of the michael@0: notation of a decimal literal, and no indication is given michael@0: that such characters were ignored. michael@0: michael@0: StrDecimalLiteral:: michael@0: Infinity michael@0: DecimalDigits.DecimalDigits opt ExponentPart opt michael@0: .DecimalDigits ExponentPart opt michael@0: DecimalDigits ExponentPart opt michael@0: michael@0: Author: christine@netscape.com michael@0: Date: 28 october 1997 michael@0: michael@0: */ michael@0: michael@0: var SECTION = "15.1.2.3-1"; michael@0: var VERSION = "ECMA_1"; michael@0: var TITLE = "parseFloat(string)"; michael@0: var BUGNUMBER="none"; michael@0: michael@0: startTest(); michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: new TestCase( SECTION, "parseFloat.length", 1, parseFloat.length ); michael@0: michael@0: new TestCase( SECTION, "parseFloat.length = null; parseFloat.length", 1, eval("parseFloat.length = null; parseFloat.length") ); michael@0: new TestCase( SECTION, "delete parseFloat.length", false, delete parseFloat.length ); michael@0: new TestCase( SECTION, "delete parseFloat.length; parseFloat.length", 1, eval("delete parseFloat.length; parseFloat.length") ); michael@0: new TestCase( SECTION, "var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat()", Number.NaN, parseFloat() ); michael@0: new TestCase( SECTION, "parseFloat('')", Number.NaN, parseFloat('') ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(' ')", Number.NaN, parseFloat(' ') ); michael@0: new TestCase( SECTION, "parseFloat(true)", Number.NaN, parseFloat(true) ); michael@0: new TestCase( SECTION, "parseFloat(false)", Number.NaN, parseFloat(false) ); michael@0: new TestCase( SECTION, "parseFloat('string')", Number.NaN, parseFloat("string") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(' Infinity')", Infinity, parseFloat("Infinity") ); michael@0: new TestCase( SECTION, "parseFloat(' Infinity ')", Infinity, parseFloat(' Infinity ') ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('Infinity')", Infinity, parseFloat("Infinity") ); michael@0: new TestCase( SECTION, "parseFloat(Infinity)", Infinity, parseFloat(Infinity) ); michael@0: michael@0: michael@0: new TestCase( SECTION, "parseFloat(' +Infinity')", +Infinity, parseFloat("+Infinity") ); michael@0: new TestCase( SECTION, "parseFloat(' -Infinity ')", -Infinity, parseFloat(' -Infinity ') ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('+Infinity')", +Infinity, parseFloat("+Infinity") ); michael@0: new TestCase( SECTION, "parseFloat(-Infinity)", -Infinity, parseFloat(-Infinity) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('0')", 0, parseFloat("0") ); michael@0: new TestCase( SECTION, "parseFloat('-0')", -0, parseFloat("-0") ); michael@0: new TestCase( SECTION, "parseFloat('+0')", 0, parseFloat("+0") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('1')", 1, parseFloat("1") ); michael@0: new TestCase( SECTION, "parseFloat('-1')", -1, parseFloat("-1") ); michael@0: new TestCase( SECTION, "parseFloat('+1')", 1, parseFloat("+1") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('2')", 2, parseFloat("2") ); michael@0: new TestCase( SECTION, "parseFloat('-2')", -2, parseFloat("-2") ); michael@0: new TestCase( SECTION, "parseFloat('+2')", 2, parseFloat("+2") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('3')", 3, parseFloat("3") ); michael@0: new TestCase( SECTION, "parseFloat('-3')", -3, parseFloat("-3") ); michael@0: new TestCase( SECTION, "parseFloat('+3')", 3, parseFloat("+3") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('4')", 4, parseFloat("4") ); michael@0: new TestCase( SECTION, "parseFloat('-4')", -4, parseFloat("-4") ); michael@0: new TestCase( SECTION, "parseFloat('+4')", 4, parseFloat("+4") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('5')", 5, parseFloat("5") ); michael@0: new TestCase( SECTION, "parseFloat('-5')", -5, parseFloat("-5") ); michael@0: new TestCase( SECTION, "parseFloat('+5')", 5, parseFloat("+5") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('6')", 6, parseFloat("6") ); michael@0: new TestCase( SECTION, "parseFloat('-6')", -6, parseFloat("-6") ); michael@0: new TestCase( SECTION, "parseFloat('+6')", 6, parseFloat("+6") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('7')", 7, parseFloat("7") ); michael@0: new TestCase( SECTION, "parseFloat('-7')", -7, parseFloat("-7") ); michael@0: new TestCase( SECTION, "parseFloat('+7')", 7, parseFloat("+7") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('8')", 8, parseFloat("8") ); michael@0: new TestCase( SECTION, "parseFloat('-8')", -8, parseFloat("-8") ); michael@0: new TestCase( SECTION, "parseFloat('+8')", 8, parseFloat("+8") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('9')", 9, parseFloat("9") ); michael@0: new TestCase( SECTION, "parseFloat('-9')", -9, parseFloat("-9") ); michael@0: new TestCase( SECTION, "parseFloat('+9')", 9, parseFloat("+9") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('3.14159')", 3.14159, parseFloat("3.14159") ); michael@0: new TestCase( SECTION, "parseFloat('-3.14159')", -3.14159, parseFloat("-3.14159") ); michael@0: new TestCase( SECTION, "parseFloat('+3.14159')", 3.14159, parseFloat("+3.14159") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('3.')", 3, parseFloat("3.") ); michael@0: new TestCase( SECTION, "parseFloat('-3.')", -3, parseFloat("-3.") ); michael@0: new TestCase( SECTION, "parseFloat('+3.')", 3, parseFloat("+3.") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('3.e1')", 30, parseFloat("3.e1") ); michael@0: new TestCase( SECTION, "parseFloat('-3.e1')", -30, parseFloat("-3.e1") ); michael@0: new TestCase( SECTION, "parseFloat('+3.e1')", 30, parseFloat("+3.e1") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('3.e+1')", 30, parseFloat("3.e+1") ); michael@0: new TestCase( SECTION, "parseFloat('-3.e+1')", -30, parseFloat("-3.e+1") ); michael@0: new TestCase( SECTION, "parseFloat('+3.e+1')", 30, parseFloat("+3.e+1") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('3.e-1')", .30, parseFloat("3.e-1") ); michael@0: new TestCase( SECTION, "parseFloat('-3.e-1')", -.30, parseFloat("-3.e-1") ); michael@0: new TestCase( SECTION, "parseFloat('+3.e-1')", .30, parseFloat("+3.e-1") ); michael@0: michael@0: // StrDecimalLiteral::: .DecimalDigits ExponentPart opt michael@0: michael@0: new TestCase( SECTION, "parseFloat('.00001')", 0.00001, parseFloat(".00001") ); michael@0: new TestCase( SECTION, "parseFloat('+.00001')", 0.00001, parseFloat("+.00001") ); michael@0: new TestCase( SECTION, "parseFloat('-0.0001')", -0.00001, parseFloat("-.00001") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('.01e2')", 1, parseFloat(".01e2") ); michael@0: new TestCase( SECTION, "parseFloat('+.01e2')", 1, parseFloat("+.01e2") ); michael@0: new TestCase( SECTION, "parseFloat('-.01e2')", -1, parseFloat("-.01e2") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('.01e+2')", 1, parseFloat(".01e+2") ); michael@0: new TestCase( SECTION, "parseFloat('+.01e+2')", 1, parseFloat("+.01e+2") ); michael@0: new TestCase( SECTION, "parseFloat('-.01e+2')", -1, parseFloat("-.01e+2") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('.01e-2')", 0.0001, parseFloat(".01e-2") ); michael@0: new TestCase( SECTION, "parseFloat('+.01e-2')", 0.0001, parseFloat("+.01e-2") ); michael@0: new TestCase( SECTION, "parseFloat('-.01e-2')", -0.0001, parseFloat("-.01e-2") ); michael@0: michael@0: // StrDecimalLiteral::: DecimalDigits ExponentPart opt michael@0: michael@0: new TestCase( SECTION, "parseFloat('1234e5')", 123400000, parseFloat("1234e5") ); michael@0: new TestCase( SECTION, "parseFloat('+1234e5')", 123400000, parseFloat("+1234e5") ); michael@0: new TestCase( SECTION, "parseFloat('-1234e5')", -123400000, parseFloat("-1234e5") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('1234e+5')", 123400000, parseFloat("1234e+5") ); michael@0: new TestCase( SECTION, "parseFloat('+1234e+5')", 123400000, parseFloat("+1234e+5") ); michael@0: new TestCase( SECTION, "parseFloat('-1234e+5')", -123400000, parseFloat("-1234e+5") ); michael@0: michael@0: new TestCase( SECTION, "parseFloat('1234e-5')", 0.01234, parseFloat("1234e-5") ); michael@0: new TestCase( SECTION, "parseFloat('+1234e-5')", 0.01234, parseFloat("+1234e-5") ); michael@0: new TestCase( SECTION, "parseFloat('-1234e-5')", -0.01234, parseFloat("-1234e-5") ); michael@0: michael@0: michael@0: new TestCase( SECTION, "parseFloat(0)", 0, parseFloat(0) ); michael@0: new TestCase( SECTION, "parseFloat(-0)", -0, parseFloat(-0) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(1)", 1, parseFloat(1) ); michael@0: new TestCase( SECTION, "parseFloat(-1)", -1, parseFloat(-1) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(2)", 2, parseFloat(2) ); michael@0: new TestCase( SECTION, "parseFloat(-2)", -2, parseFloat(-2) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(3)", 3, parseFloat(3) ); michael@0: new TestCase( SECTION, "parseFloat(-3)", -3, parseFloat(-3) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(4)", 4, parseFloat(4) ); michael@0: new TestCase( SECTION, "parseFloat(-4)", -4, parseFloat(-4) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(5)", 5, parseFloat(5) ); michael@0: new TestCase( SECTION, "parseFloat(-5)", -5, parseFloat(-5) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(6)", 6, parseFloat(6) ); michael@0: new TestCase( SECTION, "parseFloat(-6)", -6, parseFloat(-6) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(7)", 7, parseFloat(7) ); michael@0: new TestCase( SECTION, "parseFloat(-7)", -7, parseFloat(-7) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(8)", 8, parseFloat(8) ); michael@0: new TestCase( SECTION, "parseFloat(-8)", -8, parseFloat(-8) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(9)", 9, parseFloat(9) ); michael@0: new TestCase( SECTION, "parseFloat(-9)", -9, parseFloat(-9) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(3.14159)", 3.14159, parseFloat(3.14159) ); michael@0: new TestCase( SECTION, "parseFloat(-3.14159)", -3.14159, parseFloat(-3.14159) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(3.)", 3, parseFloat(3.) ); michael@0: new TestCase( SECTION, "parseFloat(-3.)", -3, parseFloat(-3.) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(3.e1)", 30, parseFloat(3.e1) ); michael@0: new TestCase( SECTION, "parseFloat(-3.e1)", -30, parseFloat(-3.e1) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(3.e+1)", 30, parseFloat(3.e+1) ); michael@0: new TestCase( SECTION, "parseFloat(-3.e+1)", -30, parseFloat(-3.e+1) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(3.e-1)", .30, parseFloat(3.e-1) ); michael@0: new TestCase( SECTION, "parseFloat(-3.e-1)", -.30, parseFloat(-3.e-1) ); michael@0: michael@0: michael@0: new TestCase( SECTION, "parseFloat(3.E1)", 30, parseFloat(3.E1) ); michael@0: new TestCase( SECTION, "parseFloat(-3.E1)", -30, parseFloat(-3.E1) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(3.E+1)", 30, parseFloat(3.E+1) ); michael@0: new TestCase( SECTION, "parseFloat(-3.E+1)", -30, parseFloat(-3.E+1) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(3.E-1)", .30, parseFloat(3.E-1) ); michael@0: new TestCase( SECTION, "parseFloat(-3.E-1)", -.30, parseFloat(-3.E-1) ); michael@0: michael@0: // StrDecimalLiteral::: .DecimalDigits ExponentPart opt michael@0: michael@0: new TestCase( SECTION, "parseFloat(.00001)", 0.00001, parseFloat(.00001) ); michael@0: new TestCase( SECTION, "parseFloat(-0.0001)", -0.00001, parseFloat(-.00001) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(.01e2)", 1, parseFloat(.01e2) ); michael@0: new TestCase( SECTION, "parseFloat(-.01e2)", -1, parseFloat(-.01e2) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(.01e+2)", 1, parseFloat(.01e+2) ); michael@0: new TestCase( SECTION, "parseFloat(-.01e+2)", -1, parseFloat(-.01e+2) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(.01e-2)", 0.0001, parseFloat(.01e-2) ); michael@0: new TestCase( SECTION, "parseFloat(-.01e-2)", -0.0001, parseFloat(-.01e-2) ); michael@0: michael@0: // StrDecimalLiteral::: DecimalDigits ExponentPart opt michael@0: michael@0: new TestCase( SECTION, "parseFloat(1234e5)", 123400000, parseFloat(1234e5) ); michael@0: new TestCase( SECTION, "parseFloat(-1234e5)", -123400000, parseFloat(-1234e5) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(1234e+5)", 123400000, parseFloat(1234e+5) ); michael@0: new TestCase( SECTION, "parseFloat(-1234e+5)", -123400000, parseFloat(-1234e+5) ); michael@0: michael@0: new TestCase( SECTION, "parseFloat(1234e-5)", 0.01234, parseFloat(1234e-5) ); michael@0: new TestCase( SECTION, "parseFloat(-1234e-5)", -0.01234, parseFloat(-1234e-5) ); michael@0: michael@0: // hex cases should all return 0 (0 is the longest string that satisfies a StringDecimalLiteral) michael@0: michael@0: new TestCase( SECTION, "parseFloat('0x0')", 0, parseFloat("0x0")); michael@0: new TestCase( SECTION, "parseFloat('0x1')", 0, parseFloat("0x1")); michael@0: new TestCase( SECTION, "parseFloat('0x2')", 0, parseFloat("0x2")); michael@0: new TestCase( SECTION, "parseFloat('0x3')", 0, parseFloat("0x3")); michael@0: new TestCase( SECTION, "parseFloat('0x4')", 0, parseFloat("0x4")); michael@0: new TestCase( SECTION, "parseFloat('0x5')", 0, parseFloat("0x5")); michael@0: new TestCase( SECTION, "parseFloat('0x6')", 0, parseFloat("0x6")); michael@0: new TestCase( SECTION, "parseFloat('0x7')", 0, parseFloat("0x7")); michael@0: new TestCase( SECTION, "parseFloat('0x8')", 0, parseFloat("0x8")); michael@0: new TestCase( SECTION, "parseFloat('0x9')", 0, parseFloat("0x9")); michael@0: new TestCase( SECTION, "parseFloat('0xa')", 0, parseFloat("0xa")); michael@0: new TestCase( SECTION, "parseFloat('0xb')", 0, parseFloat("0xb")); michael@0: new TestCase( SECTION, "parseFloat('0xc')", 0, parseFloat("0xc")); michael@0: new TestCase( SECTION, "parseFloat('0xd')", 0, parseFloat("0xd")); michael@0: new TestCase( SECTION, "parseFloat('0xe')", 0, parseFloat("0xe")); michael@0: new TestCase( SECTION, "parseFloat('0xf')", 0, parseFloat("0xf")); michael@0: new TestCase( SECTION, "parseFloat('0xA')", 0, parseFloat("0xA")); michael@0: new TestCase( SECTION, "parseFloat('0xB')", 0, parseFloat("0xB")); michael@0: new TestCase( SECTION, "parseFloat('0xC')", 0, parseFloat("0xC")); michael@0: new TestCase( SECTION, "parseFloat('0xD')", 0, parseFloat("0xD")); michael@0: new TestCase( SECTION, "parseFloat('0xE')", 0, parseFloat("0xE")); michael@0: new TestCase( SECTION, "parseFloat('0xF')", 0, parseFloat("0xF")); michael@0: michael@0: new TestCase( SECTION, "parseFloat('0X0')", 0, parseFloat("0X0")); michael@0: new TestCase( SECTION, "parseFloat('0X1')", 0, parseFloat("0X1")); michael@0: new TestCase( SECTION, "parseFloat('0X2')", 0, parseFloat("0X2")); michael@0: new TestCase( SECTION, "parseFloat('0X3')", 0, parseFloat("0X3")); michael@0: new TestCase( SECTION, "parseFloat('0X4')", 0, parseFloat("0X4")); michael@0: new TestCase( SECTION, "parseFloat('0X5')", 0, parseFloat("0X5")); michael@0: new TestCase( SECTION, "parseFloat('0X6')", 0, parseFloat("0X6")); michael@0: new TestCase( SECTION, "parseFloat('0X7')", 0, parseFloat("0X7")); michael@0: new TestCase( SECTION, "parseFloat('0X8')", 0, parseFloat("0X8")); michael@0: new TestCase( SECTION, "parseFloat('0X9')", 0, parseFloat("0X9")); michael@0: new TestCase( SECTION, "parseFloat('0Xa')", 0, parseFloat("0Xa")); michael@0: new TestCase( SECTION, "parseFloat('0Xb')", 0, parseFloat("0Xb")); michael@0: new TestCase( SECTION, "parseFloat('0Xc')", 0, parseFloat("0Xc")); michael@0: new TestCase( SECTION, "parseFloat('0Xd')", 0, parseFloat("0Xd")); michael@0: new TestCase( SECTION, "parseFloat('0Xe')", 0, parseFloat("0Xe")); michael@0: new TestCase( SECTION, "parseFloat('0Xf')", 0, parseFloat("0Xf")); michael@0: new TestCase( SECTION, "parseFloat('0XA')", 0, parseFloat("0XA")); michael@0: new TestCase( SECTION, "parseFloat('0XB')", 0, parseFloat("0XB")); michael@0: new TestCase( SECTION, "parseFloat('0XC')", 0, parseFloat("0XC")); michael@0: new TestCase( SECTION, "parseFloat('0XD')", 0, parseFloat("0XD")); michael@0: new TestCase( SECTION, "parseFloat('0XE')", 0, parseFloat("0XE")); michael@0: new TestCase( SECTION, "parseFloat('0XF')", 0, parseFloat("0XF")); michael@0: new TestCase( SECTION, "parseFloat(' 0XF ')", 0, parseFloat(" 0XF ")); michael@0: michael@0: // hex literals should still succeed michael@0: michael@0: new TestCase( SECTION, "parseFloat(0x0)", 0, parseFloat(0x0)); michael@0: new TestCase( SECTION, "parseFloat(0x1)", 1, parseFloat(0x1)); michael@0: new TestCase( SECTION, "parseFloat(0x2)", 2, parseFloat(0x2)); michael@0: new TestCase( SECTION, "parseFloat(0x3)", 3, parseFloat(0x3)); michael@0: new TestCase( SECTION, "parseFloat(0x4)", 4, parseFloat(0x4)); michael@0: new TestCase( SECTION, "parseFloat(0x5)", 5, parseFloat(0x5)); michael@0: new TestCase( SECTION, "parseFloat(0x6)", 6, parseFloat(0x6)); michael@0: new TestCase( SECTION, "parseFloat(0x7)", 7, parseFloat(0x7)); michael@0: new TestCase( SECTION, "parseFloat(0x8)", 8, parseFloat(0x8)); michael@0: new TestCase( SECTION, "parseFloat(0x9)", 9, parseFloat(0x9)); michael@0: new TestCase( SECTION, "parseFloat(0xa)", 10, parseFloat(0xa)); michael@0: new TestCase( SECTION, "parseFloat(0xb)", 11, parseFloat(0xb)); michael@0: new TestCase( SECTION, "parseFloat(0xc)", 12, parseFloat(0xc)); michael@0: new TestCase( SECTION, "parseFloat(0xd)", 13, parseFloat(0xd)); michael@0: new TestCase( SECTION, "parseFloat(0xe)", 14, parseFloat(0xe)); michael@0: new TestCase( SECTION, "parseFloat(0xf)", 15, parseFloat(0xf)); michael@0: new TestCase( SECTION, "parseFloat(0xA)", 10, parseFloat(0xA)); michael@0: new TestCase( SECTION, "parseFloat(0xB)", 11, parseFloat(0xB)); michael@0: new TestCase( SECTION, "parseFloat(0xC)", 12, parseFloat(0xC)); michael@0: new TestCase( SECTION, "parseFloat(0xD)", 13, parseFloat(0xD)); michael@0: new TestCase( SECTION, "parseFloat(0xE)", 14, parseFloat(0xE)); michael@0: new TestCase( SECTION, "parseFloat(0xF)", 15, parseFloat(0xF)); michael@0: michael@0: new TestCase( SECTION, "parseFloat(0X0)", 0, parseFloat(0X0)); michael@0: new TestCase( SECTION, "parseFloat(0X1)", 1, parseFloat(0X1)); michael@0: new TestCase( SECTION, "parseFloat(0X2)", 2, parseFloat(0X2)); michael@0: new TestCase( SECTION, "parseFloat(0X3)", 3, parseFloat(0X3)); michael@0: new TestCase( SECTION, "parseFloat(0X4)", 4, parseFloat(0X4)); michael@0: new TestCase( SECTION, "parseFloat(0X5)", 5, parseFloat(0X5)); michael@0: new TestCase( SECTION, "parseFloat(0X6)", 6, parseFloat(0X6)); michael@0: new TestCase( SECTION, "parseFloat(0X7)", 7, parseFloat(0X7)); michael@0: new TestCase( SECTION, "parseFloat(0X8)", 8, parseFloat(0X8)); michael@0: new TestCase( SECTION, "parseFloat(0X9)", 9, parseFloat(0X9)); michael@0: new TestCase( SECTION, "parseFloat(0Xa)", 10, parseFloat(0Xa)); michael@0: new TestCase( SECTION, "parseFloat(0Xb)", 11, parseFloat(0Xb)); michael@0: new TestCase( SECTION, "parseFloat(0Xc)", 12, parseFloat(0Xc)); michael@0: new TestCase( SECTION, "parseFloat(0Xd)", 13, parseFloat(0Xd)); michael@0: new TestCase( SECTION, "parseFloat(0Xe)", 14, parseFloat(0Xe)); michael@0: new TestCase( SECTION, "parseFloat(0Xf)", 15, parseFloat(0Xf)); michael@0: new TestCase( SECTION, "parseFloat(0XA)", 10, parseFloat(0XA)); michael@0: new TestCase( SECTION, "parseFloat(0XB)", 11, parseFloat(0XB)); michael@0: new TestCase( SECTION, "parseFloat(0XC)", 12, parseFloat(0XC)); michael@0: new TestCase( SECTION, "parseFloat(0XD)", 13, parseFloat(0XD)); michael@0: new TestCase( SECTION, "parseFloat(0XE)", 14, parseFloat(0XE)); michael@0: new TestCase( SECTION, "parseFloat(0XF)", 15, parseFloat(0XF)); michael@0: michael@0: michael@0: // A StringNumericLiteral may not use octal notation michael@0: michael@0: new TestCase( SECTION, "parseFloat('00')", 0, parseFloat("00")); michael@0: new TestCase( SECTION, "parseFloat('01')", 1, parseFloat("01")); michael@0: new TestCase( SECTION, "parseFloat('02')", 2, parseFloat("02")); michael@0: new TestCase( SECTION, "parseFloat('03')", 3, parseFloat("03")); michael@0: new TestCase( SECTION, "parseFloat('04')", 4, parseFloat("04")); michael@0: new TestCase( SECTION, "parseFloat('05')", 5, parseFloat("05")); michael@0: new TestCase( SECTION, "parseFloat('06')", 6, parseFloat("06")); michael@0: new TestCase( SECTION, "parseFloat('07')", 7, parseFloat("07")); michael@0: new TestCase( SECTION, "parseFloat('010')", 10, parseFloat("010")); michael@0: new TestCase( SECTION, "parseFloat('011')", 11, parseFloat("011")); michael@0: michael@0: // A StringNumericLIteral may have any number of leading 0 digits michael@0: michael@0: new TestCase( SECTION, "parseFloat('001')", 1, parseFloat("001")); michael@0: new TestCase( SECTION, "parseFloat('0001')", 1, parseFloat("0001")); michael@0: new TestCase( SECTION, "parseFloat(' 0001 ')", 1, parseFloat(" 0001 ")); michael@0: michael@0: // an octal numeric literal should be treated as an octal michael@0: michael@0: new TestCase( SECTION, "parseFloat(00)", 0, parseFloat(00)); michael@0: new TestCase( SECTION, "parseFloat(01)", 1, parseFloat(01)); michael@0: new TestCase( SECTION, "parseFloat(02)", 2, parseFloat(02)); michael@0: new TestCase( SECTION, "parseFloat(03)", 3, parseFloat(03)); michael@0: new TestCase( SECTION, "parseFloat(04)", 4, parseFloat(04)); michael@0: new TestCase( SECTION, "parseFloat(05)", 5, parseFloat(05)); michael@0: new TestCase( SECTION, "parseFloat(06)", 6, parseFloat(06)); michael@0: new TestCase( SECTION, "parseFloat(07)", 7, parseFloat(07)); michael@0: new TestCase( SECTION, "parseFloat(010)", 8, parseFloat(010)); michael@0: new TestCase( SECTION, "parseFloat(011)", 9, parseFloat(011)); michael@0: michael@0: // A StringNumericLIteral may have any number of leading 0 digits michael@0: michael@0: new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001)); michael@0: new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001)); michael@0: michael@0: // make sure it's reflexive michael@0: new TestCase( SECTION, "parseFloat(Math.PI)", Math.PI, parseFloat(Math.PI)); michael@0: new TestCase( SECTION, "parseFloat(Math.LN2)", Math.LN2, parseFloat(Math.LN2)); michael@0: new TestCase( SECTION, "parseFloat(Math.LN10)", Math.LN10, parseFloat(Math.LN10)); michael@0: new TestCase( SECTION, "parseFloat(Math.LOG2E)", Math.LOG2E, parseFloat(Math.LOG2E)); michael@0: new TestCase( SECTION, "parseFloat(Math.LOG10E)", Math.LOG10E, parseFloat(Math.LOG10E)); michael@0: new TestCase( SECTION, "parseFloat(Math.SQRT2)", Math.SQRT2, parseFloat(Math.SQRT2)); michael@0: new TestCase( SECTION, "parseFloat(Math.SQRT1_2)", Math.SQRT1_2, parseFloat(Math.SQRT1_2)); michael@0: michael@0: new TestCase( SECTION, "parseFloat(Math.PI+'')", Math.PI, parseFloat(Math.PI+'')); michael@0: new TestCase( SECTION, "parseFloat(Math.LN2+'')", Math.LN2, parseFloat(Math.LN2+'')); michael@0: new TestCase( SECTION, "parseFloat(Math.LN10+'')", Math.LN10, parseFloat(Math.LN10+'')); michael@0: new TestCase( SECTION, "parseFloat(Math.LOG2E+'')", Math.LOG2E, parseFloat(Math.LOG2E+'')); michael@0: new TestCase( SECTION, "parseFloat(Math.LOG10E+'')", Math.LOG10E, parseFloat(Math.LOG10E+'')); michael@0: new TestCase( SECTION, "parseFloat(Math.SQRT2+'')", Math.SQRT2, parseFloat(Math.SQRT2+'')); michael@0: new TestCase( SECTION, "parseFloat(Math.SQRT1_2+'')", Math.SQRT1_2, parseFloat(Math.SQRT1_2+'')); michael@0: michael@0: test();