|
1 // Environments of different instances of the same generator have the same |
|
2 // callee. I love this job. |
|
3 |
|
4 var g = newGlobal(); |
|
5 var dbg = new Debugger; |
|
6 var gw = dbg.addDebuggee(g); |
|
7 |
|
8 function check(gen, label) { |
|
9 print("check(" + label + ")"); |
|
10 var hits; |
|
11 dbg.onDebuggerStatement = function (frame) { |
|
12 hits++; |
|
13 var env = frame.environment; |
|
14 assertEq(env.callee, gw.makeDebuggeeValue(g.f)); |
|
15 }; |
|
16 hits = 0; |
|
17 gen.next(); |
|
18 assertEq(hits, 1); |
|
19 } |
|
20 |
|
21 g.eval('function f(x) { debugger; yield x; }'); |
|
22 g.eval('var g = f(2);'); |
|
23 g.eval('var h = f(3);'); |
|
24 check(g.g, 'g.g'); |
|
25 check(g.h, 'g.h'); |
|
26 |
|
27 g.eval('function* f(x) { debugger; yield x; }'); |
|
28 g.eval('var g = f(2);'); |
|
29 g.eval('var h = f(3);'); |
|
30 check(g.g, 'g.g'); |
|
31 check(g.h, 'g.h'); |