]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/LexicalConventions/7.7.3.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
24 ECMA Section: 7.7.3 Numeric Literals
26 Description: A numeric literal stands for a value of the Number type
27 This value is determined in two steps: first a
28 mathematical value (MV) is derived from the literal;
29 second, this mathematical value is rounded, ideally
30 using IEEE 754 round-to-nearest mode, to a reprentable
31 value of of the number type.
33 Author: christine@netscape.com
34 Date: 16 september 1997
36 var SECTION
= "7.7.3";
37 var VERSION
= "ECMA_1";
39 var TITLE
= "Numeric Literals";
41 writeHeaderToLog( SECTION
+ " "+ TITLE
);
43 var testcases
= getTestCases();
47 function getTestCases() {
48 var array
= new Array();
51 array
[item
++] = new TestCase( SECTION
, "0", 0, 0 );
52 array
[item
++] = new TestCase( SECTION
, "1", 1, 1 );
53 array
[item
++] = new TestCase( SECTION
, "2", 2, 2 );
54 array
[item
++] = new TestCase( SECTION
, "3", 3, 3 );
55 array
[item
++] = new TestCase( SECTION
, "4", 4, 4 );
56 array
[item
++] = new TestCase( SECTION
, "5", 5, 5 );
57 array
[item
++] = new TestCase( SECTION
, "6", 6, 6 );
58 array
[item
++] = new TestCase( SECTION
, "7", 7, 7 );
59 array
[item
++] = new TestCase( SECTION
, "8", 8, 8 );
60 array
[item
++] = new TestCase( SECTION
, "9", 9, 9 );
62 array
[item
++] = new TestCase( SECTION
, "0.", 0, 0. );
63 array
[item
++] = new TestCase( SECTION
, "1.", 1, 1. );
64 array
[item
++] = new TestCase( SECTION
, "2.", 2, 2. );
65 array
[item
++] = new TestCase( SECTION
, "3.", 3, 3. );
66 array
[item
++] = new TestCase( SECTION
, "4.", 4, 4. );
68 array
[item
++] = new TestCase( SECTION
, "0.e0", 0, 0.e0
);
69 array
[item
++] = new TestCase( SECTION
, "1.e1", 10, 1.e1
);
70 array
[item
++] = new TestCase( SECTION
, "2.e2", 200, 2.e2
);
71 array
[item
++] = new TestCase( SECTION
, "3.e3", 3000, 3.e3
);
72 array
[item
++] = new TestCase( SECTION
, "4.e4", 40000, 4.e4
);
74 array
[item
++] = new TestCase( SECTION
, "0.1e0", .1, 0.1e0
);
75 array
[item
++] = new TestCase( SECTION
, "1.1e1", 11, 1.1e1
);
76 array
[item
++] = new TestCase( SECTION
, "2.2e2", 220, 2.2e2
);
77 array
[item
++] = new TestCase( SECTION
, "3.3e3", 3300, 3.3e3
);
78 array
[item
++] = new TestCase( SECTION
, "4.4e4", 44000, 4.4e4
);
80 array
[item
++] = new TestCase( SECTION
, ".1e0", .1, .1e0
);
81 array
[item
++] = new TestCase( SECTION
, ".1e1", 1, .1e1
);
82 array
[item
++] = new TestCase( SECTION
, ".2e2", 20, .2e2
);
83 array
[item
++] = new TestCase( SECTION
, ".3e3", 300, .3e3
);
84 array
[item
++] = new TestCase( SECTION
, ".4e4", 4000, .4e4
);
86 array
[item
++] = new TestCase( SECTION
, "0e0", 0, 0e0
);
87 array
[item
++] = new TestCase( SECTION
, "1e1", 10, 1e1
);
88 array
[item
++] = new TestCase( SECTION
, "2e2", 200, 2e2
);
89 array
[item
++] = new TestCase( SECTION
, "3e3", 3000, 3e3
);
90 array
[item
++] = new TestCase( SECTION
, "4e4", 40000, 4e4
);
92 array
[item
++] = new TestCase( SECTION
, "0e0", 0, 0e0
);
93 array
[item
++] = new TestCase( SECTION
, "1e1", 10, 1e1
);
94 array
[item
++] = new TestCase( SECTION
, "2e2", 200, 2e2
);
95 array
[item
++] = new TestCase( SECTION
, "3e3", 3000, 3e3
);
96 array
[item
++] = new TestCase( SECTION
, "4e4", 40000, 4e4
);
98 array
[item
++] = new TestCase( SECTION
, "0E0", 0, 0E0
);
99 array
[item
++] = new TestCase( SECTION
, "1E1", 10, 1E1
);
100 array
[item
++] = new TestCase( SECTION
, "2E2", 200, 2E2
);
101 array
[item
++] = new TestCase( SECTION
, "3E3", 3000, 3E3
);
102 array
[item
++] = new TestCase( SECTION
, "4E4", 40000, 4E4
);
104 array
[item
++] = new TestCase( SECTION
, "1.e-1", 0.1, 1.e
-1 );
105 array
[item
++] = new TestCase( SECTION
, "2.e-2", 0.02, 2.e
-2 );
106 array
[item
++] = new TestCase( SECTION
, "3.e-3", 0.003, 3.e
-3 );
107 array
[item
++] = new TestCase( SECTION
, "4.e-4", 0.0004, 4.e
-4 );
109 array
[item
++] = new TestCase( SECTION
, "0.1e-0", .1, 0.1e-0 );
110 array
[item
++] = new TestCase( SECTION
, "1.1e-1", 0.11, 1.1e-1 );
111 array
[item
++] = new TestCase( SECTION
, "2.2e-2", .022, 2.2e-2 );
112 array
[item
++] = new TestCase( SECTION
, "3.3e-3", .0033, 3.3e-3 );
113 array
[item
++] = new TestCase( SECTION
, "4.4e-4", .00044, 4.4e-4 );
115 array
[item
++] = new TestCase( SECTION
, ".1e-0", .1, .1e-0 );
116 array
[item
++] = new TestCase( SECTION
, ".1e-1", .01, .1e-1 );
117 array
[item
++] = new TestCase( SECTION
, ".2e-2", .002, .2e-2 );
118 array
[item
++] = new TestCase( SECTION
, ".3e-3", .0003, .3e-3 );
119 array
[item
++] = new TestCase( SECTION
, ".4e-4", .00004, .4e-4 );
121 array
[item
++] = new TestCase( SECTION
, "1.e+1", 10, 1.e
+1 );
122 array
[item
++] = new TestCase( SECTION
, "2.e+2", 200, 2.e
+2 );
123 array
[item
++] = new TestCase( SECTION
, "3.e+3", 3000, 3.e
+3 );
124 array
[item
++] = new TestCase( SECTION
, "4.e+4", 40000, 4.e
+4 );
126 array
[item
++] = new TestCase( SECTION
, "0.1e+0", .1, 0.1e+0 );
127 array
[item
++] = new TestCase( SECTION
, "1.1e+1", 11, 1.1e+1 );
128 array
[item
++] = new TestCase( SECTION
, "2.2e+2", 220, 2.2e+2 );
129 array
[item
++] = new TestCase( SECTION
, "3.3e+3", 3300, 3.3e+3 );
130 array
[item
++] = new TestCase( SECTION
, "4.4e+4", 44000, 4.4e+4 );
132 array
[item
++] = new TestCase( SECTION
, ".1e+0", .1, .1e+0 );
133 array
[item
++] = new TestCase( SECTION
, ".1e+1", 1, .1e+1 );
134 array
[item
++] = new TestCase( SECTION
, ".2e+2", 20, .2e+2 );
135 array
[item
++] = new TestCase( SECTION
, ".3e+3", 300, .3e+3 );
136 array
[item
++] = new TestCase( SECTION
, ".4e+4", 4000, .4e+4 );
138 array
[item
++] = new TestCase( SECTION
, "0x0", 0, 0x0 );
139 array
[item
++] = new TestCase( SECTION
, "0x1", 1, 0x1 );
140 array
[item
++] = new TestCase( SECTION
, "0x2", 2, 0x2 );
141 array
[item
++] = new TestCase( SECTION
, "0x3", 3, 0x3 );
142 array
[item
++] = new TestCase( SECTION
, "0x4", 4, 0x4 );
143 array
[item
++] = new TestCase( SECTION
, "0x5", 5, 0x5 );
144 array
[item
++] = new TestCase( SECTION
, "0x6", 6, 0x6 );
145 array
[item
++] = new TestCase( SECTION
, "0x7", 7, 0x7 );
146 array
[item
++] = new TestCase( SECTION
, "0x8", 8, 0x8 );
147 array
[item
++] = new TestCase( SECTION
, "0x9", 9, 0x9 );
148 array
[item
++] = new TestCase( SECTION
, "0xa", 10, 0xa );
149 array
[item
++] = new TestCase( SECTION
, "0xb", 11, 0xb );
150 array
[item
++] = new TestCase( SECTION
, "0xc", 12, 0xc );
151 array
[item
++] = new TestCase( SECTION
, "0xd", 13, 0xd );
152 array
[item
++] = new TestCase( SECTION
, "0xe", 14, 0xe );
153 array
[item
++] = new TestCase( SECTION
, "0xf", 15, 0xf );
155 array
[item
++] = new TestCase( SECTION
, "0X0", 0, 0X0
);
156 array
[item
++] = new TestCase( SECTION
, "0X1", 1, 0X1
);
157 array
[item
++] = new TestCase( SECTION
, "0X2", 2, 0X2
);
158 array
[item
++] = new TestCase( SECTION
, "0X3", 3, 0X3
);
159 array
[item
++] = new TestCase( SECTION
, "0X4", 4, 0X4
);
160 array
[item
++] = new TestCase( SECTION
, "0X5", 5, 0X5
);
161 array
[item
++] = new TestCase( SECTION
, "0X6", 6, 0X6
);
162 array
[item
++] = new TestCase( SECTION
, "0X7", 7, 0X7
);
163 array
[item
++] = new TestCase( SECTION
, "0X8", 8, 0X8
);
164 array
[item
++] = new TestCase( SECTION
, "0X9", 9, 0X9
);
165 array
[item
++] = new TestCase( SECTION
, "0Xa", 10, 0Xa
);
166 array
[item
++] = new TestCase( SECTION
, "0Xb", 11, 0Xb
);
167 array
[item
++] = new TestCase( SECTION
, "0Xc", 12, 0Xc
);
168 array
[item
++] = new TestCase( SECTION
, "0Xd", 13, 0Xd
);
169 array
[item
++] = new TestCase( SECTION
, "0Xe", 14, 0Xe
);
170 array
[item
++] = new TestCase( SECTION
, "0Xf", 15, 0Xf
);
172 array
[item
++] = new TestCase( SECTION
, "0x0", 0, 0x0 );
173 array
[item
++] = new TestCase( SECTION
, "0x1", 1, 0x1 );
174 array
[item
++] = new TestCase( SECTION
, "0x2", 2, 0x2 );
175 array
[item
++] = new TestCase( SECTION
, "0x3", 3, 0x3 );
176 array
[item
++] = new TestCase( SECTION
, "0x4", 4, 0x4 );
177 array
[item
++] = new TestCase( SECTION
, "0x5", 5, 0x5 );
178 array
[item
++] = new TestCase( SECTION
, "0x6", 6, 0x6 );
179 array
[item
++] = new TestCase( SECTION
, "0x7", 7, 0x7 );
180 array
[item
++] = new TestCase( SECTION
, "0x8", 8, 0x8 );
181 array
[item
++] = new TestCase( SECTION
, "0x9", 9, 0x9 );
182 array
[item
++] = new TestCase( SECTION
, "0xA", 10, 0xA );
183 array
[item
++] = new TestCase( SECTION
, "0xB", 11, 0xB );
184 array
[item
++] = new TestCase( SECTION
, "0xC", 12, 0xC );
185 array
[item
++] = new TestCase( SECTION
, "0xD", 13, 0xD );
186 array
[item
++] = new TestCase( SECTION
, "0xE", 14, 0xE );
187 array
[item
++] = new TestCase( SECTION
, "0xF", 15, 0xF );
189 array
[item
++] = new TestCase( SECTION
, "0X0", 0, 0X0
);
190 array
[item
++] = new TestCase( SECTION
, "0X1", 1, 0X1
);
191 array
[item
++] = new TestCase( SECTION
, "0X2", 2, 0X2
);
192 array
[item
++] = new TestCase( SECTION
, "0X3", 3, 0X3
);
193 array
[item
++] = new TestCase( SECTION
, "0X4", 4, 0X4
);
194 array
[item
++] = new TestCase( SECTION
, "0X5", 5, 0X5
);
195 array
[item
++] = new TestCase( SECTION
, "0X6", 6, 0X6
);
196 array
[item
++] = new TestCase( SECTION
, "0X7", 7, 0X7
);
197 array
[item
++] = new TestCase( SECTION
, "0X8", 8, 0X8
);
198 array
[item
++] = new TestCase( SECTION
, "0X9", 9, 0X9
);
199 array
[item
++] = new TestCase( SECTION
, "0XA", 10, 0XA
);
200 array
[item
++] = new TestCase( SECTION
, "0XB", 11, 0XB
);
201 array
[item
++] = new TestCase( SECTION
, "0XC", 12, 0XC
);
202 array
[item
++] = new TestCase( SECTION
, "0XD", 13, 0XD
);
203 array
[item
++] = new TestCase( SECTION
, "0XE", 14, 0XE
);
204 array
[item
++] = new TestCase( SECTION
, "0XF", 15, 0XF
);
207 array
[item
++] = new TestCase( SECTION
, "00", 0, 00 );
208 array
[item
++] = new TestCase( SECTION
, "01", 1, 01 );
209 array
[item
++] = new TestCase( SECTION
, "02", 2, 02 );
210 array
[item
++] = new TestCase( SECTION
, "03", 3, 03 );
211 array
[item
++] = new TestCase( SECTION
, "04", 4, 04 );
212 array
[item
++] = new TestCase( SECTION
, "05", 5, 05 );
213 array
[item
++] = new TestCase( SECTION
, "06", 6, 06 );
214 array
[item
++] = new TestCase( SECTION
, "07", 7, 07 );
216 array
[item
++] = new TestCase( SECTION
, "000", 0, 000 );
217 array
[item
++] = new TestCase( SECTION
, "011", 9, 011 );
218 array
[item
++] = new TestCase( SECTION
, "022", 18, 022 );
219 array
[item
++] = new TestCase( SECTION
, "033", 27, 033 );
220 array
[item
++] = new TestCase( SECTION
, "044", 36, 044 );
221 array
[item
++] = new TestCase( SECTION
, "055", 45, 055 );
222 array
[item
++] = new TestCase( SECTION
, "066", 54, 066 );
223 array
[item
++] = new TestCase( SECTION
, "077", 63, 077 );
225 array
[item
++] = new TestCase( SECTION
, "0.00000000001", 0.00000000001, 0.00000000001 );
226 array
[item
++] = new TestCase( SECTION
, "0.00000000001e-2", 0.0000000000001, 0.00000000001e-2 );
229 array
[item
++] = new TestCase( SECTION
,
230 "123456789012345671.9999",
231 "123456789012345660",
232 123456789012345671.9999 +"");
233 array
[item
++] = new TestCase( SECTION
,
234 "123456789012345672",
235 "123456789012345660",
236 123456789012345672 +"");
238 array
[item
++] = new TestCase( SECTION
,
239 "123456789012345672.000000000000000000000000000",
240 "123456789012345660",
241 123456789012345672.000000000000000000000000000 +"");
243 array
[item
++] = new TestCase( SECTION
,
244 "123456789012345672.01",
245 "123456789012345680",
246 123456789012345672.01 +"");
248 array
[item
++] = new TestCase( SECTION
,
249 "123456789012345672.000000000000000000000000001+'' == 123456789012345680 || 123456789012345660",
251 ( 123456789012345672.00000000000000000000000000 +"" == 1234567890 * 100000000 + 12345680 )
253 ( 123456789012345672.00000000000000000000000000 +"" == 1234567890 * 100000000 + 12345660) );
255 array
[item
++] = new TestCase( SECTION
,
256 "123456789012345673",
257 "123456789012345680",
258 123456789012345673 +"" );
260 array
[item
++] = new TestCase( SECTION
,
261 "-123456789012345671.9999",
262 "-123456789012345660",
263 -123456789012345671.9999 +"" );
265 array
[item
++] = new TestCase( SECTION
,
266 "-123456789012345672",
267 "-123456789012345660",
268 -123456789012345672+"");
270 array
[item
++] = new TestCase( SECTION
,
271 "-123456789012345672.000000000000000000000000000",
272 "-123456789012345660",
273 -123456789012345672.000000000000000000000000000 +"");
275 array
[item
++] = new TestCase( SECTION
,
276 "-123456789012345672.01",
277 "-123456789012345680",
278 -123456789012345672.01 +"" );
280 array
[item
++] = new TestCase( SECTION
,
281 "-123456789012345672.000000000000000000000000001 == -123456789012345680 or -123456789012345660",
283 (-123456789012345672.000000000000000000000000001 +"" == -1234567890 * 100000000 -12345680)
285 (-123456789012345672.000000000000000000000000001 +"" == -1234567890 * 100000000 -12345660));
287 array
[item
++] = new TestCase( SECTION
,
289 "-123456789012345680",
290 -123456789012345673 +"");
292 array
[item
++] = new TestCase( SECTION
,
293 "12345678901234567890",
294 "12345678901234567000",
295 12345678901234567890 +"" );
299 array[item++] = new TestCase( SECTION, "12345678901234567", "12345678901234567", 12345678901234567+"" );
300 array[item++] = new TestCase( SECTION, "123456789012345678", "123456789012345678", 123456789012345678+"" );
301 array[item++] = new TestCase( SECTION, "1234567890123456789", "1234567890123456789", 1234567890123456789+"" );
302 array[item++] = new TestCase( SECTION, "12345678901234567890", "12345678901234567890", 12345678901234567890+"" );
303 array[item++] = new TestCase( SECTION, "123456789012345678900", "123456789012345678900", 123456789012345678900+"" );
304 array[item++] = new TestCase( SECTION, "1234567890123456789000", "1234567890123456789000", 1234567890123456789000+"" );
306 array
[item
++] = new TestCase( SECTION
, "0x1", 1, 0x1 );
307 array
[item
++] = new TestCase( SECTION
, "0x10", 16, 0x10 );
308 array
[item
++] = new TestCase( SECTION
, "0x100", 256, 0x100 );
309 array
[item
++] = new TestCase( SECTION
, "0x1000", 4096, 0x1000 );
310 array
[item
++] = new TestCase( SECTION
, "0x10000", 65536, 0x10000 );
311 array
[item
++] = new TestCase( SECTION
, "0x100000", 1048576, 0x100000 );
312 array
[item
++] = new TestCase( SECTION
, "0x1000000", 16777216, 0x1000000 );
313 array
[item
++] = new TestCase( SECTION
, "0x10000000", 268435456, 0x10000000 );
315 array[item++] = new TestCase( SECTION, "0x100000000", 4294967296, 0x100000000 );
316 array[item++] = new TestCase( SECTION, "0x1000000000", 68719476736, 0x1000000000 );
317 array[item++] = new TestCase( SECTION, "0x10000000000", 1099511627776, 0x10000000000 );
323 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
324 testcases
[tc
].actual
= testcases
[tc
].actual
;
326 testcases
[tc
].passed
= writeTestCaseResult(
327 testcases
[tc
].expect
,
328 testcases
[tc
].actual
,
329 testcases
[tc
].description
+" = "+ testcases
[tc
].actual
);
331 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
336 return ( testcases
);