forked from babel/babel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from lightmare/generator-literals
flattening tail spread recursion
- Loading branch information
Showing
8 changed files
with
108 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
packages/babel-plugin-proposal-generator-literals/test/fixtures/async/options.json
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
packages/babel-plugin-proposal-generator-literals/test/fixtures/basic/options.json
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
...ages/babel-plugin-proposal-generator-literals/test/fixtures/infinite-multi-spread/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const fiveZeros = *[0, 0, 0, 0, 0]; | ||
const fiveNonZeros = *[1, 2, 3, 4, 5]; | ||
|
||
let inf0, inf15; | ||
inf0 = *[...fiveZeros, ...inf15]; | ||
inf15 = *[...fiveNonZeros, ...inf0]; | ||
|
||
let count = 666002; | ||
let target = 999003; | ||
let sum = 0; | ||
|
||
for (const x of inf15) { | ||
if (--count < 0) break; | ||
sum += x; | ||
} | ||
|
||
expect(sum).toBe(target); |
14 changes: 14 additions & 0 deletions
14
packages/babel-plugin-proposal-generator-literals/test/fixtures/infinite-sum/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
let zeroOne, oneZero; | ||
zeroOne = *[0, ...oneZero]; | ||
oneZero = *[1, ...zeroOne]; | ||
|
||
let count = 128000; | ||
let target = 64000; | ||
let sum = 0; | ||
|
||
for (const x of oneZero) { | ||
if (--count < 0) break; | ||
sum += x; | ||
} | ||
|
||
expect(sum).toBe(target); |
3 changes: 0 additions & 3 deletions
3
packages/babel-plugin-proposal-generator-literals/test/fixtures/infinite/options.json
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
packages/babel-plugin-proposal-generator-literals/test/fixtures/lexical-this/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
let ob = { | ||
bar: 'A', | ||
foo() { | ||
return *['B', this.bar, 'R']; | ||
} | ||
} | ||
|
||
expect(Array.from(ob.foo())).toStrictEqual(['B', 'A', 'R']); | ||
|
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-proposal-generator-literals/test/fixtures/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": ["proposal-generator-literals"] | ||
} |