~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/JavaScriptCore/tests/mozilla/ecma/TypeConversion/9.3.1-3.js

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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/
 
5
 *
 
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.
 
10
 *
 
11
 * The Original Code is Mozilla Communicator client code, released March
 
12
 * 31, 1998.
 
13
 *
 
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
 
17
 * Rights Reserved.
 
18
 *
 
19
 * Contributor(s): 
 
20
 * 
 
21
 */
 
22
/**
 
23
    File Name:          9.3.1-3.js
 
24
    ECMA Section:       9.3  Type Conversion:  ToNumber
 
25
    Description:        rules for converting an argument to a number.
 
26
                        see 9.3.1 for cases for converting strings to numbers.
 
27
                        special cases:
 
28
                        undefined           NaN
 
29
                        Null                NaN
 
30
                        Boolean             1 if true; +0 if false
 
31
                        Number              the argument ( no conversion )
 
32
                        String              see test 9.3.1
 
33
                        Object              see test 9.3-1
 
34
 
 
35
 
 
36
                        Test cases provided by waldemar.
 
37
 
 
38
 
 
39
    Author:             christine@netscape.com
 
40
    Date:               10 june 1998
 
41
 
 
42
*/
 
43
 
 
44
var SECTION = "9.3.1-3";
 
45
var VERSION = "ECMA_1";
 
46
    startTest();
 
47
var BUGNUMBER="129087";
 
48
 
 
49
var TITLE   = "Number To String, String To Number";
 
50
 
 
51
writeHeaderToLog( SECTION + " "+ TITLE);
 
52
 
 
53
var testcases = new Array();
 
54
 
 
55
 
 
56
// test case from http://scopus.mcom.com/bugsplat/show_bug.cgi?id=312954
 
57
var z = 0;
 
58
 
 
59
testcases[tc++] = new TestCase(
 
60
    SECTION,
 
61
    "var z = 0; print(1/-z)",
 
62
    -Infinity,
 
63
    1/-z );
 
64
 
 
65
 
 
66
 
 
67
 
 
68
 
 
69
// test cases from bug http://scopus.mcom.com/bugsplat/show_bug.cgi?id=122882
 
70
 
 
71
 
 
72
 
 
73
testcases[tc++] = new TestCase( SECTION,
 
74
    '- -"0x80000000"',
 
75
    2147483648,
 
76
    - -"0x80000000" );
 
77
 
 
78
testcases[tc++] = new TestCase( SECTION,
 
79
    '- -"0x100000000"',
 
80
    4294967296,
 
81
    - -"0x100000000" );
 
82
 
 
83
testcases[tc++] = new TestCase( SECTION,
 
84
    '- "-0x123456789abcde8"',
 
85
    NaN,
 
86
    - "-0x123456789abcde8" );
 
87
 
 
88
// Convert some large numbers to string
 
89
 
 
90
 
 
91
testcases[tc++] = new TestCase( SECTION,
 
92
                                "1e2000 +''",
 
93
                                "Infinity",
 
94
                                1e2000 +"" );
 
95
 
 
96
testcases[tc++] = new TestCase( SECTION,
 
97
                                "1e2000",
 
98
                                Infinity,
 
99
                                1e2000 );
 
100
 
 
101
testcases[tc++] = new TestCase( SECTION,
 
102
                                "-1e2000 +''",
 
103
                                "-Infinity",
 
104
                                -1e2000 +"" );
 
105
 
 
106
testcases[tc++] = new TestCase( SECTION,
 
107
                                "-\"1e2000\"",
 
108
                                -Infinity,
 
109
                                -"1e2000" );
 
110
 
 
111
testcases[tc++] = new TestCase( SECTION,
 
112
                                "-\"-1e2000\" +''",
 
113
                                "Infinity",
 
114
                                -"-1e2000" +"" );
 
115
 
 
116
testcases[tc++] = new TestCase( SECTION,
 
117
                                "1e-2000",
 
118
                                0,
 
119
                                1e-2000 );
 
120
 
 
121
testcases[tc++] = new TestCase( SECTION,
 
122
                                "1/1e-2000",
 
123
                                Infinity,
 
124
                                1/1e-2000 );
 
125
 
 
126
// convert some strings to large numbers
 
127
 
 
128
testcases[tc++] = new TestCase( SECTION,
 
129
                                "1/-1e-2000",
 
130
                                -Infinity,
 
131
                                1/-1e-2000 );
 
132
 
 
133
testcases[tc++] = new TestCase( SECTION,
 
134
                                "1/\"1e-2000\"",
 
135
                                Infinity,
 
136
                                1/"1e-2000" );
 
137
 
 
138
testcases[tc++] = new TestCase( SECTION,
 
139
                                "1/\"-1e-2000\"",
 
140
                                -Infinity,
 
141
                                1/"-1e-2000" );
 
142
 
 
143
testcases[tc++] = new TestCase( SECTION,
 
144
                                "parseFloat(\"1e2000\")",
 
145
                                Infinity,
 
146
                                parseFloat("1e2000") );
 
147
 
 
148
testcases[tc++] = new TestCase( SECTION,
 
149
                                "parseFloat(\"1e-2000\")",
 
150
                                0,
 
151
                                parseFloat("1e-2000") );
 
152
 
 
153
testcases[tc++] = new TestCase( SECTION,
 
154
                                "1.7976931348623157E+308",
 
155
                                1.7976931348623157e+308,
 
156
                                1.7976931348623157E+308 );
 
157
 
 
158
testcases[tc++] = new TestCase( SECTION,
 
159
                                "1.7976931348623158e+308",
 
160
                                1.7976931348623157e+308,
 
161
                                1.7976931348623158e+308 );
 
162
 
 
163
testcases[tc++] = new TestCase( SECTION,
 
164
                                "1.7976931348623159e+308",
 
165
                                Infinity,
 
166
                                1.7976931348623159e+308 );
 
167
 
 
168
s =
 
169
"17976931348623158079372897140530341507993413271003782693617377898044496829276475094664901797758720709633028641669288791094655554785194040263065748867150582068";
 
170
 
 
171
testcases[tc++] = new TestCase( SECTION,
 
172
                                "s = " + s +"; s +="+
 
173
"\"190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779\""+
 
174
 
 
175
+"; s",
 
176
"17976931348623158079372897140530341507993413271003782693617377898044496829276475094664901797758720709633028641669288791094655554785194040263065748867150582068190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779",
 
177
s +=
 
178
"190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779"
 
179
);
 
180
 
 
181
s1 = s+1;
 
182
 
 
183
testcases[tc++] = new TestCase( SECTION,
 
184
"s1 = s+1; s1",
 
185
"179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497791",
 
186
s1 );
 
187
 
 
188
/***** This answer is preferred but -Infinity is also acceptable here *****/
 
189
 
 
190
testcases[tc++] = new TestCase( SECTION,
 
191
"-s1 == Infinity || s1 == 1.7976931348623157e+308",
 
192
true,
 
193
-s1 == Infinity || s1 == 1.7976931348623157e+308 );
 
194
 
 
195
s2 = s + 2;
 
196
 
 
197
testcases[tc++] = new TestCase( SECTION,
 
198
"s2 = s+2; s2",
 
199
"179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792",
 
200
s2 );
 
201
 
 
202
// ***** This answer is preferred but -1.7976931348623157e+308 is also acceptable here *****
 
203
testcases[tc++] = new TestCase( SECTION,
 
204
"-s2 == -Infinity || -s2 == -1.7976931348623157e+308 ",
 
205
true,
 
206
-s2 == -Infinity || -s2 == -1.7976931348623157e+308 );
 
207
 
 
208
s3 = s+3;
 
209
 
 
210
testcases[tc++] = new TestCase( SECTION,
 
211
"s3 = s+3; s3",
 
212
"179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497793",
 
213
s3 );
 
214
 
 
215
//***** This answer is preferred but -1.7976931348623157e+308 is also acceptable here *****
 
216
 
 
217
testcases[tc++] = new TestCase( SECTION,
 
218
"-s3 == -Infinity || -s3 == -1.7976931348623157e+308",
 
219
true,
 
220
-s3 == -Infinity || -s3 == -1.7976931348623157e+308 );
 
221
 
 
222
 
 
223
//***** This answer is preferred but Infinity is also acceptable here *****
 
224
 
 
225
testcases[tc++] = new TestCase( SECTION,
 
226
"parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity",
 
227
true,
 
228
parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity );
 
229
 
 
230
//***** This answer is preferred but 1.7976931348623157e+308 is also acceptable here *****
 
231
testcases[tc++] = new TestCase( SECTION,
 
232
"parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308",
 
233
true ,
 
234
parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308 );
 
235
 
 
236
//***** This answer is preferred but Infinity is also acceptable here *****
 
237
 
 
238
testcases[tc++] = new TestCase( SECTION,
 
239
"parseInt(s1) == 1.7976931348623157e+308 || parseInt(s1) == Infinity",
 
240
true,
 
241
parseInt(s1) == 1.7976931348623157e+308 || parseInt(s1) == Infinity);
 
242
 
 
243
//***** This answer is preferred but 1.7976931348623157e+308 is also acceptable here *****
 
244
testcases[tc++] = new TestCase( SECTION,
 
245
"parseInt(s2) == Infinity || parseInt(s2) == 1.7976931348623157e+308",
 
246
true,
 
247
parseInt(s2) == Infinity || parseInt(s2) == 1.7976931348623157e+308 );
 
248
 
 
249
testcases[tc++] = new TestCase( SECTION,
 
250
                                "0x12345678",
 
251
                                305419896,
 
252
                                0x12345678 );
 
253
 
 
254
testcases[tc++] = new TestCase( SECTION,
 
255
                                "0x80000000",
 
256
                                2147483648,
 
257
                                0x80000000 );
 
258
 
 
259
testcases[tc++] = new TestCase( SECTION,
 
260
                                "0xffffffff",
 
261
                                4294967295,
 
262
                                0xffffffff );
 
263
 
 
264
testcases[tc++] = new TestCase( SECTION,
 
265
                                "0x100000000",
 
266
                                4294967296,
 
267
                                0x100000000 );
 
268
 
 
269
testcases[tc++] = new TestCase( SECTION,
 
270
                                "077777777777777777",
 
271
                                2251799813685247,
 
272
                                077777777777777777 );
 
273
 
 
274
testcases[tc++] = new TestCase( SECTION,
 
275
                                "077777777777777776",
 
276
                                2251799813685246,
 
277
                                077777777777777776 );
 
278
 
 
279
testcases[tc++] = new TestCase( SECTION,
 
280
                                "0x1fffffffffffff",
 
281
                                9007199254740991,
 
282
                                0x1fffffffffffff );
 
283
 
 
284
testcases[tc++] = new TestCase( SECTION,
 
285
                                "0x20000000000000",
 
286
                                9007199254740992,
 
287
                                0x20000000000000 );
 
288
 
 
289
testcases[tc++] = new TestCase( SECTION,
 
290
                                "0x20123456789abc",
 
291
                                9027215253084860,
 
292
                                0x20123456789abc );
 
293
 
 
294
testcases[tc++] = new TestCase( SECTION,
 
295
                                "0x20123456789abd",
 
296
                                9027215253084860,
 
297
                                0x20123456789abd );
 
298
 
 
299
testcases[tc++] = new TestCase( SECTION,
 
300
                                "0x20123456789abe",
 
301
                                9027215253084862,
 
302
                                0x20123456789abe );
 
303
 
 
304
testcases[tc++] = new TestCase( SECTION,
 
305
                                "0x20123456789abf",
 
306
                                9027215253084864,
 
307
                                0x20123456789abf );
 
308
 
 
309
/***** These test the round-to-nearest-or-even-if-equally-close rule *****/
 
310
 
 
311
testcases[tc++] = new TestCase( SECTION,
 
312
                                "0x1000000000000080",
 
313
                                1152921504606847000,
 
314
                                0x1000000000000080 );
 
315
 
 
316
testcases[tc++] = new TestCase( SECTION,
 
317
                                "0x1000000000000081",
 
318
                                1152921504606847200,
 
319
                                0x1000000000000081 );
 
320
 
 
321
testcases[tc++] = new TestCase( SECTION,
 
322
                                "0x1000000000000100",
 
323
                                1152921504606847200,
 
324
                                0x1000000000000100 );
 
325
testcases[tc++] = new TestCase( SECTION,
 
326
                                "0x100000000000017f",
 
327
                                1152921504606847200,
 
328
                                0x100000000000017f );
 
329
 
 
330
testcases[tc++] = new TestCase( SECTION,
 
331
                                "0x1000000000000180",
 
332
                                1152921504606847500,
 
333
                                0x1000000000000180 );
 
334
 
 
335
testcases[tc++] = new TestCase( SECTION,
 
336
                                "0x1000000000000181",
 
337
                                1152921504606847500,
 
338
                                0x1000000000000181 );
 
339
 
 
340
testcases[tc++] = new TestCase( SECTION,
 
341
                                "0x10000000000001f0",
 
342
                                1152921504606847500,
 
343
                                0x10000000000001f0 );
 
344
 
 
345
testcases[tc++] = new TestCase( SECTION,
 
346
                                "0x1000000000000200",
 
347
                                1152921504606847500,
 
348
                                0x1000000000000200 );
 
349
 
 
350
testcases[tc++] = new TestCase( SECTION,
 
351
                                "0x100000000000027f",
 
352
                                1152921504606847500,
 
353
                                0x100000000000027f );
 
354
 
 
355
testcases[tc++] = new TestCase( SECTION,
 
356
                                "0x1000000000000280",
 
357
                                1152921504606847500,
 
358
                                0x1000000000000280 );
 
359
 
 
360
testcases[tc++] = new TestCase( SECTION,
 
361
                                "0x1000000000000281",
 
362
                                1152921504606847700,
 
363
                                0x1000000000000281 );
 
364
 
 
365
testcases[tc++] = new TestCase( SECTION,
 
366
                                "0x10000000000002ff",
 
367
                                1152921504606847700,
 
368
                                0x10000000000002ff );
 
369
 
 
370
testcases[tc++] = new TestCase( SECTION,
 
371
                                "0x1000000000000300",
 
372
                                1152921504606847700,
 
373
                                0x1000000000000300 );
 
374
 
 
375
testcases[tc++] = new TestCase( SECTION,
 
376
                                "0x10000000000000000",
 
377
                                18446744073709552000,
 
378
                                0x10000000000000000 );
 
379
 
 
380
testcases[tc++] = new TestCase( SECTION,
 
381
"parseInt(\"000000100000000100100011010001010110011110001001101010111100\",2)",
 
382
9027215253084860,
 
383
parseInt("000000100000000100100011010001010110011110001001101010111100",2) );
 
384
 
 
385
testcases[tc++] = new TestCase( SECTION,
 
386
"parseInt(\"000000100000000100100011010001010110011110001001101010111101\",2)",
 
387
9027215253084860,
 
388
parseInt("000000100000000100100011010001010110011110001001101010111101",2) );
 
389
 
 
390
testcases[tc++] = new TestCase( SECTION,
 
391
"parseInt(\"000000100000000100100011010001010110011110001001101010111111\",2)",
 
392
9027215253084864,
 
393
parseInt("000000100000000100100011010001010110011110001001101010111111",2) );
 
394
 
 
395
testcases[tc++] = new TestCase( SECTION,
 
396
"parseInt(\"0000001000000001001000110100010101100111100010011010101111010\",2)",
 
397
18054430506169720,
 
398
parseInt("0000001000000001001000110100010101100111100010011010101111010",2));
 
399
 
 
400
testcases[tc++] = new TestCase( SECTION,
 
401
"parseInt(\"0000001000000001001000110100010101100111100010011010101111011\",2)",
 
402
18054430506169724,
 
403
parseInt("0000001000000001001000110100010101100111100010011010101111011",2) );
 
404
 
 
405
testcases[tc++] = new TestCase( SECTION,
 
406
"parseInt(\"0000001000000001001000110100010101100111100010011010101111100\",2)",
 
407
18054430506169724,
 
408
parseInt("0000001000000001001000110100010101100111100010011010101111100",2));
 
409
 
 
410
testcases[tc++] = new TestCase( SECTION,
 
411
"parseInt(\"0000001000000001001000110100010101100111100010011010101111110\",2)",
 
412
18054430506169728,
 
413
parseInt("0000001000000001001000110100010101100111100010011010101111110",2));
 
414
 
 
415
testcases[tc++] = new TestCase( SECTION,
 
416
                                "parseInt(\"yz\",35)",
 
417
                                34,
 
418
                                parseInt("yz",35) );
 
419
 
 
420
testcases[tc++] = new TestCase( SECTION,
 
421
                                "parseInt(\"yz\",36)",
 
422
                                1259,
 
423
                                parseInt("yz",36) );
 
424
 
 
425
testcases[tc++] = new TestCase( SECTION,
 
426
                                "parseInt(\"yz\",37)",
 
427
                                NaN,
 
428
                                parseInt("yz",37) );
 
429
 
 
430
testcases[tc++] = new TestCase( SECTION,
 
431
                                "parseInt(\"+77\")",
 
432
                                77,
 
433
                                parseInt("+77") );
 
434
 
 
435
testcases[tc++] = new TestCase( SECTION,
 
436
                                "parseInt(\"-77\",9)",
 
437
                                -70,
 
438
                                parseInt("-77",9) );
 
439
 
 
440
testcases[tc++] = new TestCase( SECTION,
 
441
                                "parseInt(\"\\u20001234\\u2000\")",
 
442
                                1234,
 
443
                                parseInt("\u20001234\u2000") );
 
444
 
 
445
testcases[tc++] = new TestCase( SECTION,
 
446
                                "parseInt(\"123456789012345678\")",
 
447
                                123456789012345680,
 
448
                                parseInt("123456789012345678") );
 
449
 
 
450
testcases[tc++] = new TestCase( SECTION,
 
451
                                "parseInt(\"9\",8)",
 
452
                                NaN,
 
453
                                parseInt("9",8) );
 
454
 
 
455
testcases[tc++] = new TestCase( SECTION,
 
456
                                "parseInt(\"1e2\")",
 
457
                                1,
 
458
                                parseInt("1e2") );
 
459
 
 
460
testcases[tc++] = new TestCase( SECTION,
 
461
                                "parseInt(\"1.9999999999999999999\")",
 
462
                                1,
 
463
                                parseInt("1.9999999999999999999") );
 
464
 
 
465
testcases[tc++] = new TestCase( SECTION,
 
466
                                "parseInt(\"0x10\")",
 
467
                                16,
 
468
                                parseInt("0x10") );
 
469
 
 
470
testcases[tc++] = new TestCase( SECTION,
 
471
                                "parseInt(\"0x10\",10)",
 
472
                                0,
 
473
                                parseInt("0x10",10) );
 
474
 
 
475
testcases[tc++] = new TestCase( SECTION,
 
476
                                "parseInt(\"0022\")",
 
477
                                22,
 
478
                                parseInt("0022") );
 
479
 
 
480
testcases[tc++] = new TestCase( SECTION,
 
481
                                "parseInt(\"0022\",10)",
 
482
                                22,
 
483
                                parseInt("0022",10) );
 
484
 
 
485
testcases[tc++] = new TestCase( SECTION,
 
486
                                "parseInt(\"0x1000000000000080\")",
 
487
                                1152921504606847000,
 
488
                                parseInt("0x1000000000000080") );
 
489
 
 
490
testcases[tc++] = new TestCase( SECTION,
 
491
                                "parseInt(\"0x1000000000000081\")",
 
492
                                1152921504606847200,
 
493
                                parseInt("0x1000000000000081") );
 
494
 
 
495
s =
 
496
"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
 
497
 
 
498
testcases[tc++] = new TestCase( SECTION, "s = "+
 
499
"\"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+
 
500
"s",
 
501
"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
 
502
s );
 
503
 
 
504
 
 
505
testcases[tc++] = new TestCase( SECTION, "s +="+
 
506
"\"0000000000000000000000000000000000000\"; s",
 
507
"0xFFFFFFFFFFFFF800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
 
508
s += "0000000000000000000000000000000000000" );
 
509
 
 
510
testcases[tc++] = new TestCase( SECTION, "-s",
 
511
-1.7976931348623157e+308,
 
512
-s );
 
513
 
 
514
s =
 
515
"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
 
516
 
 
517
testcases[tc++] = new TestCase( SECTION, "s ="+
 
518
"\"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+
 
519
"s",
 
520
"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
 
521
s );
 
522
 
 
523
testcases[tc++] = new TestCase( SECTION,
 
524
"s += \"0000000000000000000000000000000000001\"",
 
525
"0xFFFFFFFFFFFFF800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
 
526
s += "0000000000000000000000000000000000001" );
 
527
 
 
528
testcases[tc++] = new TestCase( SECTION,
 
529
"-s",
 
530
-1.7976931348623157e+308,
 
531
-s );
 
532
 
 
533
s =
 
534
"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
 
535
 
 
536
testcases[tc++] = new TestCase( SECTION,
 
537
"s ="+
 
538
"\"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+
 
539
"s",
 
540
"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
 
541
s );
 
542
 
 
543
 
 
544
testcases[tc++] = new TestCase( SECTION,
 
545
"s += \"0000000000000000000000000000000000000\"",
 
546
"0xFFFFFFFFFFFFFC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
 
547
s += "0000000000000000000000000000000000000");
 
548
 
 
549
 
 
550
testcases[tc++] = new TestCase( SECTION,
 
551
"-s",
 
552
-Infinity,
 
553
-s );
 
554
 
 
555
s =
 
556
"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
 
557
 
 
558
testcases[tc++] = new TestCase( SECTION,
 
559
"s = "+
 
560
"\"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";s",
 
561
"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
 
562
s);
 
563
 
 
564
testcases[tc++] = new TestCase( SECTION,
 
565
"s += \"0000000000000000000000000000000000001\"",
 
566
"0xFFFFFFFFFFFFFB00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
 
567
s += "0000000000000000000000000000000000001" );
 
568
 
 
569
testcases[tc++] = new TestCase( SECTION,
 
570
"-s",
 
571
-1.7976931348623157e+308,
 
572
-s );
 
573
 
 
574
testcases[tc++] = new TestCase( SECTION,
 
575
"s += \"0\"",
 
576
"0xFFFFFFFFFFFFFB000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010",
 
577
s += "0" );
 
578
 
 
579
testcases[tc++] = new TestCase( SECTION,
 
580
"-s",
 
581
-Infinity,
 
582
-s );
 
583
 
 
584
testcases[tc++] = new TestCase( SECTION,
 
585
"parseInt(s)",
 
586
Infinity,
 
587
parseInt(s) );
 
588
 
 
589
testcases[tc++] = new TestCase( SECTION,
 
590
"parseInt(s,32)",
 
591
0,
 
592
parseInt(s,32) );
 
593
 
 
594
testcases[tc++] = new TestCase( SECTION,
 
595
"parseInt(s,36)",
 
596
Infinity,
 
597
parseInt(s,36) );
 
598
 
 
599
testcases[tc++] = new TestCase( SECTION,
 
600
                                "-\"\"",
 
601
                                0,
 
602
                                -"" );
 
603
 
 
604
testcases[tc++] = new TestCase( SECTION,
 
605
                                "-\" \"",
 
606
                                0,
 
607
                                -" " );
 
608
 
 
609
testcases[tc++] = new TestCase( SECTION,
 
610
                                "-\"999\"",
 
611
                                -999,
 
612
                                -"999" );
 
613
 
 
614
testcases[tc++] = new TestCase( SECTION,
 
615
                                "-\" 999\"",
 
616
                                -999,
 
617
                                -" 999" );
 
618
 
 
619
testcases[tc++] = new TestCase( SECTION,
 
620
                                "-\"\\t999\"",
 
621
                                -999,
 
622
                                -"\t999" );
 
623
 
 
624
testcases[tc++] = new TestCase( SECTION,
 
625
                                "-\"013  \"",
 
626
                                -13,
 
627
                                -"013  " );
 
628
 
 
629
testcases[tc++] = new TestCase( SECTION,
 
630
                                "-\"999\\t\"",
 
631
                                -999,
 
632
                                -"999\t" );
 
633
 
 
634
testcases[tc++] = new TestCase( SECTION,
 
635
                                "-\"-Infinity\"",
 
636
                                Infinity,
 
637
                                -"-Infinity" );
 
638
 
 
639
testcases[tc++] = new TestCase( SECTION,
 
640
                                "-\"-infinity\"",
 
641
                                NaN,
 
642
                                -"-infinity" );
 
643
 
 
644
 
 
645
testcases[tc++] = new TestCase( SECTION,
 
646
                                "-\"+Infinity\"",
 
647
                                -Infinity,
 
648
                                -"+Infinity" );
 
649
 
 
650
testcases[tc++] = new TestCase( SECTION,
 
651
                                "-\"+Infiniti\"",
 
652
                                NaN,
 
653
                                -"+Infiniti" );
 
654
 
 
655
testcases[tc++] = new TestCase( SECTION,
 
656
                                "- -\"0x80000000\"",
 
657
                                2147483648,
 
658
                                - -"0x80000000" );
 
659
 
 
660
testcases[tc++] = new TestCase( SECTION,
 
661
                                "- -\"0x100000000\"",
 
662
                                4294967296,
 
663
                                - -"0x100000000" );
 
664
 
 
665
testcases[tc++] = new TestCase( SECTION,
 
666
                                "- \"-0x123456789abcde8\"",
 
667
                                NaN,
 
668
                                - "-0x123456789abcde8" );
 
669
 
 
670
// the following two tests are not strictly ECMA 1.0
 
671
 
 
672
testcases[tc++] = new TestCase( SECTION,
 
673
                                "-\"\\u20001234\\u2001\"",
 
674
                                -1234,
 
675
                                -"\u20001234\u2001" );
 
676
 
 
677
testcases[tc++] = new TestCase( SECTION,
 
678
                                "-\"\\u20001234\\0\"",
 
679
                                NaN,
 
680
                                -"\u20001234\0" );
 
681
 
 
682
testcases[tc++] = new TestCase( SECTION,
 
683
                                "-\"0x10\"",
 
684
                                -16,
 
685
                                -"0x10" );
 
686
 
 
687
testcases[tc++] = new TestCase( SECTION,
 
688
                                "-\"+\"",
 
689
                                NaN,
 
690
                                -"+" );
 
691
 
 
692
testcases[tc++] = new TestCase( SECTION,
 
693
                                "-\"-\"",
 
694
                                NaN,
 
695
                                -"-" );
 
696
 
 
697
testcases[tc++] = new TestCase( SECTION,
 
698
                                "-\"-0-\"",
 
699
                                NaN,
 
700
                                -"-0-" );
 
701
 
 
702
testcases[tc++] = new TestCase( SECTION,
 
703
                                "-\"1e-\"",
 
704
                                NaN,
 
705
                                -"1e-" );
 
706
 
 
707
testcases[tc++] = new TestCase( SECTION,
 
708
                                "-\"1e-1\"",
 
709
                                -0.1,
 
710
                                -"1e-1" );
 
711
 
 
712
test();
 
713
 
 
714
function test(){
 
715
    for ( tc=0; tc < testcases.length; tc++ ) {
 
716
        testcases[tc].passed = writeTestCaseResult(
 
717
                            testcases[tc].expect,
 
718
                            testcases[tc].actual,
 
719
                            testcases[tc].description +" = "+
 
720
                            testcases[tc].actual );
 
721
 
 
722
        testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
 
723
    }
 
724
    stopTest();
 
725
    return ( testcases );
 
726
}