Skip to content
This repository has been archived by the owner on Feb 1, 2025. It is now read-only.

Failing test of class computed method name yield with argument #487

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions test/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,30 @@ describe("class methods", function () {
assert.strictEqual(new res().one(), 1);
assert.strictEqual(new res().two(), 2);
});

it("should allow computed method keys containing yield with argument", function () {
function *gen(prefix) {
return class Foo {
[yield "array iterator"](x) {
return [prefix + x][Symbol.iterator]();
}

*[yield "generator method"](x) {
yield (prefix + x);
}
}
}

const g = gen("prefix:");

assert.deepEqual(g.next(), { value: "array iterator", done: false });
assert.deepEqual(g.next("arr"), { value: "generator method", done: false });

const { value: Foo, done } = g.next("gen");
assert.strictEqual(done, true);

const foo = new Foo();
check(foo.arr("xxx"), ["prefix:xxx"]);
check(foo.gen("yyy"), ["prefix:yyy"]);
});
});