js/src/tests/ecma/GlobalObject/15.1.2.2-2.js

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

mercurial