js/src/jit-test/tests/debug/Environment-callee-03.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/Environment-callee-03.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,31 @@
     1.4 +// Environments of different instances of the same generator have the same
     1.5 +// callee. I love this job.
     1.6 +
     1.7 +var g = newGlobal();
     1.8 +var dbg = new Debugger;
     1.9 +var gw = dbg.addDebuggee(g);
    1.10 +
    1.11 +function check(gen, label) {
    1.12 +  print("check(" + label + ")");
    1.13 +  var hits;
    1.14 +  dbg.onDebuggerStatement = function (frame) {
    1.15 +    hits++;
    1.16 +    var env = frame.environment;
    1.17 +    assertEq(env.callee, gw.makeDebuggeeValue(g.f));
    1.18 +  };
    1.19 +  hits = 0;
    1.20 +  gen.next();
    1.21 +  assertEq(hits, 1);
    1.22 +}
    1.23 +
    1.24 +g.eval('function f(x) { debugger; yield x; }');
    1.25 +g.eval('var g = f(2);');
    1.26 +g.eval('var h = f(3);');
    1.27 +check(g.g, 'g.g');
    1.28 +check(g.h, 'g.h');
    1.29 +
    1.30 +g.eval('function* f(x) { debugger; yield x; }');
    1.31 +g.eval('var g = f(2);');
    1.32 +g.eval('var h = f(3);');
    1.33 +check(g.g, 'g.g');
    1.34 +check(g.h, 'g.h');

mercurial