]>
Commit | Line | Data |
---|---|---|
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 | //------------------------------------------------------------------------------------------------- | |
38 | var bug = '49233'; | |
39 | var summary = 'Testing numeric literals that begin with 0'; | |
40 | var statprefix = 'Testing '; | |
41 | var quote = "'"; | |
42 | var status = new Array(); | |
43 | var actual = new Array(); | |
44 | var expect = new Array(); | |
45 | ||
46 | ||
47 | status[0]=showStatus('01') | |
48 | actual[0]=01 | |
49 | expect[0]=1 | |
50 | ||
51 | status[1]=showStatus('07') | |
52 | actual[1]=07 | |
53 | expect[1]=7 | |
54 | ||
55 | status[2]=showStatus('08') | |
56 | actual[2]=08 | |
57 | expect[2]=8 | |
58 | ||
59 | status[3]=showStatus('09') | |
60 | actual[3]=09 | |
61 | expect[3]=9 | |
62 | ||
63 | status[4]=showStatus('010') | |
64 | actual[4]=010 | |
65 | expect[4]=8 | |
66 | ||
67 | status[5]=showStatus('017') | |
68 | actual[5]=017 | |
69 | expect[5]=15 | |
70 | ||
71 | status[6]=showStatus('018') | |
72 | actual[6]=018 | |
73 | expect[6]=18 | |
74 | ||
75 | status[7]=showStatus('019') | |
76 | actual[7]=019 | |
77 | expect[7]=19 | |
78 | ||
79 | status[8]=showStatus('079') | |
80 | actual[8]=079 | |
81 | expect[8]=79 | |
82 | ||
83 | status[9]=showStatus('0079') | |
84 | actual[9]=0079 | |
85 | expect[9]=79 | |
86 | ||
87 | status[10]=showStatus('099') | |
88 | actual[10]=099 | |
89 | expect[10]=99 | |
90 | ||
91 | status[11]=showStatus('0099') | |
92 | actual[11]=0099 | |
93 | expect[11]=99 | |
94 | ||
95 | status[12]=showStatus('000000000077') | |
96 | actual[12]=000000000077 | |
97 | expect[12]=63 | |
98 | ||
99 | status[13]=showStatus('000000000078') | |
100 | actual[13]=000000000078 | |
101 | expect[13]=78 | |
102 | ||
103 | status[14]=showStatus('0000000000770000') | |
104 | actual[14]=0000000000770000 | |
105 | expect[14]=258048 | |
106 | ||
107 | status[15]=showStatus('0000000000780000') | |
108 | actual[15]=0000000000780000 | |
109 | expect[15]=780000 | |
110 | ||
111 | status[16]=showStatus('0765432198') | |
112 | actual[16]=0765432198 | |
113 | expect[16]=765432198 | |
114 | ||
115 | status[17]=showStatus('00076543219800') | |
116 | actual[17]=00076543219800 | |
117 | expect[17]=76543219800 | |
118 | ||
119 | status[18]=showStatus('0000001001007') | |
120 | actual[18]=0000001001007 | |
121 | expect[18]=262663 | |
122 | ||
123 | status[19]=showStatus('0000001001009') | |
124 | actual[19]=0000001001009 | |
125 | expect[19]=1001009 | |
126 | ||
127 | status[20]=showStatus('070') | |
128 | actual[20]=070 | |
129 | expect[20]=56 | |
130 | ||
131 | status[21]=showStatus('080') | |
132 | actual[21]=080 | |
133 | expect[21]=80 | |
134 | ||
135 | ||
136 | ||
137 | //------------------------------------------------------------------------------------------------- | |
138 | test(); | |
139 | //------------------------------------------------------------------------------------------------- | |
140 | ||
141 | ||
142 | function showStatus(msg) | |
143 | { | |
144 | return (statprefix + quote + msg + quote); | |
145 | } | |
146 | ||
147 | ||
148 | function 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 | } |