1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
23 * pschwartau@netscape.com
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
41 * Date: 26 November 2000
43 *SUMMARY: Testing numeric literals that begin with 0.
44 *This test arose from Bugzilla bug 49233.
45 *The best explanation is from jsscan.c:
47 * "We permit 08 and 09 as decimal numbers, which makes
48 * our behaviour a superset of the ECMA numeric grammar.
49 * We might not always be so permissive, so we warn about it."
51 *Thus an expression 010 will evaluate, as always, as an octal (to 8).
52 *However, 018 will evaluate as a decimal, to 18. Even though the
53 *user began the expression as an octal, he later used a non-octal
54 *digit. We forgive this and assume he intended a decimal. If the
55 *JavaScript "strict" option is set though, we will give a warning.
58 //-------------------------------------------------------------------------------------------------
59 var BUGNUMBER = '49233';
60 var summary = 'Testing numeric literals that begin with 0';
61 var statprefix = 'Testing ';
63 var status = new Array();
64 var actual = new Array();
65 var expect = new Array();
68 status[0]=showStatus('01')
72 status[1]=showStatus('07')
76 status[2]=showStatus('08')
80 status[3]=showStatus('09')
84 status[4]=showStatus('010')
88 status[5]=showStatus('017')
92 status[6]=showStatus('018')
96 status[7]=showStatus('019')
100 status[8]=showStatus('079')
104 status[9]=showStatus('0079')
108 status[10]=showStatus('099')
112 status[11]=showStatus('0099')
116 status[12]=showStatus('000000000077')
117 actual[12]=000000000077
120 status[13]=showStatus('000000000078')
121 actual[13]=000000000078
124 status[14]=showStatus('0000000000770000')
125 actual[14]=0000000000770000
128 status[15]=showStatus('0000000000780000')
129 actual[15]=0000000000780000
132 status[16]=showStatus('0765432198')
133 actual[16]=0765432198
136 status[17]=showStatus('00076543219800')
137 actual[17]=00076543219800
138 expect[17]=76543219800
140 status[18]=showStatus('0000001001007')
141 actual[18]=0000001001007
144 status[19]=showStatus('0000001001009')
145 actual[19]=0000001001009
148 status[20]=showStatus('070')
152 status[21]=showStatus('080')
158 //-------------------------------------------------------------------------------------------------
160 //-------------------------------------------------------------------------------------------------
163 function showStatus(msg)
165 return (statprefix + quote + msg + quote);
172 printBugNumber(BUGNUMBER);
173 printStatus (summary);
176 for (i=0; i !=status.length; i++)
178 reportCompare (expect[i], actual[i], status[i]);