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.2-1.js michael@0: ECMA Section: 15.1.2.2 Function properties of the global object michael@0: parseInt( string, radix ) michael@0: michael@0: Description: parseInt test cases written by waldemar, and documented in michael@0: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123874. michael@0: michael@0: Author: christine@netscape.com michael@0: Date: 28 october 1997 michael@0: michael@0: */ michael@0: var SECTION = "15.1.2.2-2"; michael@0: var VERSION = "ECMA_1"; michael@0: var TITLE = "parseInt(string, radix)"; michael@0: var BUGNUMBER = "none"; michael@0: michael@0: startTest(); michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("000000100000000100100011010001010110011110001001101010111100",2)', michael@0: 9027215253084860, michael@0: parseInt("000000100000000100100011010001010110011110001001101010111100",2) ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("000000100000000100100011010001010110011110001001101010111101",2)', michael@0: 9027215253084860, michael@0: parseInt("000000100000000100100011010001010110011110001001101010111101",2)); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("000000100000000100100011010001010110011110001001101010111111",2)', michael@0: 9027215253084864, michael@0: parseInt("000000100000000100100011010001010110011110001001101010111111",2) ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("0000001000000001001000110100010101100111100010011010101111010",2)', michael@0: 18054430506169720, michael@0: parseInt("0000001000000001001000110100010101100111100010011010101111010",2) ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("0000001000000001001000110100010101100111100010011010101111011",2)', michael@0: 18054430506169724, michael@0: parseInt("0000001000000001001000110100010101100111100010011010101111011",2)); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("0000001000000001001000110100010101100111100010011010101111100",2)', michael@0: 18054430506169724, michael@0: parseInt("0000001000000001001000110100010101100111100010011010101111100",2) ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("0000001000000001001000110100010101100111100010011010101111110",2)', michael@0: 18054430506169728, michael@0: parseInt("0000001000000001001000110100010101100111100010011010101111110",2) ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("yz",35)', michael@0: 34, michael@0: parseInt("yz",35) ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("yz",36)', michael@0: 1259, michael@0: parseInt("yz",36) ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("yz",37)', michael@0: NaN, michael@0: parseInt("yz",37) ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("+77")', michael@0: 77, michael@0: parseInt("+77") ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("-77",9)', michael@0: -70, michael@0: parseInt("-77",9) ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("\u20001234\u2000")', michael@0: 1234, michael@0: parseInt("\u20001234\u2000") ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("123456789012345678")', michael@0: 123456789012345680, michael@0: parseInt("123456789012345678") ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("9",8)', michael@0: NaN, michael@0: parseInt("9",8) ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("1e2")', michael@0: 1, michael@0: parseInt("1e2") ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("1.9999999999999999999")', michael@0: 1, michael@0: parseInt("1.9999999999999999999") ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("0x10")', michael@0: 16, michael@0: parseInt("0x10") ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("0x10",10)', michael@0: 0, michael@0: parseInt("0x10",10)); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("0022")', michael@0: 22, michael@0: parseInt("0022")); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("0022", 8)', michael@0: 18, michael@0: parseInt("0022", 8)); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("0022", 10)', michael@0: 22, michael@0: parseInt("0022", 10) ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("0x1000000000000080")', michael@0: 1152921504606847000, michael@0: parseInt("0x1000000000000080") ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt("0x1000000000000081")', michael@0: 1152921504606847200, michael@0: parseInt("0x1000000000000081") ); michael@0: michael@0: s = michael@0: "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" michael@0: michael@0: s += "0000000000000000000000000000000000000"; michael@0: michael@0: new TestCase( SECTION, michael@0: "s = " + s +"; -s", michael@0: -1.7976931348623157e+308, michael@0: -s ); michael@0: michael@0: s = michael@0: "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; michael@0: s += "0000000000000000000000000000000000001"; michael@0: michael@0: new TestCase( SECTION, michael@0: "s = " + s +"; -s", michael@0: -1.7976931348623157e+308, michael@0: -s ); michael@0: michael@0: michael@0: s = "0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; michael@0: michael@0: s += "0000000000000000000000000000000000000" michael@0: michael@0: michael@0: new TestCase( SECTION, michael@0: "s = " + s + "; -s", michael@0: -Infinity, michael@0: -s ); michael@0: michael@0: s = "0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; michael@0: s += "0000000000000000000000000000000000001"; michael@0: michael@0: new TestCase( SECTION, michael@0: "s = " + s + "; -s", michael@0: -1.7976931348623157e+308, michael@0: -s ); michael@0: michael@0: s += "0" michael@0: michael@0: new TestCase( SECTION, michael@0: "s = " + s + "; -s", michael@0: -Infinity, michael@0: -s ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt(s)', michael@0: Infinity, michael@0: parseInt(s) ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt(s,32)', michael@0: 0, michael@0: parseInt(s,32) ); michael@0: michael@0: new TestCase( SECTION, michael@0: 'parseInt(s,36)', michael@0: Infinity, michael@0: parseInt(s,36)); michael@0: michael@0: test(); michael@0: