js/src/tests/js1_7/geniter/gen-with-call-obj.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:1ecb267a08f7
1 var foo;
2
3 function gen() {
4 var x = 0;
5 foo = function() { return x++; }
6 for (var i = 0; i < 10; ++i)
7 yield x++;
8 }
9
10 var j = 0;
11 for (i in gen())
12 assertEq(i, j++);
13
14 // now mess up the stack
15
16 function f1(x) {
17 var a, b, c, d, e, f, g;
18 return x <= 0 ? 0 : f1(x-1);
19 }
20 f1(10);
21 function f2(x) {
22 var a = x, b = x;
23 return x <= 0 ? 0 : f2(x-1);
24 }
25 f2(10);
26
27 // now observe gen's call object (which should have been put)
28
29 gc();
30 assertEq(foo(), 10);
31 gc();
32 assertEq(foo(), 11);
33 gc();
34 assertEq(foo(), 12);
35
36 reportCompare(true,true);

mercurial