Debian Codegraph @

rhino/testsrc/tests/ecma/GlobalObject/15.1.2.2-2.js

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