| 1 |
/* -*- indent-tabs-mode: nil; js-indent-level: 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 |
printBugNumber(BUGNUMBER); |
| 67 |
printStatus(summary); |
| 68 |
|
| 69 |
for (var i=0; i<UBound; i++) |
| 70 |
{ |
| 71 |
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
| 72 |
} |
| 73 |
} |