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
45
46
47
48
49
50
51
52
53
|
// |jit-test| error:all-jobs-completed-successfully
load(libdir + "asserts.js");
load(libdir + 'match.js');
load(libdir + 'match-debugger.js');
const { Pattern } = Match;
const { OBJECT_WITH_EXACTLY: EXACT } = Pattern;
let g = newGlobal({newCompartment: true});
let dbg = Debugger(g);
const log = [];
g.capture = function () {
dbg.getNewestFrame().onPop = completion => {
log.push(completion);
};
};
g.eval(`
async function* asyncgen() {
capture();
await Promise.resolve(1);
yield 2;
await Promise.resolve(3);
yield 4;
return "ok";
}
`);
async function collect() {
let items = [];
for await (let item of g.asyncgen()) {
items.push(item);
}
return items;
}
collect().then(value => {
assertDeepEq(value, [2, 4]);
Pattern([
EXACT({ return: new DebuggerObjectPattern("Promise"), await: true }),
EXACT({ return: 2, await: true }),
EXACT({ return: 2, yield: true }),
EXACT({ return: new DebuggerObjectPattern("Promise"), await: true }),
EXACT({ return: 4, await: true }),
EXACT({ return: 4, yield: true }),
EXACT({ return: "ok", await: true }),
EXACT({ return: "ok" }),
]).assert(log);
throw "all-jobs-completed-successfully";
});
|