Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | File Name: 15.1.2.2-1.js |
michael@0 | 9 | ECMA Section: 15.1.2.2 Function properties of the global object |
michael@0 | 10 | parseInt( string, radix ) |
michael@0 | 11 | |
michael@0 | 12 | Description: parseInt test cases written by waldemar, and documented in |
michael@0 | 13 | http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123874. |
michael@0 | 14 | |
michael@0 | 15 | Author: christine@netscape.com |
michael@0 | 16 | Date: 28 october 1997 |
michael@0 | 17 | |
michael@0 | 18 | */ |
michael@0 | 19 | var SECTION = "15.1.2.2-2"; |
michael@0 | 20 | var VERSION = "ECMA_1"; |
michael@0 | 21 | var TITLE = "parseInt(string, radix)"; |
michael@0 | 22 | var BUGNUMBER = "none"; |
michael@0 | 23 | |
michael@0 | 24 | startTest(); |
michael@0 | 25 | |
michael@0 | 26 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 27 | |
michael@0 | 28 | new TestCase( SECTION, |
michael@0 | 29 | 'parseInt("000000100000000100100011010001010110011110001001101010111100",2)', |
michael@0 | 30 | 9027215253084860, |
michael@0 | 31 | parseInt("000000100000000100100011010001010110011110001001101010111100",2) ); |
michael@0 | 32 | |
michael@0 | 33 | new TestCase( SECTION, |
michael@0 | 34 | 'parseInt("000000100000000100100011010001010110011110001001101010111101",2)', |
michael@0 | 35 | 9027215253084860, |
michael@0 | 36 | parseInt("000000100000000100100011010001010110011110001001101010111101",2)); |
michael@0 | 37 | |
michael@0 | 38 | new TestCase( SECTION, |
michael@0 | 39 | 'parseInt("000000100000000100100011010001010110011110001001101010111111",2)', |
michael@0 | 40 | 9027215253084864, |
michael@0 | 41 | parseInt("000000100000000100100011010001010110011110001001101010111111",2) ); |
michael@0 | 42 | |
michael@0 | 43 | new TestCase( SECTION, |
michael@0 | 44 | 'parseInt("0000001000000001001000110100010101100111100010011010101111010",2)', |
michael@0 | 45 | 18054430506169720, |
michael@0 | 46 | parseInt("0000001000000001001000110100010101100111100010011010101111010",2) ); |
michael@0 | 47 | |
michael@0 | 48 | new TestCase( SECTION, |
michael@0 | 49 | 'parseInt("0000001000000001001000110100010101100111100010011010101111011",2)', |
michael@0 | 50 | 18054430506169724, |
michael@0 | 51 | parseInt("0000001000000001001000110100010101100111100010011010101111011",2)); |
michael@0 | 52 | |
michael@0 | 53 | new TestCase( SECTION, |
michael@0 | 54 | 'parseInt("0000001000000001001000110100010101100111100010011010101111100",2)', |
michael@0 | 55 | 18054430506169724, |
michael@0 | 56 | parseInt("0000001000000001001000110100010101100111100010011010101111100",2) ); |
michael@0 | 57 | |
michael@0 | 58 | new TestCase( SECTION, |
michael@0 | 59 | 'parseInt("0000001000000001001000110100010101100111100010011010101111110",2)', |
michael@0 | 60 | 18054430506169728, |
michael@0 | 61 | parseInt("0000001000000001001000110100010101100111100010011010101111110",2) ); |
michael@0 | 62 | |
michael@0 | 63 | new TestCase( SECTION, |
michael@0 | 64 | 'parseInt("yz",35)', |
michael@0 | 65 | 34, |
michael@0 | 66 | parseInt("yz",35) ); |
michael@0 | 67 | |
michael@0 | 68 | new TestCase( SECTION, |
michael@0 | 69 | 'parseInt("yz",36)', |
michael@0 | 70 | 1259, |
michael@0 | 71 | parseInt("yz",36) ); |
michael@0 | 72 | |
michael@0 | 73 | new TestCase( SECTION, |
michael@0 | 74 | 'parseInt("yz",37)', |
michael@0 | 75 | NaN, |
michael@0 | 76 | parseInt("yz",37) ); |
michael@0 | 77 | |
michael@0 | 78 | new TestCase( SECTION, |
michael@0 | 79 | 'parseInt("+77")', |
michael@0 | 80 | 77, |
michael@0 | 81 | parseInt("+77") ); |
michael@0 | 82 | |
michael@0 | 83 | new TestCase( SECTION, |
michael@0 | 84 | 'parseInt("-77",9)', |
michael@0 | 85 | -70, |
michael@0 | 86 | parseInt("-77",9) ); |
michael@0 | 87 | |
michael@0 | 88 | new TestCase( SECTION, |
michael@0 | 89 | 'parseInt("\u20001234\u2000")', |
michael@0 | 90 | 1234, |
michael@0 | 91 | parseInt("\u20001234\u2000") ); |
michael@0 | 92 | |
michael@0 | 93 | new TestCase( SECTION, |
michael@0 | 94 | 'parseInt("123456789012345678")', |
michael@0 | 95 | 123456789012345680, |
michael@0 | 96 | parseInt("123456789012345678") ); |
michael@0 | 97 | |
michael@0 | 98 | new TestCase( SECTION, |
michael@0 | 99 | 'parseInt("9",8)', |
michael@0 | 100 | NaN, |
michael@0 | 101 | parseInt("9",8) ); |
michael@0 | 102 | |
michael@0 | 103 | new TestCase( SECTION, |
michael@0 | 104 | 'parseInt("1e2")', |
michael@0 | 105 | 1, |
michael@0 | 106 | parseInt("1e2") ); |
michael@0 | 107 | |
michael@0 | 108 | new TestCase( SECTION, |
michael@0 | 109 | 'parseInt("1.9999999999999999999")', |
michael@0 | 110 | 1, |
michael@0 | 111 | parseInt("1.9999999999999999999") ); |
michael@0 | 112 | |
michael@0 | 113 | new TestCase( SECTION, |
michael@0 | 114 | 'parseInt("0x10")', |
michael@0 | 115 | 16, |
michael@0 | 116 | parseInt("0x10") ); |
michael@0 | 117 | |
michael@0 | 118 | new TestCase( SECTION, |
michael@0 | 119 | 'parseInt("0x10",10)', |
michael@0 | 120 | 0, |
michael@0 | 121 | parseInt("0x10",10)); |
michael@0 | 122 | |
michael@0 | 123 | new TestCase( SECTION, |
michael@0 | 124 | 'parseInt("0022")', |
michael@0 | 125 | 22, |
michael@0 | 126 | parseInt("0022")); |
michael@0 | 127 | |
michael@0 | 128 | new TestCase( SECTION, |
michael@0 | 129 | 'parseInt("0022", 8)', |
michael@0 | 130 | 18, |
michael@0 | 131 | parseInt("0022", 8)); |
michael@0 | 132 | |
michael@0 | 133 | new TestCase( SECTION, |
michael@0 | 134 | 'parseInt("0022", 10)', |
michael@0 | 135 | 22, |
michael@0 | 136 | parseInt("0022", 10) ); |
michael@0 | 137 | |
michael@0 | 138 | new TestCase( SECTION, |
michael@0 | 139 | 'parseInt("0x1000000000000080")', |
michael@0 | 140 | 1152921504606847000, |
michael@0 | 141 | parseInt("0x1000000000000080") ); |
michael@0 | 142 | |
michael@0 | 143 | new TestCase( SECTION, |
michael@0 | 144 | 'parseInt("0x1000000000000081")', |
michael@0 | 145 | 1152921504606847200, |
michael@0 | 146 | parseInt("0x1000000000000081") ); |
michael@0 | 147 | |
michael@0 | 148 | s = |
michael@0 | 149 | "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" |
michael@0 | 150 | |
michael@0 | 151 | s += "0000000000000000000000000000000000000"; |
michael@0 | 152 | |
michael@0 | 153 | new TestCase( SECTION, |
michael@0 | 154 | "s = " + s +"; -s", |
michael@0 | 155 | -1.7976931348623157e+308, |
michael@0 | 156 | -s ); |
michael@0 | 157 | |
michael@0 | 158 | s = |
michael@0 | 159 | "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; |
michael@0 | 160 | s += "0000000000000000000000000000000000001"; |
michael@0 | 161 | |
michael@0 | 162 | new TestCase( SECTION, |
michael@0 | 163 | "s = " + s +"; -s", |
michael@0 | 164 | -1.7976931348623157e+308, |
michael@0 | 165 | -s ); |
michael@0 | 166 | |
michael@0 | 167 | |
michael@0 | 168 | s = "0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; |
michael@0 | 169 | |
michael@0 | 170 | s += "0000000000000000000000000000000000000" |
michael@0 | 171 | |
michael@0 | 172 | |
michael@0 | 173 | new TestCase( SECTION, |
michael@0 | 174 | "s = " + s + "; -s", |
michael@0 | 175 | -Infinity, |
michael@0 | 176 | -s ); |
michael@0 | 177 | |
michael@0 | 178 | s = "0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; |
michael@0 | 179 | s += "0000000000000000000000000000000000001"; |
michael@0 | 180 | |
michael@0 | 181 | new TestCase( SECTION, |
michael@0 | 182 | "s = " + s + "; -s", |
michael@0 | 183 | -1.7976931348623157e+308, |
michael@0 | 184 | -s ); |
michael@0 | 185 | |
michael@0 | 186 | s += "0" |
michael@0 | 187 | |
michael@0 | 188 | new TestCase( SECTION, |
michael@0 | 189 | "s = " + s + "; -s", |
michael@0 | 190 | -Infinity, |
michael@0 | 191 | -s ); |
michael@0 | 192 | |
michael@0 | 193 | new TestCase( SECTION, |
michael@0 | 194 | 'parseInt(s)', |
michael@0 | 195 | Infinity, |
michael@0 | 196 | parseInt(s) ); |
michael@0 | 197 | |
michael@0 | 198 | new TestCase( SECTION, |
michael@0 | 199 | 'parseInt(s,32)', |
michael@0 | 200 | 0, |
michael@0 | 201 | parseInt(s,32) ); |
michael@0 | 202 | |
michael@0 | 203 | new TestCase( SECTION, |
michael@0 | 204 | 'parseInt(s,36)', |
michael@0 | 205 | Infinity, |
michael@0 | 206 | parseInt(s,36)); |
michael@0 | 207 | |
michael@0 | 208 | test(); |
michael@0 | 209 |