Frame-onPop-generators-06.js (698B)
1 load(libdir + "asserts.js"); 2 load(libdir + 'match.js'); 3 load(libdir + 'match-debugger.js'); 4 const { Pattern } = Match; 5 const { OBJECT_WITH_EXACTLY: EXACT } = Pattern; 6 7 let g = newGlobal({newCompartment: true}); 8 let dbg = Debugger(g); 9 const log = []; 10 g.capture = function () { 11 dbg.getNewestFrame().onPop = completion => { 12 log.push(completion); 13 }; 14 }; 15 16 g.eval(` 17 function* f() { 18 capture(); 19 yield 3; 20 return "ok"; 21 } 22 `); 23 24 assertDeepEq([... g.f()], [3]); 25 Pattern([ 26 EXACT({ return: new DebuggerObjectPattern("Object", { value: 3, done: false }), yield: true }), 27 EXACT({ return: new DebuggerObjectPattern("Object", { value: "ok", done: true }) }), 28 ]).assert(log);