Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions test/class.js
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"]);
});
});