Skip to content

Commit

Permalink
failing test for generator resumption
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Nov 30, 2023
1 parent fb666c7 commit b071244
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/variable/define-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,3 +532,32 @@ it("variable.define does not report stale rejections", async () => {
assert.deepStrictEqual(values, []);
assert.deepStrictEqual(errors, ["error2"]);
});

it.only("variable.define can resume a generator", async () => {
const runtime = new Runtime();
try {
const module = runtime.module();
module.variable(true).define("cell", () => {
const i = (function* () {
for (let i = 0; true; ++i) {
yield i;
}
})();
return {i};
});
module.define("i", ["cell"], ({i}) => i);
const variable = module.variable(true).define(["i"], (i) => i);
assert.deepStrictEqual(await valueof(variable), {value: 0});
assert.deepStrictEqual(await valueof(variable), {value: 1});
assert.deepStrictEqual(await valueof(variable), {value: 2});
variable.delete();
await runtime._computing;
assert.deepStrictEqual(await valueof(variable), {value: undefined});
variable.define(["i"], (i) => i);
assert.deepStrictEqual(await valueof(variable), {value: 0});
assert.deepStrictEqual(await valueof(variable), {value: 1});
assert.deepStrictEqual(await valueof(variable), {value: 2});
} finally {
runtime.dispose();
}
});

0 comments on commit b071244

Please sign in to comment.