Debian Codegraph @

rhino/testsrc/tests/js1_7/geniter/regress-350621.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-350621.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 350621;
9 var summary = 'for-in loops over generator objects';
10 var actual = '';
11 var expect = '';
12
13
14 //-----------------------------------------------------------------------------
15 test();
16 //-----------------------------------------------------------------------------
17
18 function test()
19 {
20 enterFunc ('test');
21 printBugNumber(BUGNUMBER);
22 printStatus (summary);
23
24 var LOOPS = 500;
25
26 function gen1() {
27 for (var a = 1; a <= LOOPS; ++a)
28 yield;
29 }
30
31 function gen2() {
32 for (var b in gen1())
33 yield;
34 }
35
36 function test_it(RUNS) {
37 for (var c = 1; c <= RUNS; ++c) {
38 var count = 0;
39 for (var d in gen2()) {
40 // The next line is needed to demonstrate the bug.
41 // Note that simply omitting the "x" triggers the bug far less often.
42 Object("x");
43 ++count;
44 }
45 if (count != LOOPS) {
46 print("Test run " + c + ": test failed, count = " + count +
47 ", should be " + LOOPS);
48 var failed = true;
49 }
50 }
51 actual = !failed;
52 if (!failed)
53 {
54 print("Test passed.");
55 }
56 }
57
58 expect = true;
59 test_it(20);
60
61 reportCompare(expect, actual, summary);
62
63 exitFunc ('test');
64 }