]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/GlobalObject/15.1.2.3-1.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / mozilla / ecma / GlobalObject / 15.1.2.3-1.js
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: 15.1.2.3.js
24 ECMA Section: 15.1.2.3 Function properties of the global object:
25 parseFloat( string )
26
27 Description: The parseFloat function produces a number value dictated
28 by the interpretation of the contents of the string
29 argument defined as a decimal literal.
30
31 When the parseFloat function is called, the following
32 steps are taken:
33
34 1. Call ToString( string ).
35 2. Remove leading whitespace Result(1).
36 3. If neither Result(2) nor any prefix of Result(2)
37 satisfies the syntax of a StrDecimalLiteral,
38 return NaN.
39 4. Compute the longest prefix of Result(2) which might
40 be Resusult(2) itself, that satisfies the syntax of
41 a StrDecimalLiteral
42 5. Return the number value for the MV of Result(4).
43
44 Note that parseFloate may interpret only a leading
45 portion of the string as a number value; it ignores any
46 characters that cannot be interpreted as part of the
47 notation of a decimal literal, and no indication is given
48 that such characters were ignored.
49
50 StrDecimalLiteral::
51 Infinity
52 DecimalDigits.DecimalDigits opt ExponentPart opt
53 .DecimalDigits ExponentPart opt
54 DecimalDigits ExponentPart opt
55
56 Author: christine@netscape.com
57 Date: 28 october 1997
58
59 */
60
61 var SECTION = "15.1.2.3-1";
62 var VERSION = "ECMA_1";
63 startTest();
64 var TITLE = "parseFloat(string)";
65 var BUGNUMBER= "77391";
66
67 writeHeaderToLog( SECTION + " "+ TITLE);
68
69 var testcases = getTestCases();
70
71 test();
72
73
74 function getTestCases() {
75 var array = new Array();
76 var item = 0;
77
78 array[item++] = new TestCase( SECTION, "parseFloat.length", 1, parseFloat.length );
79
80 array[item++] = new TestCase( SECTION, "parseFloat.length = null; parseFloat.length", 1, eval("parseFloat.length = null; parseFloat.length") );
81 array[item++] = new TestCase( SECTION, "delete parseFloat.length", false, delete parseFloat.length );
82 array[item++] = new TestCase( SECTION, "delete parseFloat.length; parseFloat.length", 1, eval("delete parseFloat.length; parseFloat.length") );
83 array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS") );
84
85 array[item++] = new TestCase( SECTION, "parseFloat()", Number.NaN, parseFloat() );
86 array[item++] = new TestCase( SECTION, "parseFloat('')", Number.NaN, parseFloat('') );
87
88 array[item++] = new TestCase( SECTION, "parseFloat(' ')", Number.NaN, parseFloat(' ') );
89 array[item++] = new TestCase( SECTION, "parseFloat(true)", Number.NaN, parseFloat(true) );
90 array[item++] = new TestCase( SECTION, "parseFloat(false)", Number.NaN, parseFloat(false) );
91 array[item++] = new TestCase( SECTION, "parseFloat('string')", Number.NaN, parseFloat("string") );
92
93 array[item++] = new TestCase( SECTION, "parseFloat(' Infinity')", Infinity, parseFloat("Infinity") );
94 array[item++] = new TestCase( SECTION, "parseFloat(' Infinity ')", Infinity, parseFloat(' Infinity ') );
95
96 array[item++] = new TestCase( SECTION, "parseFloat('Infinity')", Infinity, parseFloat("Infinity") );
97 array[item++] = new TestCase( SECTION, "parseFloat(Infinity)", Infinity, parseFloat(Infinity) );
98
99
100 array[item++] = new TestCase( SECTION, "parseFloat(' +Infinity')", +Infinity, parseFloat("+Infinity") );
101 array[item++] = new TestCase( SECTION, "parseFloat(' -Infinity ')", -Infinity, parseFloat(' -Infinity ') );
102
103 array[item++] = new TestCase( SECTION, "parseFloat('+Infinity')", +Infinity, parseFloat("+Infinity") );
104 array[item++] = new TestCase( SECTION, "parseFloat(-Infinity)", -Infinity, parseFloat(-Infinity) );
105
106 array[item++] = new TestCase( SECTION, "parseFloat('0')", 0, parseFloat("0") );
107 array[item++] = new TestCase( SECTION, "parseFloat('-0')", -0, parseFloat("-0") );
108 array[item++] = new TestCase( SECTION, "parseFloat('+0')", 0, parseFloat("+0") );
109
110 array[item++] = new TestCase( SECTION, "parseFloat('1')", 1, parseFloat("1") );
111 array[item++] = new TestCase( SECTION, "parseFloat('-1')", -1, parseFloat("-1") );
112 array[item++] = new TestCase( SECTION, "parseFloat('+1')", 1, parseFloat("+1") );
113
114 array[item++] = new TestCase( SECTION, "parseFloat('2')", 2, parseFloat("2") );
115 array[item++] = new TestCase( SECTION, "parseFloat('-2')", -2, parseFloat("-2") );
116 array[item++] = new TestCase( SECTION, "parseFloat('+2')", 2, parseFloat("+2") );
117
118 array[item++] = new TestCase( SECTION, "parseFloat('3')", 3, parseFloat("3") );
119 array[item++] = new TestCase( SECTION, "parseFloat('-3')", -3, parseFloat("-3") );
120 array[item++] = new TestCase( SECTION, "parseFloat('+3')", 3, parseFloat("+3") );
121
122 array[item++] = new TestCase( SECTION, "parseFloat('4')", 4, parseFloat("4") );
123 array[item++] = new TestCase( SECTION, "parseFloat('-4')", -4, parseFloat("-4") );
124 array[item++] = new TestCase( SECTION, "parseFloat('+4')", 4, parseFloat("+4") );
125
126 array[item++] = new TestCase( SECTION, "parseFloat('5')", 5, parseFloat("5") );
127 array[item++] = new TestCase( SECTION, "parseFloat('-5')", -5, parseFloat("-5") );
128 array[item++] = new TestCase( SECTION, "parseFloat('+5')", 5, parseFloat("+5") );
129
130 array[item++] = new TestCase( SECTION, "parseFloat('6')", 6, parseFloat("6") );
131 array[item++] = new TestCase( SECTION, "parseFloat('-6')", -6, parseFloat("-6") );
132 array[item++] = new TestCase( SECTION, "parseFloat('+6')", 6, parseFloat("+6") );
133
134 array[item++] = new TestCase( SECTION, "parseFloat('7')", 7, parseFloat("7") );
135 array[item++] = new TestCase( SECTION, "parseFloat('-7')", -7, parseFloat("-7") );
136 array[item++] = new TestCase( SECTION, "parseFloat('+7')", 7, parseFloat("+7") );
137
138 array[item++] = new TestCase( SECTION, "parseFloat('8')", 8, parseFloat("8") );
139 array[item++] = new TestCase( SECTION, "parseFloat('-8')", -8, parseFloat("-8") );
140 array[item++] = new TestCase( SECTION, "parseFloat('+8')", 8, parseFloat("+8") );
141
142 array[item++] = new TestCase( SECTION, "parseFloat('9')", 9, parseFloat("9") );
143 array[item++] = new TestCase( SECTION, "parseFloat('-9')", -9, parseFloat("-9") );
144 array[item++] = new TestCase( SECTION, "parseFloat('+9')", 9, parseFloat("+9") );
145
146 array[item++] = new TestCase( SECTION, "parseFloat('3.14159')", 3.14159, parseFloat("3.14159") );
147 array[item++] = new TestCase( SECTION, "parseFloat('-3.14159')", -3.14159, parseFloat("-3.14159") );
148 array[item++] = new TestCase( SECTION, "parseFloat('+3.14159')", 3.14159, parseFloat("+3.14159") );
149
150 array[item++] = new TestCase( SECTION, "parseFloat('3.')", 3, parseFloat("3.") );
151 array[item++] = new TestCase( SECTION, "parseFloat('-3.')", -3, parseFloat("-3.") );
152 array[item++] = new TestCase( SECTION, "parseFloat('+3.')", 3, parseFloat("+3.") );
153
154 array[item++] = new TestCase( SECTION, "parseFloat('3.e1')", 30, parseFloat("3.e1") );
155 array[item++] = new TestCase( SECTION, "parseFloat('-3.e1')", -30, parseFloat("-3.e1") );
156 array[item++] = new TestCase( SECTION, "parseFloat('+3.e1')", 30, parseFloat("+3.e1") );
157
158 array[item++] = new TestCase( SECTION, "parseFloat('3.e+1')", 30, parseFloat("3.e+1") );
159 array[item++] = new TestCase( SECTION, "parseFloat('-3.e+1')", -30, parseFloat("-3.e+1") );
160 array[item++] = new TestCase( SECTION, "parseFloat('+3.e+1')", 30, parseFloat("+3.e+1") );
161
162 array[item++] = new TestCase( SECTION, "parseFloat('3.e-1')", .30, parseFloat("3.e-1") );
163 array[item++] = new TestCase( SECTION, "parseFloat('-3.e-1')", -.30, parseFloat("-3.e-1") );
164 array[item++] = new TestCase( SECTION, "parseFloat('+3.e-1')", .30, parseFloat("+3.e-1") );
165
166 // StrDecimalLiteral::: .DecimalDigits ExponentPart opt
167
168 array[item++] = new TestCase( SECTION, "parseFloat('.00001')", 0.00001, parseFloat(".00001") );
169 array[item++] = new TestCase( SECTION, "parseFloat('+.00001')", 0.00001, parseFloat("+.00001") );
170 array[item++] = new TestCase( SECTION, "parseFloat('-0.0001')", -0.00001, parseFloat("-.00001") );
171
172 array[item++] = new TestCase( SECTION, "parseFloat('.01e2')", 1, parseFloat(".01e2") );
173 array[item++] = new TestCase( SECTION, "parseFloat('+.01e2')", 1, parseFloat("+.01e2") );
174 array[item++] = new TestCase( SECTION, "parseFloat('-.01e2')", -1, parseFloat("-.01e2") );
175
176 array[item++] = new TestCase( SECTION, "parseFloat('.01e+2')", 1, parseFloat(".01e+2") );
177 array[item++] = new TestCase( SECTION, "parseFloat('+.01e+2')", 1, parseFloat("+.01e+2") );
178 array[item++] = new TestCase( SECTION, "parseFloat('-.01e+2')", -1, parseFloat("-.01e+2") );
179
180 array[item++] = new TestCase( SECTION, "parseFloat('.01e-2')", 0.0001, parseFloat(".01e-2") );
181 array[item++] = new TestCase( SECTION, "parseFloat('+.01e-2')", 0.0001, parseFloat("+.01e-2") );
182 array[item++] = new TestCase( SECTION, "parseFloat('-.01e-2')", -0.0001, parseFloat("-.01e-2") );
183
184 // StrDecimalLiteral::: DecimalDigits ExponentPart opt
185
186 array[item++] = new TestCase( SECTION, "parseFloat('1234e5')", 123400000, parseFloat("1234e5") );
187 array[item++] = new TestCase( SECTION, "parseFloat('+1234e5')", 123400000, parseFloat("+1234e5") );
188 array[item++] = new TestCase( SECTION, "parseFloat('-1234e5')", -123400000, parseFloat("-1234e5") );
189
190 array[item++] = new TestCase( SECTION, "parseFloat('1234e+5')", 123400000, parseFloat("1234e+5") );
191 array[item++] = new TestCase( SECTION, "parseFloat('+1234e+5')", 123400000, parseFloat("+1234e+5") );
192 array[item++] = new TestCase( SECTION, "parseFloat('-1234e+5')", -123400000, parseFloat("-1234e+5") );
193
194 array[item++] = new TestCase( SECTION, "parseFloat('1234e-5')", 0.01234, parseFloat("1234e-5") );
195 array[item++] = new TestCase( SECTION, "parseFloat('+1234e-5')", 0.01234, parseFloat("+1234e-5") );
196 array[item++] = new TestCase( SECTION, "parseFloat('-1234e-5')", -0.01234, parseFloat("-1234e-5") );
197
198
199 array[item++] = new TestCase( SECTION, "parseFloat(0)", 0, parseFloat(0) );
200 array[item++] = new TestCase( SECTION, "parseFloat(-0)", -0, parseFloat(-0) );
201
202 array[item++] = new TestCase( SECTION, "parseFloat(1)", 1, parseFloat(1) );
203 array[item++] = new TestCase( SECTION, "parseFloat(-1)", -1, parseFloat(-1) );
204
205 array[item++] = new TestCase( SECTION, "parseFloat(2)", 2, parseFloat(2) );
206 array[item++] = new TestCase( SECTION, "parseFloat(-2)", -2, parseFloat(-2) );
207
208 array[item++] = new TestCase( SECTION, "parseFloat(3)", 3, parseFloat(3) );
209 array[item++] = new TestCase( SECTION, "parseFloat(-3)", -3, parseFloat(-3) );
210
211 array[item++] = new TestCase( SECTION, "parseFloat(4)", 4, parseFloat(4) );
212 array[item++] = new TestCase( SECTION, "parseFloat(-4)", -4, parseFloat(-4) );
213
214 array[item++] = new TestCase( SECTION, "parseFloat(5)", 5, parseFloat(5) );
215 array[item++] = new TestCase( SECTION, "parseFloat(-5)", -5, parseFloat(-5) );
216
217 array[item++] = new TestCase( SECTION, "parseFloat(6)", 6, parseFloat(6) );
218 array[item++] = new TestCase( SECTION, "parseFloat(-6)", -6, parseFloat(-6) );
219
220 array[item++] = new TestCase( SECTION, "parseFloat(7)", 7, parseFloat(7) );
221 array[item++] = new TestCase( SECTION, "parseFloat(-7)", -7, parseFloat(-7) );
222
223 array[item++] = new TestCase( SECTION, "parseFloat(8)", 8, parseFloat(8) );
224 array[item++] = new TestCase( SECTION, "parseFloat(-8)", -8, parseFloat(-8) );
225
226 array[item++] = new TestCase( SECTION, "parseFloat(9)", 9, parseFloat(9) );
227 array[item++] = new TestCase( SECTION, "parseFloat(-9)", -9, parseFloat(-9) );
228
229 array[item++] = new TestCase( SECTION, "parseFloat(3.14159)", 3.14159, parseFloat(3.14159) );
230 array[item++] = new TestCase( SECTION, "parseFloat(-3.14159)", -3.14159, parseFloat(-3.14159) );
231
232 array[item++] = new TestCase( SECTION, "parseFloat(3.)", 3, parseFloat(3.) );
233 array[item++] = new TestCase( SECTION, "parseFloat(-3.)", -3, parseFloat(-3.) );
234
235 array[item++] = new TestCase( SECTION, "parseFloat(3.e1)", 30, parseFloat(3.e1) );
236 array[item++] = new TestCase( SECTION, "parseFloat(-3.e1)", -30, parseFloat(-3.e1) );
237
238 array[item++] = new TestCase( SECTION, "parseFloat(3.e+1)", 30, parseFloat(3.e+1) );
239 array[item++] = new TestCase( SECTION, "parseFloat(-3.e+1)", -30, parseFloat(-3.e+1) );
240
241 array[item++] = new TestCase( SECTION, "parseFloat(3.e-1)", .30, parseFloat(3.e-1) );
242 array[item++] = new TestCase( SECTION, "parseFloat(-3.e-1)", -.30, parseFloat(-3.e-1) );
243
244
245 array[item++] = new TestCase( SECTION, "parseFloat(3.E1)", 30, parseFloat(3.E1) );
246 array[item++] = new TestCase( SECTION, "parseFloat(-3.E1)", -30, parseFloat(-3.E1) );
247
248 array[item++] = new TestCase( SECTION, "parseFloat(3.E+1)", 30, parseFloat(3.E+1) );
249 array[item++] = new TestCase( SECTION, "parseFloat(-3.E+1)", -30, parseFloat(-3.E+1) );
250
251 array[item++] = new TestCase( SECTION, "parseFloat(3.E-1)", .30, parseFloat(3.E-1) );
252 array[item++] = new TestCase( SECTION, "parseFloat(-3.E-1)", -.30, parseFloat(-3.E-1) );
253
254 // StrDecimalLiteral::: .DecimalDigits ExponentPart opt
255
256 array[item++] = new TestCase( SECTION, "parseFloat(.00001)", 0.00001, parseFloat(.00001) );
257 array[item++] = new TestCase( SECTION, "parseFloat(-0.0001)", -0.00001, parseFloat(-.00001) );
258
259 array[item++] = new TestCase( SECTION, "parseFloat(.01e2)", 1, parseFloat(.01e2) );
260 array[item++] = new TestCase( SECTION, "parseFloat(-.01e2)", -1, parseFloat(-.01e2) );
261
262 array[item++] = new TestCase( SECTION, "parseFloat(.01e+2)", 1, parseFloat(.01e+2) );
263 array[item++] = new TestCase( SECTION, "parseFloat(-.01e+2)", -1, parseFloat(-.01e+2) );
264
265 array[item++] = new TestCase( SECTION, "parseFloat(.01e-2)", 0.0001, parseFloat(.01e-2) );
266 array[item++] = new TestCase( SECTION, "parseFloat(-.01e-2)", -0.0001, parseFloat(-.01e-2) );
267
268 // StrDecimalLiteral::: DecimalDigits ExponentPart opt
269
270 array[item++] = new TestCase( SECTION, "parseFloat(1234e5)", 123400000, parseFloat(1234e5) );
271 array[item++] = new TestCase( SECTION, "parseFloat(-1234e5)", -123400000, parseFloat(-1234e5) );
272
273 array[item++] = new TestCase( SECTION, "parseFloat(1234e+5)", 123400000, parseFloat(1234e+5) );
274 array[item++] = new TestCase( SECTION, "parseFloat(-1234e+5)", -123400000, parseFloat(-1234e+5) );
275
276 array[item++] = new TestCase( SECTION, "parseFloat(1234e-5)", 0.01234, parseFloat(1234e-5) );
277 array[item++] = new TestCase( SECTION, "parseFloat(-1234e-5)", -0.01234, parseFloat(-1234e-5) );
278
279 // hex cases should all return 0 (0 is the longest string that satisfies a StringDecimalLiteral)
280
281 array[item++] = new TestCase( SECTION, "parseFloat('0x0')", 0, parseFloat("0x0"));
282 array[item++] = new TestCase( SECTION, "parseFloat('0x1')", 0, parseFloat("0x1"));
283 array[item++] = new TestCase( SECTION, "parseFloat('0x2')", 0, parseFloat("0x2"));
284 array[item++] = new TestCase( SECTION, "parseFloat('0x3')", 0, parseFloat("0x3"));
285 array[item++] = new TestCase( SECTION, "parseFloat('0x4')", 0, parseFloat("0x4"));
286 array[item++] = new TestCase( SECTION, "parseFloat('0x5')", 0, parseFloat("0x5"));
287 array[item++] = new TestCase( SECTION, "parseFloat('0x6')", 0, parseFloat("0x6"));
288 array[item++] = new TestCase( SECTION, "parseFloat('0x7')", 0, parseFloat("0x7"));
289 array[item++] = new TestCase( SECTION, "parseFloat('0x8')", 0, parseFloat("0x8"));
290 array[item++] = new TestCase( SECTION, "parseFloat('0x9')", 0, parseFloat("0x9"));
291 array[item++] = new TestCase( SECTION, "parseFloat('0xa')", 0, parseFloat("0xa"));
292 array[item++] = new TestCase( SECTION, "parseFloat('0xb')", 0, parseFloat("0xb"));
293 array[item++] = new TestCase( SECTION, "parseFloat('0xc')", 0, parseFloat("0xc"));
294 array[item++] = new TestCase( SECTION, "parseFloat('0xd')", 0, parseFloat("0xd"));
295 array[item++] = new TestCase( SECTION, "parseFloat('0xe')", 0, parseFloat("0xe"));
296 array[item++] = new TestCase( SECTION, "parseFloat('0xf')", 0, parseFloat("0xf"));
297 array[item++] = new TestCase( SECTION, "parseFloat('0xA')", 0, parseFloat("0xA"));
298 array[item++] = new TestCase( SECTION, "parseFloat('0xB')", 0, parseFloat("0xB"));
299 array[item++] = new TestCase( SECTION, "parseFloat('0xC')", 0, parseFloat("0xC"));
300 array[item++] = new TestCase( SECTION, "parseFloat('0xD')", 0, parseFloat("0xD"));
301 array[item++] = new TestCase( SECTION, "parseFloat('0xE')", 0, parseFloat("0xE"));
302 array[item++] = new TestCase( SECTION, "parseFloat('0xF')", 0, parseFloat("0xF"));
303
304 array[item++] = new TestCase( SECTION, "parseFloat('0X0')", 0, parseFloat("0X0"));
305 array[item++] = new TestCase( SECTION, "parseFloat('0X1')", 0, parseFloat("0X1"));
306 array[item++] = new TestCase( SECTION, "parseFloat('0X2')", 0, parseFloat("0X2"));
307 array[item++] = new TestCase( SECTION, "parseFloat('0X3')", 0, parseFloat("0X3"));
308 array[item++] = new TestCase( SECTION, "parseFloat('0X4')", 0, parseFloat("0X4"));
309 array[item++] = new TestCase( SECTION, "parseFloat('0X5')", 0, parseFloat("0X5"));
310 array[item++] = new TestCase( SECTION, "parseFloat('0X6')", 0, parseFloat("0X6"));
311 array[item++] = new TestCase( SECTION, "parseFloat('0X7')", 0, parseFloat("0X7"));
312 array[item++] = new TestCase( SECTION, "parseFloat('0X8')", 0, parseFloat("0X8"));
313 array[item++] = new TestCase( SECTION, "parseFloat('0X9')", 0, parseFloat("0X9"));
314 array[item++] = new TestCase( SECTION, "parseFloat('0Xa')", 0, parseFloat("0Xa"));
315 array[item++] = new TestCase( SECTION, "parseFloat('0Xb')", 0, parseFloat("0Xb"));
316 array[item++] = new TestCase( SECTION, "parseFloat('0Xc')", 0, parseFloat("0Xc"));
317 array[item++] = new TestCase( SECTION, "parseFloat('0Xd')", 0, parseFloat("0Xd"));
318 array[item++] = new TestCase( SECTION, "parseFloat('0Xe')", 0, parseFloat("0Xe"));
319 array[item++] = new TestCase( SECTION, "parseFloat('0Xf')", 0, parseFloat("0Xf"));
320 array[item++] = new TestCase( SECTION, "parseFloat('0XA')", 0, parseFloat("0XA"));
321 array[item++] = new TestCase( SECTION, "parseFloat('0XB')", 0, parseFloat("0XB"));
322 array[item++] = new TestCase( SECTION, "parseFloat('0XC')", 0, parseFloat("0XC"));
323 array[item++] = new TestCase( SECTION, "parseFloat('0XD')", 0, parseFloat("0XD"));
324 array[item++] = new TestCase( SECTION, "parseFloat('0XE')", 0, parseFloat("0XE"));
325 array[item++] = new TestCase( SECTION, "parseFloat('0XF')", 0, parseFloat("0XF"));
326 array[item++] = new TestCase( SECTION, "parseFloat(' 0XF ')", 0, parseFloat(" 0XF "));
327
328 // hex literals should still succeed
329
330 array[item++] = new TestCase( SECTION, "parseFloat(0x0)", 0, parseFloat(0x0));
331 array[item++] = new TestCase( SECTION, "parseFloat(0x1)", 1, parseFloat(0x1));
332 array[item++] = new TestCase( SECTION, "parseFloat(0x2)", 2, parseFloat(0x2));
333 array[item++] = new TestCase( SECTION, "parseFloat(0x3)", 3, parseFloat(0x3));
334 array[item++] = new TestCase( SECTION, "parseFloat(0x4)", 4, parseFloat(0x4));
335 array[item++] = new TestCase( SECTION, "parseFloat(0x5)", 5, parseFloat(0x5));
336 array[item++] = new TestCase( SECTION, "parseFloat(0x6)", 6, parseFloat(0x6));
337 array[item++] = new TestCase( SECTION, "parseFloat(0x7)", 7, parseFloat(0x7));
338 array[item++] = new TestCase( SECTION, "parseFloat(0x8)", 8, parseFloat(0x8));
339 array[item++] = new TestCase( SECTION, "parseFloat(0x9)", 9, parseFloat(0x9));
340 array[item++] = new TestCase( SECTION, "parseFloat(0xa)", 10, parseFloat(0xa));
341 array[item++] = new TestCase( SECTION, "parseFloat(0xb)", 11, parseFloat(0xb));
342 array[item++] = new TestCase( SECTION, "parseFloat(0xc)", 12, parseFloat(0xc));
343 array[item++] = new TestCase( SECTION, "parseFloat(0xd)", 13, parseFloat(0xd));
344 array[item++] = new TestCase( SECTION, "parseFloat(0xe)", 14, parseFloat(0xe));
345 array[item++] = new TestCase( SECTION, "parseFloat(0xf)", 15, parseFloat(0xf));
346 array[item++] = new TestCase( SECTION, "parseFloat(0xA)", 10, parseFloat(0xA));
347 array[item++] = new TestCase( SECTION, "parseFloat(0xB)", 11, parseFloat(0xB));
348 array[item++] = new TestCase( SECTION, "parseFloat(0xC)", 12, parseFloat(0xC));
349 array[item++] = new TestCase( SECTION, "parseFloat(0xD)", 13, parseFloat(0xD));
350 array[item++] = new TestCase( SECTION, "parseFloat(0xE)", 14, parseFloat(0xE));
351 array[item++] = new TestCase( SECTION, "parseFloat(0xF)", 15, parseFloat(0xF));
352
353 array[item++] = new TestCase( SECTION, "parseFloat(0X0)", 0, parseFloat(0X0));
354 array[item++] = new TestCase( SECTION, "parseFloat(0X1)", 1, parseFloat(0X1));
355 array[item++] = new TestCase( SECTION, "parseFloat(0X2)", 2, parseFloat(0X2));
356 array[item++] = new TestCase( SECTION, "parseFloat(0X3)", 3, parseFloat(0X3));
357 array[item++] = new TestCase( SECTION, "parseFloat(0X4)", 4, parseFloat(0X4));
358 array[item++] = new TestCase( SECTION, "parseFloat(0X5)", 5, parseFloat(0X5));
359 array[item++] = new TestCase( SECTION, "parseFloat(0X6)", 6, parseFloat(0X6));
360 array[item++] = new TestCase( SECTION, "parseFloat(0X7)", 7, parseFloat(0X7));
361 array[item++] = new TestCase( SECTION, "parseFloat(0X8)", 8, parseFloat(0X8));
362 array[item++] = new TestCase( SECTION, "parseFloat(0X9)", 9, parseFloat(0X9));
363 array[item++] = new TestCase( SECTION, "parseFloat(0Xa)", 10, parseFloat(0Xa));
364 array[item++] = new TestCase( SECTION, "parseFloat(0Xb)", 11, parseFloat(0Xb));
365 array[item++] = new TestCase( SECTION, "parseFloat(0Xc)", 12, parseFloat(0Xc));
366 array[item++] = new TestCase( SECTION, "parseFloat(0Xd)", 13, parseFloat(0Xd));
367 array[item++] = new TestCase( SECTION, "parseFloat(0Xe)", 14, parseFloat(0Xe));
368 array[item++] = new TestCase( SECTION, "parseFloat(0Xf)", 15, parseFloat(0Xf));
369 array[item++] = new TestCase( SECTION, "parseFloat(0XA)", 10, parseFloat(0XA));
370 array[item++] = new TestCase( SECTION, "parseFloat(0XB)", 11, parseFloat(0XB));
371 array[item++] = new TestCase( SECTION, "parseFloat(0XC)", 12, parseFloat(0XC));
372 array[item++] = new TestCase( SECTION, "parseFloat(0XD)", 13, parseFloat(0XD));
373 array[item++] = new TestCase( SECTION, "parseFloat(0XE)", 14, parseFloat(0XE));
374 array[item++] = new TestCase( SECTION, "parseFloat(0XF)", 15, parseFloat(0XF));
375
376
377 // A StringNumericLiteral may not use octal notation
378
379 array[item++] = new TestCase( SECTION, "parseFloat('00')", 0, parseFloat("00"));
380 array[item++] = new TestCase( SECTION, "parseFloat('01')", 1, parseFloat("01"));
381 array[item++] = new TestCase( SECTION, "parseFloat('02')", 2, parseFloat("02"));
382 array[item++] = new TestCase( SECTION, "parseFloat('03')", 3, parseFloat("03"));
383 array[item++] = new TestCase( SECTION, "parseFloat('04')", 4, parseFloat("04"));
384 array[item++] = new TestCase( SECTION, "parseFloat('05')", 5, parseFloat("05"));
385 array[item++] = new TestCase( SECTION, "parseFloat('06')", 6, parseFloat("06"));
386 array[item++] = new TestCase( SECTION, "parseFloat('07')", 7, parseFloat("07"));
387 array[item++] = new TestCase( SECTION, "parseFloat('010')", 10, parseFloat("010"));
388 array[item++] = new TestCase( SECTION, "parseFloat('011')", 11, parseFloat("011"));
389
390 // A StringNumericLIteral may have any number of leading 0 digits
391
392 array[item++] = new TestCase( SECTION, "parseFloat('001')", 1, parseFloat("001"));
393 array[item++] = new TestCase( SECTION, "parseFloat('0001')", 1, parseFloat("0001"));
394 array[item++] = new TestCase( SECTION, "parseFloat(' 0001 ')", 1, parseFloat(" 0001 "));
395
396 // an octal numeric literal should be treated as an octal
397
398 array[item++] = new TestCase( SECTION, "parseFloat(00)", 0, parseFloat(00));
399 array[item++] = new TestCase( SECTION, "parseFloat(01)", 1, parseFloat(01));
400 array[item++] = new TestCase( SECTION, "parseFloat(02)", 2, parseFloat(02));
401 array[item++] = new TestCase( SECTION, "parseFloat(03)", 3, parseFloat(03));
402 array[item++] = new TestCase( SECTION, "parseFloat(04)", 4, parseFloat(04));
403 array[item++] = new TestCase( SECTION, "parseFloat(05)", 5, parseFloat(05));
404 array[item++] = new TestCase( SECTION, "parseFloat(06)", 6, parseFloat(06));
405 array[item++] = new TestCase( SECTION, "parseFloat(07)", 7, parseFloat(07));
406 array[item++] = new TestCase( SECTION, "parseFloat(010)", 8, parseFloat(010));
407 array[item++] = new TestCase( SECTION, "parseFloat(011)", 9, parseFloat(011));
408
409 // A StringNumericLIteral may have any number of leading 0 digits
410
411 array[item++] = new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001));
412 array[item++] = new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001));
413
414 // make sure it's reflexive
415 array[item++] = new TestCase( SECTION, "parseFloat(Math.PI)", Math.PI, parseFloat(Math.PI));
416 array[item++] = new TestCase( SECTION, "parseFloat(Math.LN2)", Math.LN2, parseFloat(Math.LN2));
417 array[item++] = new TestCase( SECTION, "parseFloat(Math.LN10)", Math.LN10, parseFloat(Math.LN10));
418 array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG2E)", Math.LOG2E, parseFloat(Math.LOG2E));
419 array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG10E)", Math.LOG10E, parseFloat(Math.LOG10E));
420 array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT2)", Math.SQRT2, parseFloat(Math.SQRT2));
421 array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT1_2)", Math.SQRT1_2, parseFloat(Math.SQRT1_2));
422
423 array[item++] = new TestCase( SECTION, "parseFloat(Math.PI+'')", Math.PI, parseFloat(Math.PI+''));
424 array[item++] = new TestCase( SECTION, "parseFloat(Math.LN2+'')", Math.LN2, parseFloat(Math.LN2+''));
425 array[item++] = new TestCase( SECTION, "parseFloat(Math.LN10+'')", Math.LN10, parseFloat(Math.LN10+''));
426 array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG2E+'')", Math.LOG2E, parseFloat(Math.LOG2E+''));
427 array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG10E+'')", Math.LOG10E, parseFloat(Math.LOG10E+''));
428 array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT2+'')", Math.SQRT2, parseFloat(Math.SQRT2+''));
429 array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT1_2+'')", Math.SQRT1_2, parseFloat(Math.SQRT1_2+''));
430
431 return ( array );
432 }
433 function test() {
434 for ( tc=0; tc < testcases.length; tc++ ) {
435 testcases[tc].passed = writeTestCaseResult(
436 testcases[tc].expect,
437 testcases[tc].actual,
438 testcases[tc].description +" = "+ testcases[tc].actual );
439
440 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
441 }
442 stopTest();
443 return ( testcases );
444 }