1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_7/geniter/gen-with-call-obj.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,36 @@ 1.4 +var foo; 1.5 + 1.6 +function gen() { 1.7 + var x = 0; 1.8 + foo = function() { return x++; } 1.9 + for (var i = 0; i < 10; ++i) 1.10 + yield x++; 1.11 +} 1.12 + 1.13 +var j = 0; 1.14 +for (i in gen()) 1.15 + assertEq(i, j++); 1.16 + 1.17 +// now mess up the stack 1.18 + 1.19 +function f1(x) { 1.20 + var a, b, c, d, e, f, g; 1.21 + return x <= 0 ? 0 : f1(x-1); 1.22 +} 1.23 +f1(10); 1.24 +function f2(x) { 1.25 + var a = x, b = x; 1.26 + return x <= 0 ? 0 : f2(x-1); 1.27 +} 1.28 +f2(10); 1.29 + 1.30 +// now observe gen's call object (which should have been put) 1.31 + 1.32 +gc(); 1.33 +assertEq(foo(), 10); 1.34 +gc(); 1.35 +assertEq(foo(), 11); 1.36 +gc(); 1.37 +assertEq(foo(), 12); 1.38 + 1.39 +reportCompare(true,true);