@@ -51,6 +51,59 @@ test("for..of", () => {
5151 ` . expectToMatchJsResult ( ) ;
5252} ) ;
5353
54+ describe ( "yield*" , ( ) => {
55+ test ( "generator" , ( ) => {
56+ util . testFunction `
57+ function* subGenerator() {
58+ yield 1;
59+ yield 2;
60+ yield 3;
61+ }
62+
63+ function* generator() {
64+ yield 0;
65+ return yield* subGenerator();
66+ }
67+
68+ const it = generator();
69+ return [it.next(), it.next(), it.next(), it.next(), it.next()];
70+ ` . expectToMatchJsResult ( ) ;
71+ } ) ;
72+
73+ test ( "array" , ( ) => {
74+ util . testFunction `
75+ function* generator() {
76+ return yield* [1, 2, 3];
77+ }
78+
79+ const it = generator();
80+ return [it.next(), it.next(), it.next(), it.next()];
81+ ` . expectToMatchJsResult ( ) ;
82+ } ) ;
83+
84+ test ( "string" , ( ) => {
85+ util . testFunction `
86+ function* generator() {
87+ return yield* "abc";
88+ }
89+
90+ const it = generator();
91+ return [it.next(), it.next(), it.next(), it.next()];
92+ ` . expectToMatchJsResult ( ) ;
93+ } ) ;
94+
95+ test ( "iterable" , ( ) => {
96+ util . testFunction `
97+ function* generator() {
98+ return yield* new Set([1, 2, 3]);
99+ }
100+
101+ const it = generator();
102+ return [it.next(), it.next(), it.next(), it.next()];
103+ ` . expectToMatchJsResult ( ) ;
104+ } ) ;
105+ } ) ;
106+
54107test ( "function expression" , ( ) => {
55108 util . testFunction `
56109 const generator = function*() {
0 commit comments