]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_5/LexicalConventions/lexical-001.js
42e947d588d37705f5b965e2c278c64decd3d577
2 * The contents of this file are subject to the Netscape Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/NPL/
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is mozilla.org code.
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
19 * Contributor(s): pschwartau@netscape.com
23 *SUMMARY: Testing numeric literals that begin with 0.
24 *This test arose from Bugzilla bug 49233.
25 *The best explanation is from jsscan.c:
27 * "We permit 08 and 09 as decimal numbers, which makes
28 * our behaviour a superset of the ECMA numeric grammar.
29 * We might not always be so permissive, so we warn about it."
31 *Thus an expression 010 will evaluate, as always, as an octal (to 8).
32 *However, 018 will evaluate as a decimal, to 18. Even though the
33 *user began the expression as an octal, he later used a non-octal
34 *digit. We forgive this and assume he intended a decimal. If the
35 *JavaScript "strict" option is set though, we will give a warning.
37 //-------------------------------------------------------------------------------------------------
39 var summary
= 'Testing numeric literals that begin with 0';
40 var statprefix
= 'Testing ';
42 var status
= new Array();
43 var actual
= new Array();
44 var expect
= new Array();
47 status
[0]=showStatus('01')
51 status
[1]=showStatus('07')
55 status
[2]=showStatus('08')
59 status
[3]=showStatus('09')
63 status
[4]=showStatus('010')
67 status
[5]=showStatus('017')
71 status
[6]=showStatus('018')
75 status
[7]=showStatus('019')
79 status
[8]=showStatus('079')
83 status
[9]=showStatus('0079')
87 status
[10]=showStatus('099')
91 status
[11]=showStatus('0099')
95 status
[12]=showStatus('000000000077')
96 actual
[12]=000000000077
99 status
[13]=showStatus('000000000078')
100 actual
[13]=000000000078
103 status
[14]=showStatus('0000000000770000')
104 actual
[14]=0000000000770000
107 status
[15]=showStatus('0000000000780000')
108 actual
[15]=0000000000780000
111 status
[16]=showStatus('0765432198')
112 actual
[16]=0765432198
115 status
[17]=showStatus('00076543219800')
116 actual
[17]=00076543219800
117 expect
[17]=76543219800
119 status
[18]=showStatus('0000001001007')
120 actual
[18]=0000001001007
123 status
[19]=showStatus('0000001001009')
124 actual
[19]=0000001001009
127 status
[20]=showStatus('070')
131 status
[21]=showStatus('080')
137 //-------------------------------------------------------------------------------------------------
139 //-------------------------------------------------------------------------------------------------
142 function showStatus(msg
)
144 return (statprefix
+ quote
+ msg
+ quote
);
151 printBugNumber (bug
);
152 printStatus (summary
);
155 for (i
=0; i
!=status
.length
; i
++)
157 reportCompare (expect
[i
], actual
[i
], status
[i
]);