]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/mozilla/js1_5/LexicalConventions/lexical-001.js
JavaScriptCore-554.1.tar.gz
[apple/javascriptcore.git] / tests / mozilla / js1_5 / LexicalConventions / lexical-001.js
CommitLineData
b37bf2e1
A
1/*
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/
6*
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.
11*
12* The Original Code is mozilla.org code.
13*
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
17* Rights Reserved.
18*
19* Contributor(s): pschwartau@netscape.com
20* 26 November 2000
21*
22*
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:
26*
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."
30*
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.
36*/
37//-------------------------------------------------------------------------------------------------
38var bug = '49233';
39var summary = 'Testing numeric literals that begin with 0';
40var statprefix = 'Testing ';
41var quote = "'";
42var status = new Array();
43var actual = new Array();
44var expect = new Array();
45
46
47status[0]=showStatus('01')
48actual[0]=01
49expect[0]=1
50
51status[1]=showStatus('07')
52actual[1]=07
53expect[1]=7
54
55status[2]=showStatus('08')
56actual[2]=08
57expect[2]=8
58
59status[3]=showStatus('09')
60actual[3]=09
61expect[3]=9
62
63status[4]=showStatus('010')
64actual[4]=010
65expect[4]=8
66
67status[5]=showStatus('017')
68actual[5]=017
69expect[5]=15
70
71status[6]=showStatus('018')
72actual[6]=018
73expect[6]=18
74
75status[7]=showStatus('019')
76actual[7]=019
77expect[7]=19
78
79status[8]=showStatus('079')
80actual[8]=079
81expect[8]=79
82
83status[9]=showStatus('0079')
84actual[9]=0079
85expect[9]=79
86
87status[10]=showStatus('099')
88actual[10]=099
89expect[10]=99
90
91status[11]=showStatus('0099')
92actual[11]=0099
93expect[11]=99
94
95status[12]=showStatus('000000000077')
96actual[12]=000000000077
97expect[12]=63
98
99status[13]=showStatus('000000000078')
100actual[13]=000000000078
101expect[13]=78
102
103status[14]=showStatus('0000000000770000')
104actual[14]=0000000000770000
105expect[14]=258048
106
107status[15]=showStatus('0000000000780000')
108actual[15]=0000000000780000
109expect[15]=780000
110
111status[16]=showStatus('0765432198')
112actual[16]=0765432198
113expect[16]=765432198
114
115status[17]=showStatus('00076543219800')
116actual[17]=00076543219800
117expect[17]=76543219800
118
119status[18]=showStatus('0000001001007')
120actual[18]=0000001001007
121expect[18]=262663
122
123status[19]=showStatus('0000001001009')
124actual[19]=0000001001009
125expect[19]=1001009
126
127status[20]=showStatus('070')
128actual[20]=070
129expect[20]=56
130
131status[21]=showStatus('080')
132actual[21]=080
133expect[21]=80
134
135
136
137//-------------------------------------------------------------------------------------------------
138test();
139//-------------------------------------------------------------------------------------------------
140
141
142function showStatus(msg)
143{
144 return (statprefix + quote + msg + quote);
145}
146
147
148function test()
149{
150 enterFunc ('test');
151 printBugNumber (bug);
152 printStatus (summary);
153
154
155 for (i=0; i !=status.length; i++)
156 {
157 reportCompare (expect[i], actual[i], status[i]);
158 }
159
160 exitFunc ('test');
161}