Debian Codegraph @

rhino/testsrc/tests/js1_5/Expressions/regress-394673.js

raw symbols SCIP
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 var gTestfile = 'regress-394673.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 394673;
9 var summary = 'Parsing long chains of "&&" or "||"';
10 var actual = 'No Error';
11 var expect = 'No Error';
12
13 printBugNumber(BUGNUMBER);
14 printStatus (summary);
15
16 var N = 70*1000;
17 var counter;
18
19 counter = 0;
20 var x = build("&&")();
21 if (x !== true)
22 throw "Unexpected result: x="+x;
23 if (counter != N)
24 throw "Unexpected counter: counter="+counter;
25
26 counter = 0;
27 var x = build("||")();
28 if (x !== true)
29 throw "Unexpected result: x="+x;
30 if (counter != 1)
31 throw "Unexpected counter: counter="+counter;
32
33 function build(operation)
34 {
35 var counter;
36 var a = [];
37 a.push("return f()");
38 for (var i = 1; i != N - 1; ++i)
39 a.push("f()");
40 a.push("f();");
41 return new Function(a.join(operation));
42 }
43
44 function f()
45 {
46 ++counter;
47 return true;
48 }
49
50 reportCompare(expect, actual, summary);