1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/GlobalObject/15.1.2.2-2.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,209 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + File Name: 15.1.2.2-1.js 1.12 + ECMA Section: 15.1.2.2 Function properties of the global object 1.13 + parseInt( string, radix ) 1.14 + 1.15 + Description: parseInt test cases written by waldemar, and documented in 1.16 + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123874. 1.17 + 1.18 + Author: christine@netscape.com 1.19 + Date: 28 october 1997 1.20 + 1.21 +*/ 1.22 +var SECTION = "15.1.2.2-2"; 1.23 +var VERSION = "ECMA_1"; 1.24 +var TITLE = "parseInt(string, radix)"; 1.25 +var BUGNUMBER = "none"; 1.26 + 1.27 +startTest(); 1.28 + 1.29 +writeHeaderToLog( SECTION + " "+ TITLE); 1.30 + 1.31 +new TestCase( SECTION, 1.32 + 'parseInt("000000100000000100100011010001010110011110001001101010111100",2)', 1.33 + 9027215253084860, 1.34 + parseInt("000000100000000100100011010001010110011110001001101010111100",2) ); 1.35 + 1.36 +new TestCase( SECTION, 1.37 + 'parseInt("000000100000000100100011010001010110011110001001101010111101",2)', 1.38 + 9027215253084860, 1.39 + parseInt("000000100000000100100011010001010110011110001001101010111101",2)); 1.40 + 1.41 +new TestCase( SECTION, 1.42 + 'parseInt("000000100000000100100011010001010110011110001001101010111111",2)', 1.43 + 9027215253084864, 1.44 + parseInt("000000100000000100100011010001010110011110001001101010111111",2) ); 1.45 + 1.46 +new TestCase( SECTION, 1.47 + 'parseInt("0000001000000001001000110100010101100111100010011010101111010",2)', 1.48 + 18054430506169720, 1.49 + parseInt("0000001000000001001000110100010101100111100010011010101111010",2) ); 1.50 + 1.51 +new TestCase( SECTION, 1.52 + 'parseInt("0000001000000001001000110100010101100111100010011010101111011",2)', 1.53 + 18054430506169724, 1.54 + parseInt("0000001000000001001000110100010101100111100010011010101111011",2)); 1.55 + 1.56 +new TestCase( SECTION, 1.57 + 'parseInt("0000001000000001001000110100010101100111100010011010101111100",2)', 1.58 + 18054430506169724, 1.59 + parseInt("0000001000000001001000110100010101100111100010011010101111100",2) ); 1.60 + 1.61 +new TestCase( SECTION, 1.62 + 'parseInt("0000001000000001001000110100010101100111100010011010101111110",2)', 1.63 + 18054430506169728, 1.64 + parseInt("0000001000000001001000110100010101100111100010011010101111110",2) ); 1.65 + 1.66 +new TestCase( SECTION, 1.67 + 'parseInt("yz",35)', 1.68 + 34, 1.69 + parseInt("yz",35) ); 1.70 + 1.71 +new TestCase( SECTION, 1.72 + 'parseInt("yz",36)', 1.73 + 1259, 1.74 + parseInt("yz",36) ); 1.75 + 1.76 +new TestCase( SECTION, 1.77 + 'parseInt("yz",37)', 1.78 + NaN, 1.79 + parseInt("yz",37) ); 1.80 + 1.81 +new TestCase( SECTION, 1.82 + 'parseInt("+77")', 1.83 + 77, 1.84 + parseInt("+77") ); 1.85 + 1.86 +new TestCase( SECTION, 1.87 + 'parseInt("-77",9)', 1.88 + -70, 1.89 + parseInt("-77",9) ); 1.90 + 1.91 +new TestCase( SECTION, 1.92 + 'parseInt("\u20001234\u2000")', 1.93 + 1234, 1.94 + parseInt("\u20001234\u2000") ); 1.95 + 1.96 +new TestCase( SECTION, 1.97 + 'parseInt("123456789012345678")', 1.98 + 123456789012345680, 1.99 + parseInt("123456789012345678") ); 1.100 + 1.101 +new TestCase( SECTION, 1.102 + 'parseInt("9",8)', 1.103 + NaN, 1.104 + parseInt("9",8) ); 1.105 + 1.106 +new TestCase( SECTION, 1.107 + 'parseInt("1e2")', 1.108 + 1, 1.109 + parseInt("1e2") ); 1.110 + 1.111 +new TestCase( SECTION, 1.112 + 'parseInt("1.9999999999999999999")', 1.113 + 1, 1.114 + parseInt("1.9999999999999999999") ); 1.115 + 1.116 +new TestCase( SECTION, 1.117 + 'parseInt("0x10")', 1.118 + 16, 1.119 + parseInt("0x10") ); 1.120 + 1.121 +new TestCase( SECTION, 1.122 + 'parseInt("0x10",10)', 1.123 + 0, 1.124 + parseInt("0x10",10)); 1.125 + 1.126 +new TestCase( SECTION, 1.127 + 'parseInt("0022")', 1.128 + 22, 1.129 + parseInt("0022")); 1.130 + 1.131 +new TestCase( SECTION, 1.132 + 'parseInt("0022", 8)', 1.133 + 18, 1.134 + parseInt("0022", 8)); 1.135 + 1.136 +new TestCase( SECTION, 1.137 + 'parseInt("0022", 10)', 1.138 + 22, 1.139 + parseInt("0022", 10) ); 1.140 + 1.141 +new TestCase( SECTION, 1.142 + 'parseInt("0x1000000000000080")', 1.143 + 1152921504606847000, 1.144 + parseInt("0x1000000000000080") ); 1.145 + 1.146 +new TestCase( SECTION, 1.147 + 'parseInt("0x1000000000000081")', 1.148 + 1152921504606847200, 1.149 + parseInt("0x1000000000000081") ); 1.150 + 1.151 +s = 1.152 + "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" 1.153 + 1.154 + s += "0000000000000000000000000000000000000"; 1.155 + 1.156 +new TestCase( SECTION, 1.157 + "s = " + s +"; -s", 1.158 + -1.7976931348623157e+308, 1.159 + -s ); 1.160 + 1.161 +s = 1.162 + "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; 1.163 +s += "0000000000000000000000000000000000001"; 1.164 + 1.165 +new TestCase( SECTION, 1.166 + "s = " + s +"; -s", 1.167 + -1.7976931348623157e+308, 1.168 + -s ); 1.169 + 1.170 + 1.171 +s = "0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; 1.172 + 1.173 +s += "0000000000000000000000000000000000000" 1.174 + 1.175 + 1.176 +new TestCase( SECTION, 1.177 + "s = " + s + "; -s", 1.178 + -Infinity, 1.179 + -s ); 1.180 + 1.181 +s = "0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; 1.182 +s += "0000000000000000000000000000000000001"; 1.183 + 1.184 +new TestCase( SECTION, 1.185 + "s = " + s + "; -s", 1.186 + -1.7976931348623157e+308, 1.187 + -s ); 1.188 + 1.189 +s += "0" 1.190 + 1.191 +new TestCase( SECTION, 1.192 + "s = " + s + "; -s", 1.193 + -Infinity, 1.194 + -s ); 1.195 + 1.196 +new TestCase( SECTION, 1.197 + 'parseInt(s)', 1.198 + Infinity, 1.199 + parseInt(s) ); 1.200 + 1.201 +new TestCase( SECTION, 1.202 + 'parseInt(s,32)', 1.203 + 0, 1.204 + parseInt(s,32) ); 1.205 + 1.206 +new TestCase( SECTION, 1.207 + 'parseInt(s,36)', 1.208 + Infinity, 1.209 + parseInt(s,36)); 1.210 + 1.211 +test(); 1.212 +