summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Frame-onPop-generators-07.js
blob: 7872b345e649d23dd648fa71cc988e2b25ccf74e (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
// Completion values for generators report yields and initial yields.

load(libdir + "asserts.js");
load(libdir + 'match.js');
load(libdir + 'match-debugger.js');
const { Pattern } = Match;
const { OBJECT_WITH_EXACTLY: X } = Pattern;

const g = newGlobal({ newCompartment: true });
g.eval(`
  function* f() {
    yield "yielding";
    return "returning";
  }
`);

const dbg = new Debugger(g);
const completions = [];
dbg.onEnterFrame = frame => {
  frame.onPop = completion => {
    completions.push(completion);
  };
};

assertDeepEq([... g.f()], ["yielding"]);
print(JSON.stringify(completions));
Pattern([
  X({
    return: new DebuggerObjectPattern("Generator", {}),
    yield: true,
    initial: true
  }),
  X({
    return: new DebuggerObjectPattern("Object", { value: "yielding", done: false }),
    yield: true
  }),
  X({
    return: new DebuggerObjectPattern("Object", { value: "returning", done: true })
  }),
]).assert(completions);