Debian Codegraph @

rhino/testsrc/tests/js1_5/LexicalConventions/lexical-001.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 var gTestfile = 'lexical-001.js';
7
8 /*
9 * Date: 26 November 2000
10 *
11 *SUMMARY: Testing numeric literals that begin with 0.
12 *This test arose from Bugzilla bug 49233.
13 *The best explanation is from jsscan.c:
14 *
15 * "We permit 08 and 09 as decimal numbers, which makes
16 * our behaviour a superset of the ECMA numeric grammar.
17 * We might not always be so permissive, so we warn about it."
18 *
19 *Thus an expression 010 will evaluate, as always, as an octal (to 8).
20 *However, 018 will evaluate as a decimal, to 18. Even though the
21 *user began the expression as an octal, he later used a non-octal
22 *digit. We forgive this and assume he intended a decimal. If the
23 *JavaScript "strict" option is set though, we will give a warning.
24 */
25
26 //-------------------------------------------------------------------------------------------------
27 var BUGNUMBER = '49233';
28 var summary = 'Testing numeric literals that begin with 0';
29 var statprefix = 'Testing ';
30 var quote = "'";
31 var status = new Array();
32 var actual = new Array();
33 var expect = new Array();
34
35
36 status[0]=showStatus('01')
37 actual[0]=01
38 expect[0]=1
39
40 status[1]=showStatus('07')
41 actual[1]=07
42 expect[1]=7
43
44 status[2]=showStatus('08')
45 actual[2]=08
46 expect[2]=8
47
48 status[3]=showStatus('09')
49 actual[3]=09
50 expect[3]=9
51
52 status[4]=showStatus('010')
53 actual[4]=010
54 expect[4]=8
55
56 status[5]=showStatus('017')
57 actual[5]=017
58 expect[5]=15
59
60 status[6]=showStatus('018')
61 actual[6]=018
62 expect[6]=18
63
64 status[7]=showStatus('019')
65 actual[7]=019
66 expect[7]=19
67
68 status[8]=showStatus('079')
69 actual[8]=079
70 expect[8]=79
71
72 status[9]=showStatus('0079')
73 actual[9]=0079
74 expect[9]=79
75
76 status[10]=showStatus('099')
77 actual[10]=099
78 expect[10]=99
79
80 status[11]=showStatus('0099')
81 actual[11]=0099
82 expect[11]=99
83
84 status[12]=showStatus('000000000077')
85 actual[12]=000000000077
86 expect[12]=63
87
88 status[13]=showStatus('000000000078')
89 actual[13]=000000000078
90 expect[13]=78
91
92 status[14]=showStatus('0000000000770000')
93 actual[14]=0000000000770000
94 expect[14]=258048
95
96 status[15]=showStatus('0000000000780000')
97 actual[15]=0000000000780000
98 expect[15]=780000
99
100 status[16]=showStatus('0765432198')
101 actual[16]=0765432198
102 expect[16]=765432198
103
104 status[17]=showStatus('00076543219800')
105 actual[17]=00076543219800
106 expect[17]=76543219800
107
108 status[18]=showStatus('0000001001007')
109 actual[18]=0000001001007
110 expect[18]=262663
111
112 status[19]=showStatus('0000001001009')
113 actual[19]=0000001001009
114 expect[19]=1001009
115
116 status[20]=showStatus('070')
117 actual[20]=070
118 expect[20]=56
119
120 status[21]=showStatus('080')
121 actual[21]=080
122 expect[21]=80
123
124
125
126 //-------------------------------------------------------------------------------------------------
127 test();
128 //-------------------------------------------------------------------------------------------------
129
130
131 function showStatus(msg)
132 {
133 return (statprefix + quote + msg + quote);
134 }
135
136
137 function test()
138 {
139 enterFunc ('test');
140 printBugNumber(BUGNUMBER);
141 printStatus (summary);
142
143
144 for (i=0; i !=status.length; i++)
145 {
146 reportCompare (expect[i], actual[i], status[i]);
147 }
148
149 exitFunc ('test');
150 }