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