js/src/tests/js1_5/LexicalConventions/regress-177314.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_5/LexicalConventions/regress-177314.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/*
    1.10 + *
    1.11 + * Date:    30 Oct 2002
    1.12 + * SUMMARY: '\400' should lex as a 2-digit octal escape + '0'
    1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=177314
    1.14 + *
    1.15 + * Bug was that Rhino interpreted '\400' as a 3-digit octal escape. As such
    1.16 + * it is invalid, since octal escapes may only run from '\0' to '\377'. But
    1.17 + * the lexer should interpret this as '\40' + '0' instead, and throw no error.
    1.18 + *
    1.19 + */
    1.20 +//-----------------------------------------------------------------------------
    1.21 +var UBound = 0;
    1.22 +var BUGNUMBER = 177314;
    1.23 +var summary = "'\\" + "400' should lex as a 2-digit octal escape + '0'";
    1.24 +var status = '';
    1.25 +var statusitems = [];
    1.26 +var actual = '';
    1.27 +var actualvalues = [];
    1.28 +var expect= '';
    1.29 +var expectedvalues = [];
    1.30 +
    1.31 +
    1.32 +// the last valid octal escape is '\377', which should equal hex escape '\xFF'
    1.33 +status = inSection(1);
    1.34 +actual = '\377';
    1.35 +expect = '\xFF';
    1.36 +addThis();
    1.37 +
    1.38 +// now exercise the lexer by going one higher in the last digit
    1.39 +status = inSection(2);
    1.40 +actual = '\378';
    1.41 +expect = '\37' + '8';
    1.42 +addThis();
    1.43 +
    1.44 +// trickier: 400 is a valid octal number, but '\400' isn't a valid octal escape
    1.45 +status = inSection(3);
    1.46 +actual = '\400';
    1.47 +expect = '\40' + '0';
    1.48 +addThis();
    1.49 +
    1.50 +
    1.51 +
    1.52 +//-----------------------------------------------------------------------------
    1.53 +test();
    1.54 +//-----------------------------------------------------------------------------
    1.55 +
    1.56 +
    1.57 +
    1.58 +function addThis()
    1.59 +{
    1.60 +  statusitems[UBound] = status;
    1.61 +  actualvalues[UBound] = actual;
    1.62 +  expectedvalues[UBound] = expect;
    1.63 +  UBound++;
    1.64 +}
    1.65 +
    1.66 +
    1.67 +function test()
    1.68 +{
    1.69 +  enterFunc('test');
    1.70 +  printBugNumber(BUGNUMBER);
    1.71 +  printStatus(summary);
    1.72 +
    1.73 +  for (var i=0; i<UBound; i++)
    1.74 +  {
    1.75 +    reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
    1.76 +  }
    1.77 +
    1.78 +  exitFunc ('test');
    1.79 +}

mercurial