blob: 00f9d0f3b4fa22a3143f777b194a7714c68bf9eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// When a generator frame is resumed, the onEnterFrame fires again.
// The same Frame object is passed.
let g = newGlobal({newCompartment: true});
g.eval(`
function* easyMode() {}
function* f() { yield* "XYZ"; }
function* hardMode() {
for (let c1 of "AB")
for (let c2 of f())
yield c1 + c2;
}
`);
function test(mode, expected) {
let dbg = new Debugger(g);
let nextid = 1;
dbg.onEnterFrame = frame => {
if (frame.type == "call") {
if (!("id" in frame))
frame.id = nextid++;
g.log += frame.id + "(";
frame.onPop = rv => {
g.log += ")";
};
}
};
g.log = "";
g.eval(`
for (let x of ${mode}())
log += x;
`);
assertEq(g.log, expected);
dbg.removeDebuggee(g);
}
// We fire onEnterFrame for the initial activation when a generator is first
// called, even though the initial yield happens before any body code. This is
// weird but at least it's consistent.
test("easyMode", "1()1()");
test("hardMode", "1()1(2()2())AX1(2())AY1(2())AZ1(2()3()3())BX1(3())BY1(3())BZ1(3())");
|