js/src/tests/js1_5/Regress/regress-31255.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_5/Regress/regress-31255.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,79 @@
     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:    09 November 2002
    1.12 + * SUMMARY: JS should treat --> as a single-line comment indicator.
    1.13 + *          Whitespace may occur before the --> on the same line.
    1.14 + *
    1.15 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=31255
    1.16 + * and http://bugzilla.mozilla.org/show_bug.cgi?id=179366 (Rhino version)
    1.17 + *
    1.18 + * Note: <!--, --> are the HTML multi-line comment opener, closer.
    1.19 + * JS already accepted <!-- as a single-line comment indicator.
    1.20 + *
    1.21 + */
    1.22 +//-----------------------------------------------------------------------------
    1.23 +var UBound = 0;
    1.24 +var BUGNUMBER = 31255;
    1.25 +var summary = 'JS should treat --> as a single-line comment indicator';
    1.26 +var status = '';
    1.27 +var statusitems = [];
    1.28 +var actual = '';
    1.29 +var actualvalues = [];
    1.30 +var expect= '';
    1.31 +var expectedvalues = [];
    1.32 +
    1.33 +
    1.34 +<!-- HTML comment start is already a single-line JS comment indicator
    1.35 + var x = 1; <!-- until end-of-line
    1.36 +
    1.37 +	     status = inSection(1);
    1.38 +actual = (x == 1);
    1.39 +expect = true;
    1.40 +addThis();
    1.41 +
    1.42 +--> HTML comment end is JS comments until end-of-line
    1.43 +--> but only if it follows a possible whitespace after line start
    1.44 +--> so in the following --> should not be treated as comments
    1.45 +if (x-->0)
    1.46 +  x = 2;
    1.47 +
    1.48 +status = inSection(2);
    1.49 +actual = (x == 2);
    1.50 +expect = true;
    1.51 +addThis();
    1.52 +
    1.53 +
    1.54 +
    1.55 +//-----------------------------------------------------------------------------
    1.56 +test();
    1.57 +//-----------------------------------------------------------------------------
    1.58 +
    1.59 +
    1.60 +
    1.61 +function addThis()
    1.62 +{
    1.63 +  statusitems[UBound] = status;
    1.64 +  actualvalues[UBound] = actual;
    1.65 +  expectedvalues[UBound] = expect;
    1.66 +  UBound++;
    1.67 +}
    1.68 +
    1.69 +
    1.70 +function test()
    1.71 +{
    1.72 +  enterFunc('test');
    1.73 +  printBugNumber(BUGNUMBER);
    1.74 +  printStatus(summary);
    1.75 +
    1.76 +  for (var i=0; i<UBound; i++)
    1.77 +  {
    1.78 +    reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
    1.79 +  }
    1.80 +
    1.81 +  exitFunc ('test');
    1.82 +}

mercurial