blob: 76c91b6dcb3e11b7b0666a3926e64d4c9e527047 (
plain)
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
|
describe("parsing freestanding generators", () => {
test("simple", () => {
expect(`function* foo() {}`).toEval();
expect(`function *foo() {}`).toEval();
expect(`function
*foo() {}`).toEval();
});
test("yield expression", () => {
expect(`function* foo() { yield; }`).toEval();
expect(`function* foo() { yield (yield); }`).toEval();
expect(`function* foo() { yield (yield foo); }`).toEval();
expect(`function foo() { yield; }`).toEval();
expect(`function foo() { yield 3; }`).not.toEval();
});
test("yield-from expression", () => {
expect(`function* foo() { yield *bar; }`).toEval();
expect(`function* foo() { yield *(yield); }`).toEval();
expect(`function* foo() { yield
*bar; }`).not.toEval();
expect(`function foo() { yield
*bar; }`).toEval();
});
});
describe("parsing object literal generator functions", () => {
test("simple", () => {
expect(`x = { *foo() { } }`).toEval();
expect(`x = { * foo() { } }`).toEval();
expect(`x = { *
foo() { } }`).toEval();
});
test("yield", () => {
expect(`x = { foo() { yield; } }`).toEval();
expect(`x = { *foo() { yield; } }`).toEval();
expect(`x = { *foo() { yield 42; } }`).toEval();
expect(`x = { foo() { yield 42; } }`).not.toEval();
expect(`x = { *foo() { yield (yield); } }`).toEval();
expect(`x = { *
foo() { yield (yield); } }`).toEval();
});
});
|