Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36cd0bb
commit e401c35
Showing
29 changed files
with
199 additions
and
102 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
.../babel-plugin-transform-block-scoping/test/fixtures/general/assignment-patterns/output.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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
var foo = "foo"; | ||
function foobar() { | ||
for (var item of [1, 2, 3]) { | ||
var _foo = "bar"; | ||
[bar, _foo] = [1, 2]; | ||
var foo = "bar"; | ||
[bar, foo] = [1, 2]; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...lugin-transform-block-scoping/test/fixtures/general/closure-in-generator-or-async/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,36 @@ | ||
function* a() { | ||
do { | ||
let x = yield "iteration"; | ||
var fn = () => x; | ||
} while (false); | ||
return fn; | ||
} | ||
|
||
async function b() { | ||
do { | ||
let x = await "iteration"; | ||
var fn = () => x; | ||
} while (false); | ||
return fn; | ||
} | ||
|
||
async function* c() { | ||
do { | ||
let x = yield "iteration"; | ||
var fn = () => x; | ||
} while (false); | ||
return fn; | ||
} | ||
|
||
return (async () => { | ||
let it = a(); | ||
expect(it.next().value).toBe("iteration"); | ||
expect(it.next("foo").value()).toBe("foo"); | ||
|
||
expect((await b())()).toBe("iteration"); | ||
|
||
it = c(); | ||
expect((await it.next()).value).toBe("iteration"); | ||
expect((await it.next("foo")).value()).toBe("foo"); | ||
})(); | ||
|
23 changes: 23 additions & 0 deletions
23
...ugin-transform-block-scoping/test/fixtures/general/closure-in-generator-or-async/input.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,23 @@ | ||
function* a() { | ||
do { | ||
let x = yield "iteration"; | ||
var fn = () => x; | ||
} while (false); | ||
return fn; | ||
} | ||
|
||
async function b() { | ||
do { | ||
let x = await "iteration"; | ||
var fn = () => x; | ||
} while (false); | ||
return fn; | ||
} | ||
|
||
async function* c() { | ||
do { | ||
let x = yield "iteration"; | ||
var fn = () => x; | ||
} while (false); | ||
return fn; | ||
} |
5 changes: 5 additions & 0 deletions
5
...-transform-block-scoping/test/fixtures/general/closure-in-generator-or-async/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,5 @@ | ||
{ | ||
"parserOpts": { | ||
"allowReturnOutsideFunction": true | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...gin-transform-block-scoping/test/fixtures/general/closure-in-generator-or-async/output.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,39 @@ | ||
function* a() { | ||
var _loop = function* () { | ||
var x = yield "iteration"; | ||
fn = function () { | ||
return x; | ||
}; | ||
}; | ||
do { | ||
var fn; | ||
yield* _loop(); | ||
} while (false); | ||
return fn; | ||
} | ||
async function b() { | ||
var _loop2 = async function () { | ||
var x = await "iteration"; | ||
fn = function () { | ||
return x; | ||
}; | ||
}; | ||
do { | ||
var fn; | ||
await _loop2(); | ||
} while (false); | ||
return fn; | ||
} | ||
async function* c() { | ||
var _loop3 = async function* () { | ||
var x = yield "iteration"; | ||
fn = function () { | ||
return x; | ||
}; | ||
}; | ||
do { | ||
var fn; | ||
yield* _loop3(); | ||
} while (false); | ||
return fn; | ||
} |
22 changes: 11 additions & 11 deletions
22
...plugin-transform-block-scoping/test/fixtures/general/for-break-continue-closure/output.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 |
---|---|---|
@@ -1,21 +1,21 @@ | ||
for (var a of [1]) { | ||
var _loop = function () { | ||
switch (true) { | ||
case true: | ||
{ | ||
var _ret = function () { | ||
var b = 1; | ||
(function () { | ||
return b; | ||
}); | ||
if (true) return "break"; | ||
return "continue"; | ||
}(); | ||
if (_ret === "break") break; | ||
if (_ret === "continue") continue; | ||
var b = 1; | ||
(function () { | ||
return b; | ||
}); | ||
if (true) break; | ||
return "continue"; | ||
} | ||
case false: | ||
{ | ||
throw new Error("unreachable"); | ||
} | ||
} | ||
}; | ||
for (var a of [1]) { | ||
var _ret = _loop(); | ||
if (_ret === "continue") continue; | ||
} |
4 changes: 2 additions & 2 deletions
4
...es/babel-plugin-transform-block-scoping/test/fixtures/general/for-const-closure/output.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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
var _loop = function (i) { | ||
var _loop = function () { | ||
var l = i; | ||
setTimeout(function () { | ||
console.log(l); | ||
}, 1); | ||
}; | ||
for (var i = 0; i < 5; i++) { | ||
_loop(i); | ||
_loop(); | ||
} |
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
14 changes: 6 additions & 8 deletions
14
...abel-plugin-transform-block-scoping/test/fixtures/general/issue-10046-generator/output.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
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
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
21 changes: 11 additions & 10 deletions
21
packages/babel-plugin-transform-block-scoping/test/fixtures/general/issue-1051/output.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 |
---|---|---|
@@ -1,17 +1,18 @@ | ||
foo.func1 = function () { | ||
if (cond1) { | ||
for (;;) { | ||
var _loop = function () { | ||
if (cond2) { | ||
var _ret = function () { | ||
function func2() {} | ||
function func3() {} | ||
func4(function () { | ||
func2(); | ||
}); | ||
return "break"; | ||
}(); | ||
if (_ret === "break") break; | ||
var func2 = function () {}; | ||
var func3 = function () {}; | ||
func4(function () { | ||
func2(); | ||
}); | ||
return "break"; | ||
} | ||
}; | ||
for (;;) { | ||
var _ret = _loop(); | ||
if (_ret === "break") break; | ||
} | ||
} | ||
}; |
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
7 changes: 3 additions & 4 deletions
7
...el-plugin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-after/output.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
7 changes: 3 additions & 4 deletions
7
...gin-transform-block-scoping/test/fixtures/general/issue-8128-for-of-loose-after/output.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
4 changes: 2 additions & 2 deletions
4
packages/babel-plugin-transform-block-scoping/test/fixtures/general/issue-973/output.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
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
32 changes: 16 additions & 16 deletions
32
packages/babel-plugin-transform-block-scoping/test/fixtures/general/superswitch/output.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 |
---|---|---|
@@ -1,24 +1,24 @@ | ||
function foo() { | ||
while (true) { | ||
var _loop = function () { | ||
switch (2) { | ||
case 0: | ||
{ | ||
var _ret = function () { | ||
if (true) { | ||
return { | ||
v: void 0 | ||
}; | ||
} | ||
var stuff = new Map(); | ||
var data = 0; | ||
stuff.forEach(function () { | ||
var d = data; | ||
}); | ||
return "break"; | ||
}(); | ||
if (_ret === "break") break; | ||
if (typeof _ret === "object") return _ret.v; | ||
if (true) { | ||
return { | ||
v: void 0 | ||
}; | ||
} | ||
var stuff = new Map(); | ||
var data = 0; | ||
stuff.forEach(function () { | ||
var d = data; | ||
}); | ||
break; | ||
} | ||
} | ||
}; | ||
while (true) { | ||
var _ret = _loop(); | ||
if (typeof _ret === "object") return _ret.v; | ||
} | ||
} |
Oops, something went wrong.