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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 var foo;
     3 function gen() {
     4     var x = 0;
     5     foo = function() { return x++; }
     6     for (var i = 0; i < 10; ++i)
     7         yield x++;
     8 }
    10 var j = 0;
    11 for (i in gen())
    12     assertEq(i, j++);
    14 // now mess up the stack
    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);
    27 // now observe gen's call object (which should have been put)
    29 gc();
    30 assertEq(foo(), 10);
    31 gc();
    32 assertEq(foo(), 11);
    33 gc();
    34 assertEq(foo(), 12);
    36 reportCompare(true,true);

mercurial