js/src/tests/js1_5/Expressions/regress-394673.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_5/Expressions/regress-394673.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,49 @@
     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 +var BUGNUMBER = 394673;
    1.11 +var summary = 'Parsing long chains of "&&" or "||"';
    1.12 +var actual = 'No Error';
    1.13 +var expect = 'No Error';
    1.14 +
    1.15 +printBugNumber(BUGNUMBER);
    1.16 +printStatus (summary);
    1.17 + 
    1.18 +var N = 70*1000;
    1.19 +var counter;
    1.20 +
    1.21 +counter = 0;
    1.22 +var x = build("&&")();
    1.23 +if (x !== true)
    1.24 +  throw "Unexpected result: x="+x;
    1.25 +if (counter != N)
    1.26 +  throw "Unexpected counter: counter="+counter;
    1.27 +
    1.28 +counter = 0;
    1.29 +var x = build("||")();
    1.30 +if (x !== true)
    1.31 +  throw "Unexpected result: x="+x;
    1.32 +if (counter != 1)
    1.33 +  throw "Unexpected counter: counter="+counter;
    1.34 +
    1.35 +function build(operation)
    1.36 +{
    1.37 +  var counter;
    1.38 +  var a = [];
    1.39 +  a.push("return f()");
    1.40 +  for (var i = 1; i != N - 1; ++i)
    1.41 +    a.push("f()");
    1.42 +  a.push("f();");
    1.43 +  return new Function(a.join(operation));
    1.44 +}
    1.45 +
    1.46 +function f()
    1.47 +{
    1.48 +  ++counter;
    1.49 +  return true;
    1.50 +}
    1.51 +
    1.52 +reportCompare(expect, actual, summary);

mercurial