|
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 /* |
|
7 * |
|
8 * Date: 30 Oct 2002 |
|
9 * SUMMARY: '\400' should lex as a 2-digit octal escape + '0' |
|
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=177314 |
|
11 * |
|
12 * Bug was that Rhino interpreted '\400' as a 3-digit octal escape. As such |
|
13 * it is invalid, since octal escapes may only run from '\0' to '\377'. But |
|
14 * the lexer should interpret this as '\40' + '0' instead, and throw no error. |
|
15 * |
|
16 */ |
|
17 //----------------------------------------------------------------------------- |
|
18 var UBound = 0; |
|
19 var BUGNUMBER = 177314; |
|
20 var summary = "'\\" + "400' should lex as a 2-digit octal escape + '0'"; |
|
21 var status = ''; |
|
22 var statusitems = []; |
|
23 var actual = ''; |
|
24 var actualvalues = []; |
|
25 var expect= ''; |
|
26 var expectedvalues = []; |
|
27 |
|
28 |
|
29 // the last valid octal escape is '\377', which should equal hex escape '\xFF' |
|
30 status = inSection(1); |
|
31 actual = '\377'; |
|
32 expect = '\xFF'; |
|
33 addThis(); |
|
34 |
|
35 // now exercise the lexer by going one higher in the last digit |
|
36 status = inSection(2); |
|
37 actual = '\378'; |
|
38 expect = '\37' + '8'; |
|
39 addThis(); |
|
40 |
|
41 // trickier: 400 is a valid octal number, but '\400' isn't a valid octal escape |
|
42 status = inSection(3); |
|
43 actual = '\400'; |
|
44 expect = '\40' + '0'; |
|
45 addThis(); |
|
46 |
|
47 |
|
48 |
|
49 //----------------------------------------------------------------------------- |
|
50 test(); |
|
51 //----------------------------------------------------------------------------- |
|
52 |
|
53 |
|
54 |
|
55 function addThis() |
|
56 { |
|
57 statusitems[UBound] = status; |
|
58 actualvalues[UBound] = actual; |
|
59 expectedvalues[UBound] = expect; |
|
60 UBound++; |
|
61 } |
|
62 |
|
63 |
|
64 function test() |
|
65 { |
|
66 enterFunc('test'); |
|
67 printBugNumber(BUGNUMBER); |
|
68 printStatus(summary); |
|
69 |
|
70 for (var i=0; i<UBound; i++) |
|
71 { |
|
72 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
|
73 } |
|
74 |
|
75 exitFunc ('test'); |
|
76 } |