From 52d4d73f0bc6f8786a6d063121708a9d43b58c81 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sun, 12 Oct 2014 16:18:18 +1100 Subject: [PATCH] remove block binding because the current implementation is flaky and will have to be rewritten from scratch without the issue of wrapping functions --- README.md | 4 +- lib/6to5/transformers/block-binding.js | 145 ------------------ test/fixtures/bin/6to5/--blacklist/stdin.txt | 1 - test/fixtures/bin/6to5/--blacklist/stdout.txt | 5 +- .../syntax/block-binding/arguments/actual.js | 6 - .../block-binding/arguments/expected.js | 9 -- .../block-multiple-let-inside/actual.js | 5 - .../block-multiple-let-inside/expected.js | 7 - .../block-single-let-inside/actual.js | 4 - .../block-single-let-inside/expected.js | 6 - .../closure-ignore-children/actual.js | 4 - .../closure-ignore-children/expected.js | 4 - .../for-in-break-multiple/actual.js | 10 -- .../for-in-break-multiple/expected.js | 16 -- .../block-binding/for-in-break/actual.js | 5 - .../block-binding/for-in-break/expected.js | 12 -- .../block-binding/for-in-continue/actual.js | 5 - .../block-binding/for-in-continue/expected.js | 9 -- .../block-binding/for-in-multiple/actual.js | 9 -- .../block-binding/for-in-multiple/expected.js | 12 -- .../syntax/block-binding/for-in/actual.js | 4 - .../syntax/block-binding/for-in/expected.js | 8 - .../syntax/block-binding/for/actual.js | 3 - .../syntax/block-binding/for/expected.js | 5 - .../block-binding/hoist-multiple/actual.js | 2 - .../block-binding/hoist-multiple/expected.js | 6 - .../syntax/block-binding/hoist/actual.js | 2 - .../syntax/block-binding/hoist/expected.js | 5 - .../syntax/block-binding/labels/actual.js | 4 - .../syntax/block-binding/labels/options.json | 3 - .../syntax/block-binding/program/actual.js | 1 - .../syntax/block-binding/program/expected.js | 7 - .../return-ignore-siblings/actual.js | 6 - .../return-ignore-siblings/expected.js | 8 - .../syntax/block-binding/return/actual.js | 16 -- .../syntax/block-binding/return/expected.js | 14 -- .../syntax/block-binding/this-usage/actual.js | 5 - .../block-binding/this-usage/expected.js | 13 -- .../constants/block-statement/expected.js | 12 +- .../constants/destructuring/expected.js | 38 +++-- .../syntax/constants/program/expected.js | 12 +- test/fixtures/syntax/for-of/let/expected.js | 8 +- .../modules/exports-variable/expected.js | 47 +++--- 43 files changed, 54 insertions(+), 453 deletions(-) delete mode 100644 test/fixtures/syntax/block-binding/arguments/actual.js delete mode 100644 test/fixtures/syntax/block-binding/arguments/expected.js delete mode 100644 test/fixtures/syntax/block-binding/block-multiple-let-inside/actual.js delete mode 100644 test/fixtures/syntax/block-binding/block-multiple-let-inside/expected.js delete mode 100644 test/fixtures/syntax/block-binding/block-single-let-inside/actual.js delete mode 100644 test/fixtures/syntax/block-binding/block-single-let-inside/expected.js delete mode 100644 test/fixtures/syntax/block-binding/closure-ignore-children/actual.js delete mode 100644 test/fixtures/syntax/block-binding/closure-ignore-children/expected.js delete mode 100644 test/fixtures/syntax/block-binding/for-in-break-multiple/actual.js delete mode 100644 test/fixtures/syntax/block-binding/for-in-break-multiple/expected.js delete mode 100644 test/fixtures/syntax/block-binding/for-in-break/actual.js delete mode 100644 test/fixtures/syntax/block-binding/for-in-break/expected.js delete mode 100644 test/fixtures/syntax/block-binding/for-in-continue/actual.js delete mode 100644 test/fixtures/syntax/block-binding/for-in-continue/expected.js delete mode 100644 test/fixtures/syntax/block-binding/for-in-multiple/actual.js delete mode 100644 test/fixtures/syntax/block-binding/for-in-multiple/expected.js delete mode 100644 test/fixtures/syntax/block-binding/for-in/actual.js delete mode 100644 test/fixtures/syntax/block-binding/for-in/expected.js delete mode 100644 test/fixtures/syntax/block-binding/for/actual.js delete mode 100644 test/fixtures/syntax/block-binding/for/expected.js delete mode 100644 test/fixtures/syntax/block-binding/hoist-multiple/actual.js delete mode 100644 test/fixtures/syntax/block-binding/hoist-multiple/expected.js delete mode 100644 test/fixtures/syntax/block-binding/hoist/actual.js delete mode 100644 test/fixtures/syntax/block-binding/hoist/expected.js delete mode 100644 test/fixtures/syntax/block-binding/labels/actual.js delete mode 100644 test/fixtures/syntax/block-binding/labels/options.json delete mode 100644 test/fixtures/syntax/block-binding/program/actual.js delete mode 100644 test/fixtures/syntax/block-binding/program/expected.js delete mode 100644 test/fixtures/syntax/block-binding/return-ignore-siblings/actual.js delete mode 100644 test/fixtures/syntax/block-binding/return-ignore-siblings/expected.js delete mode 100644 test/fixtures/syntax/block-binding/return/actual.js delete mode 100644 test/fixtures/syntax/block-binding/return/expected.js delete mode 100644 test/fixtures/syntax/block-binding/this-usage/actual.js delete mode 100644 test/fixtures/syntax/block-binding/this-usage/expected.js diff --git a/README.md b/README.md index 78e6096055..02cb73634e 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,6 @@ It's as easy as: - [Array comprehension](FEATURES.md#array-comprehension) - [Arrow functions](FEATURES.md#arrow-functions) - - [Block binding](FEATURES.md#block-binding) - [Classes](FEATURES.md#classes) - [Computed property names](FEATURES.md#computed-property-names) - [Constants](FEATURES.md#constants) @@ -67,6 +66,7 @@ It's as easy as: To be implemented: + - [Block binding](FEATURES.md#block-binding) - [Generators](FEATURES.md#generators) ## Usage @@ -340,7 +340,7 @@ better suited if you'd like a full ES6 environment with polyfills and all. | Source maps | ✓ | ✓ | ✓ | | ✓ | ✓ | | No compiler global pollution | ✓ | | ✓ | | ✓ | ✓ | | Arrow functions | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| Block binding | ✓ | ✓ | | | ✓ | | +| Block binding | | ✓ | | | ✓ | | | Classes | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | Computed property names | ✓ | ✓ | ✓ | ✓ | ✓ | | | Constants | ✓ | ✓ | | | ✓ | | diff --git a/lib/6to5/transformers/block-binding.js b/lib/6to5/transformers/block-binding.js index 4467cca308..e69de29bb2 100644 --- a/lib/6to5/transformers/block-binding.js +++ b/lib/6to5/transformers/block-binding.js @@ -1,145 +0,0 @@ -var traverse = require("../traverse"); -var util = require("../util"); -var b = require("ast-types").builders; -var _ = require("lodash"); - -var blockTypes = traverse.FUNCTION_TYPES.concat(["BlockStatement"]); - -var isLet = function (node) { - if (node && node.type === "VariableDeclaration" && node.kind === "let") { - node.kind = "var"; - node._ignoreBlockBindingHoist = true; - return true; - } -}; - -var hasLet = function (nodes) { - var has = false; - - _.each(nodes, function (node) { - if (isLet(node)) has = true; - }); - - return has; -}; - -exports.Program = function (node, parent, opts, generateUid) { - if (hasLet(node.body)) node.body = buildNode(node.body, generateUid).node; -}; - -exports.BlockStatement = function (node, parent, opts, generateUid) { - if (!hasLet(node.body)) return; - - // ignore if we're the body of a closure already - if (_.contains(traverse.FUNCTION_TYPES, parent.type)) return; - - var body = node.body; - - var built = buildNode(node.body, generateUid); - node.body = built.node; - - traverse(built.body, function (node) { - if (node.type === "ContinueStatement") { - return b.returnStatement(null); - } - }, blockTypes); - - if (traverse.hasType(body, "BreakStatement", blockTypes)) { - var id = b.identifier(generateUid("break")); - - node.body.unshift(b.variableDeclaration("var", [ - b.variableDeclarator(id, b.literal(false)) - ])); - - traverse(built.body, function (node) { - if (node.type === "BreakStatement") { - return b.returnStatement(b.assignmentExpression("=", id, b.literal(true))); - } - }, blockTypes); - - node.body.push(b.ifStatement(id, b.breakStatement())); - } -}; - -var buildForStatement = function (key) { - return function (node, parent, opts, generateUid) { - if (isLet(node[key])) { - if (parent.type === "LabeledStatement") { - throw util.errorWithNode(parent, "Label statements not supported with block binding yet."); - } - - return buildNode(node, generateUid).node; - } - }; -}; - -exports.ForOfStatement = exports.ForInStatement = buildForStatement("left"); -exports.ForStatement = buildForStatement("init"); - -var buildNode = function (node, generateUid) { - var nodes = []; - - // hoist normal variable declarations - - node = [].concat(node); - node = node.map(function (node) { - if (node._ignoreBlockBindingHoist) return node; - - if (node.type === "VariableDeclaration" && node.kind === "var") { - var declars = node.declarations.map(function (declar) { - return b.variableDeclarator(declar.id, null); - }); - - nodes.push(b.variableDeclaration("var", declars)); - - return _.compact(node.declarations.map(function (declar) { - if (!declar.init) return; - - return util.template("assign", { - VALUE: declar.init, - KEY: declar.id - }, true); - })); - } else if (node.type === "ForInStatement" && node.left.type === "VariableDeclaration" && !node.left._ignoreBlockBindingHoist) { - var id = node.left.declarations[0].id; - node.left = id; - nodes.push(util.template("variable-declare", { - KEY: id - })); - } - - return node; - }); - - // - - var argumentsId = util.aliasArguments(generateUid, node); - - if (argumentsId) { - nodes.push(b.variableDeclaration("var", [ - b.variableDeclarator(argumentsId, b.identifier("arguments")) - ])); - } - - // - - var block = b.blockStatement([]); - block.body = node; - - var func = b.functionExpression(null, [], block, false); - - // - - var templateName = "function-call"; - if (traverse.hasType(node, "ThisExpression")) templateName += "-this"; - if (traverse.hasType(node, "ReturnStatement", traverse.FUNCTION_TYPES)) templateName += "-return"; - - nodes.push(util.template(templateName, { - FUNCTION: func - }, true)); - - return { - node: nodes, - body: block - }; -}; diff --git a/test/fixtures/bin/6to5/--blacklist/stdin.txt b/test/fixtures/bin/6to5/--blacklist/stdin.txt index 030f13f9fa..4bc9539528 100644 --- a/test/fixtures/bin/6to5/--blacklist/stdin.txt +++ b/test/fixtures/bin/6to5/--blacklist/stdin.txt @@ -1,2 +1 @@ -let MULTIPLER = 5; arr.map(x => x * MULTIPLIER); diff --git a/test/fixtures/bin/6to5/--blacklist/stdout.txt b/test/fixtures/bin/6to5/--blacklist/stdout.txt index 386cf5664a..4bc9539528 100644 --- a/test/fixtures/bin/6to5/--blacklist/stdout.txt +++ b/test/fixtures/bin/6to5/--blacklist/stdout.txt @@ -1,4 +1 @@ -(function() { - var MULTIPLER = 5; - arr.map(x => x * MULTIPLIER); -})(); +arr.map(x => x * MULTIPLIER); diff --git a/test/fixtures/syntax/block-binding/arguments/actual.js b/test/fixtures/syntax/block-binding/arguments/actual.js deleted file mode 100644 index 0661a55078..0000000000 --- a/test/fixtures/syntax/block-binding/arguments/actual.js +++ /dev/null @@ -1,6 +0,0 @@ -(function () { - if (true) { - let a = arguments[0]; - console.log(a); - } -})(1); diff --git a/test/fixtures/syntax/block-binding/arguments/expected.js b/test/fixtures/syntax/block-binding/arguments/expected.js deleted file mode 100644 index 826ea547e3..0000000000 --- a/test/fixtures/syntax/block-binding/arguments/expected.js +++ /dev/null @@ -1,9 +0,0 @@ -(function () { - if (true) { - var _arguments = arguments; - (function () { - var a = _arguments[0]; - console.log(a); - })(); - } -})(1); diff --git a/test/fixtures/syntax/block-binding/block-multiple-let-inside/actual.js b/test/fixtures/syntax/block-binding/block-multiple-let-inside/actual.js deleted file mode 100644 index 46448a3743..0000000000 --- a/test/fixtures/syntax/block-binding/block-multiple-let-inside/actual.js +++ /dev/null @@ -1,5 +0,0 @@ -{ - let val = 1; - let multiplier = 5; - console.log(val * multiplier); -} diff --git a/test/fixtures/syntax/block-binding/block-multiple-let-inside/expected.js b/test/fixtures/syntax/block-binding/block-multiple-let-inside/expected.js deleted file mode 100644 index 1edebe0070..0000000000 --- a/test/fixtures/syntax/block-binding/block-multiple-let-inside/expected.js +++ /dev/null @@ -1,7 +0,0 @@ -{ - (function () { - var val = 1; - var multiplier = 5; - console.log(val * multiplier); - }()); -} diff --git a/test/fixtures/syntax/block-binding/block-single-let-inside/actual.js b/test/fixtures/syntax/block-binding/block-single-let-inside/actual.js deleted file mode 100644 index 25951533e5..0000000000 --- a/test/fixtures/syntax/block-binding/block-single-let-inside/actual.js +++ /dev/null @@ -1,4 +0,0 @@ -{ - let val = 1; - console.log(val * 2); -} diff --git a/test/fixtures/syntax/block-binding/block-single-let-inside/expected.js b/test/fixtures/syntax/block-binding/block-single-let-inside/expected.js deleted file mode 100644 index 262b3401e1..0000000000 --- a/test/fixtures/syntax/block-binding/block-single-let-inside/expected.js +++ /dev/null @@ -1,6 +0,0 @@ -{ - (function () { - var val = 1; - console.log(val * 2); - }()); -} diff --git a/test/fixtures/syntax/block-binding/closure-ignore-children/actual.js b/test/fixtures/syntax/block-binding/closure-ignore-children/actual.js deleted file mode 100644 index 52b0faf62e..0000000000 --- a/test/fixtures/syntax/block-binding/closure-ignore-children/actual.js +++ /dev/null @@ -1,4 +0,0 @@ -(function () { - let i = 5; - console.log(i); -}()); diff --git a/test/fixtures/syntax/block-binding/closure-ignore-children/expected.js b/test/fixtures/syntax/block-binding/closure-ignore-children/expected.js deleted file mode 100644 index 8070f8da35..0000000000 --- a/test/fixtures/syntax/block-binding/closure-ignore-children/expected.js +++ /dev/null @@ -1,4 +0,0 @@ -(function () { - var i = 5; - console.log(i); -}()); diff --git a/test/fixtures/syntax/block-binding/for-in-break-multiple/actual.js b/test/fixtures/syntax/block-binding/for-in-break-multiple/actual.js deleted file mode 100644 index 0c9ac188ee..0000000000 --- a/test/fixtures/syntax/block-binding/for-in-break-multiple/actual.js +++ /dev/null @@ -1,10 +0,0 @@ -for (var i in arr) { - let val = arr[i]; - - for (i in arr) { - let val2 = arr[i]; - break; - } - - break; -} diff --git a/test/fixtures/syntax/block-binding/for-in-break-multiple/expected.js b/test/fixtures/syntax/block-binding/for-in-break-multiple/expected.js deleted file mode 100644 index 6b78a8ad6b..0000000000 --- a/test/fixtures/syntax/block-binding/for-in-break-multiple/expected.js +++ /dev/null @@ -1,16 +0,0 @@ -for (var i in arr) { - var _break = false; - (function () { - var val = arr[i]; - for (i in arr) { - var _break2 = false; - (function () { - var val2 = arr[i]; - return _break2 = true; - }()); - if (_break2) break; - } - return _break = true; - }()); - if (_break) break; -} diff --git a/test/fixtures/syntax/block-binding/for-in-break/actual.js b/test/fixtures/syntax/block-binding/for-in-break/actual.js deleted file mode 100644 index fb28aa3109..0000000000 --- a/test/fixtures/syntax/block-binding/for-in-break/actual.js +++ /dev/null @@ -1,5 +0,0 @@ -for (let i in arr) { - let val = arr[i]; - console.log(val * 2); - break; -} diff --git a/test/fixtures/syntax/block-binding/for-in-break/expected.js b/test/fixtures/syntax/block-binding/for-in-break/expected.js deleted file mode 100644 index 9a0e8bc03b..0000000000 --- a/test/fixtures/syntax/block-binding/for-in-break/expected.js +++ /dev/null @@ -1,12 +0,0 @@ - -(function () { - for (var i in arr) { - var _break = false; - (function () { - var val = arr[i]; - console.log(val * 2); - return _break = true; - }()); - if (_break) break; - } -}()); diff --git a/test/fixtures/syntax/block-binding/for-in-continue/actual.js b/test/fixtures/syntax/block-binding/for-in-continue/actual.js deleted file mode 100644 index 3951978153..0000000000 --- a/test/fixtures/syntax/block-binding/for-in-continue/actual.js +++ /dev/null @@ -1,5 +0,0 @@ -for (let i in arr) { - let val = arr[i]; - console.log(val * 2); - continue; -} diff --git a/test/fixtures/syntax/block-binding/for-in-continue/expected.js b/test/fixtures/syntax/block-binding/for-in-continue/expected.js deleted file mode 100644 index 26a4c89000..0000000000 --- a/test/fixtures/syntax/block-binding/for-in-continue/expected.js +++ /dev/null @@ -1,9 +0,0 @@ -(function () { - for (var i in arr) { - (function () { - var val = arr[i]; - console.log(val * 2); - return; - }()); - } -}()); diff --git a/test/fixtures/syntax/block-binding/for-in-multiple/actual.js b/test/fixtures/syntax/block-binding/for-in-multiple/actual.js deleted file mode 100644 index 9d15042c0c..0000000000 --- a/test/fixtures/syntax/block-binding/for-in-multiple/actual.js +++ /dev/null @@ -1,9 +0,0 @@ -for (var i in arr) { - let val = arr[i]; - console.log(val * 2); - - for (i in arr) { - let x = arr[i]; - console.log(x * 2); - } -} diff --git a/test/fixtures/syntax/block-binding/for-in-multiple/expected.js b/test/fixtures/syntax/block-binding/for-in-multiple/expected.js deleted file mode 100644 index de1e630fd2..0000000000 --- a/test/fixtures/syntax/block-binding/for-in-multiple/expected.js +++ /dev/null @@ -1,12 +0,0 @@ -for (var i in arr) { - (function () { - var val = arr[i]; - console.log(val * 2); - for (i in arr) { - (function () { - var x = arr[i]; - console.log(x * 2); - }()); - } - }()); -} diff --git a/test/fixtures/syntax/block-binding/for-in/actual.js b/test/fixtures/syntax/block-binding/for-in/actual.js deleted file mode 100644 index b03a71fbc8..0000000000 --- a/test/fixtures/syntax/block-binding/for-in/actual.js +++ /dev/null @@ -1,4 +0,0 @@ -for (let i in arr) { - let val = arr[i]; - console.log(val * 2); -} diff --git a/test/fixtures/syntax/block-binding/for-in/expected.js b/test/fixtures/syntax/block-binding/for-in/expected.js deleted file mode 100644 index 8460525f6a..0000000000 --- a/test/fixtures/syntax/block-binding/for-in/expected.js +++ /dev/null @@ -1,8 +0,0 @@ -(function () { - for (var i in arr) { - (function () { - var val = arr[i]; - console.log(val * 2); - }()); - } -}()); diff --git a/test/fixtures/syntax/block-binding/for/actual.js b/test/fixtures/syntax/block-binding/for/actual.js deleted file mode 100644 index 071195d953..0000000000 --- a/test/fixtures/syntax/block-binding/for/actual.js +++ /dev/null @@ -1,3 +0,0 @@ -for (let i = 0; i < 9; i++) { - console.log(i); -} diff --git a/test/fixtures/syntax/block-binding/for/expected.js b/test/fixtures/syntax/block-binding/for/expected.js deleted file mode 100644 index 142d1ea6dc..0000000000 --- a/test/fixtures/syntax/block-binding/for/expected.js +++ /dev/null @@ -1,5 +0,0 @@ -(function () { - for (var i = 0; i < 9; i++) { - console.log(i); - } -}()); diff --git a/test/fixtures/syntax/block-binding/hoist-multiple/actual.js b/test/fixtures/syntax/block-binding/hoist-multiple/actual.js deleted file mode 100644 index 7a036ab60b..0000000000 --- a/test/fixtures/syntax/block-binding/hoist-multiple/actual.js +++ /dev/null @@ -1,2 +0,0 @@ -let MULTIPLIER = 5; -var foo = "bar", bar = "foo"; diff --git a/test/fixtures/syntax/block-binding/hoist-multiple/expected.js b/test/fixtures/syntax/block-binding/hoist-multiple/expected.js deleted file mode 100644 index 8a6023042b..0000000000 --- a/test/fixtures/syntax/block-binding/hoist-multiple/expected.js +++ /dev/null @@ -1,6 +0,0 @@ -var foo, bar; -(function () { - var MULTIPLIER = 5; - foo = "bar"; - bar = "foo"; -})(); diff --git a/test/fixtures/syntax/block-binding/hoist/actual.js b/test/fixtures/syntax/block-binding/hoist/actual.js deleted file mode 100644 index 6fb20a8759..0000000000 --- a/test/fixtures/syntax/block-binding/hoist/actual.js +++ /dev/null @@ -1,2 +0,0 @@ -let MULTIPLIER = 5; -var foo = "bar"; diff --git a/test/fixtures/syntax/block-binding/hoist/expected.js b/test/fixtures/syntax/block-binding/hoist/expected.js deleted file mode 100644 index 87197e5dc3..0000000000 --- a/test/fixtures/syntax/block-binding/hoist/expected.js +++ /dev/null @@ -1,5 +0,0 @@ -var foo; -(function () { - var MULTIPLIER = 5; - foo = "bar"; -})(); diff --git a/test/fixtures/syntax/block-binding/labels/actual.js b/test/fixtures/syntax/block-binding/labels/actual.js deleted file mode 100644 index fa1996e13c..0000000000 --- a/test/fixtures/syntax/block-binding/labels/actual.js +++ /dev/null @@ -1,4 +0,0 @@ -test: -for (let i in test) { - -} diff --git a/test/fixtures/syntax/block-binding/labels/options.json b/test/fixtures/syntax/block-binding/labels/options.json deleted file mode 100644 index c76faa3c4b..0000000000 --- a/test/fixtures/syntax/block-binding/labels/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Label statements not supported with block binding yet." -} diff --git a/test/fixtures/syntax/block-binding/program/actual.js b/test/fixtures/syntax/block-binding/program/actual.js deleted file mode 100644 index b669f730d2..0000000000 --- a/test/fixtures/syntax/block-binding/program/actual.js +++ /dev/null @@ -1 +0,0 @@ -let arr = [1, 2, 3]; diff --git a/test/fixtures/syntax/block-binding/program/expected.js b/test/fixtures/syntax/block-binding/program/expected.js deleted file mode 100644 index 593f2c31b6..0000000000 --- a/test/fixtures/syntax/block-binding/program/expected.js +++ /dev/null @@ -1,7 +0,0 @@ -(function () { - var arr = [ - 1, - 2, - 3 - ]; -})(); diff --git a/test/fixtures/syntax/block-binding/return-ignore-siblings/actual.js b/test/fixtures/syntax/block-binding/return-ignore-siblings/actual.js deleted file mode 100644 index ac8d9a28f1..0000000000 --- a/test/fixtures/syntax/block-binding/return-ignore-siblings/actual.js +++ /dev/null @@ -1,6 +0,0 @@ -let _message = message(); -console.log( _message ); - -function message () { - return 'hello'; -} diff --git a/test/fixtures/syntax/block-binding/return-ignore-siblings/expected.js b/test/fixtures/syntax/block-binding/return-ignore-siblings/expected.js deleted file mode 100644 index 3598b1a684..0000000000 --- a/test/fixtures/syntax/block-binding/return-ignore-siblings/expected.js +++ /dev/null @@ -1,8 +0,0 @@ -(function () { - var _message = message(); - console.log(_message); - - function message () { - return 'hello'; - } -})(); diff --git a/test/fixtures/syntax/block-binding/return/actual.js b/test/fixtures/syntax/block-binding/return/actual.js deleted file mode 100644 index 1974a42dec..0000000000 --- a/test/fixtures/syntax/block-binding/return/actual.js +++ /dev/null @@ -1,16 +0,0 @@ -function student () { - let isStudent = true; - return Object.freeze({ - isStudent - }); -} - -function student () { - let isStudent = true; - while (true) { - let test = "foo"; - return Object.freeze({ - isStudent - }); - } -} diff --git a/test/fixtures/syntax/block-binding/return/expected.js b/test/fixtures/syntax/block-binding/return/expected.js deleted file mode 100644 index fb2e343ae4..0000000000 --- a/test/fixtures/syntax/block-binding/return/expected.js +++ /dev/null @@ -1,14 +0,0 @@ -function student() { - var isStudent = true; - return Object.freeze({ isStudent: isStudent }); -} - -function student() { - var isStudent = true; - while (true) { - return function () { - var test = 'foo'; - return Object.freeze({ isStudent: isStudent }); - }(); - } -} diff --git a/test/fixtures/syntax/block-binding/this-usage/actual.js b/test/fixtures/syntax/block-binding/this-usage/actual.js deleted file mode 100644 index 11689687b0..0000000000 --- a/test/fixtures/syntax/block-binding/this-usage/actual.js +++ /dev/null @@ -1,5 +0,0 @@ -var arr = [1, 2, 3]; -for (let i in arr) { - let val = arr[i]; - console.log(val * this.multiplier); -} diff --git a/test/fixtures/syntax/block-binding/this-usage/expected.js b/test/fixtures/syntax/block-binding/this-usage/expected.js deleted file mode 100644 index 9b5a790d5a..0000000000 --- a/test/fixtures/syntax/block-binding/this-usage/expected.js +++ /dev/null @@ -1,13 +0,0 @@ -var arr = [ - 1, - 2, - 3 -]; -(function () { - for (var i in arr) { - (function () { - var val = arr[i]; - console.log(val * this.multiplier); - }.call(this)); - } -}.call(this)); diff --git a/test/fixtures/syntax/constants/block-statement/expected.js b/test/fixtures/syntax/constants/block-statement/expected.js index 31d62981de..551349fa3b 100644 --- a/test/fixtures/syntax/constants/block-statement/expected.js +++ b/test/fixtures/syntax/constants/block-statement/expected.js @@ -1,8 +1,4 @@ -(function () { - for (var i in arr) { - (function () { - var MULTIPLIER = 5; - console.log(arr[i] * MULTIPLIER); - }()); - } -}()); +for (let i in arr) { + let MULTIPLIER = 5; + console.log(arr[i] * MULTIPLIER); +} diff --git a/test/fixtures/syntax/constants/destructuring/expected.js b/test/fixtures/syntax/constants/destructuring/expected.js index 3e5d42e210..350ef2cf1a 100644 --- a/test/fixtures/syntax/constants/destructuring/expected.js +++ b/test/fixtures/syntax/constants/destructuring/expected.js @@ -1,23 +1,21 @@ -(function () { - var _ref = [1, 2]; - var a = _ref[0]; - var b = _ref[1]; +var _ref = [1, 2]; +let a = _ref[0]; +let b = _ref[1]; - var _ref2 = [3, 4]; - var c = _ref2[0]; - var d = _ref2[1]; +var _ref2 = [3, 4]; +let c = _ref2[0]; +let d = _ref2[1]; - var _ref3 = { - e: 5, - f: 6 - }; - var e = _ref3.e; - var f = _ref3.f; +var _ref3 = { + e: 5, + f: 6 +}; +let e = _ref3.e; +let f = _ref3.f; - var _ref4 = { - a: 7, - b: 8 - }; - var g = _ref4.a; - var h = _ref4.b; -})(); +var _ref4 = { + a: 7, + b: 8 +}; +let g = _ref4.a; +let h = _ref4.b; diff --git a/test/fixtures/syntax/constants/program/expected.js b/test/fixtures/syntax/constants/program/expected.js index e3c52ab40f..7b8fde94e5 100644 --- a/test/fixtures/syntax/constants/program/expected.js +++ b/test/fixtures/syntax/constants/program/expected.js @@ -1,7 +1,5 @@ -var i; -(function () { - var MULTIPLIER = 5; - for (i in arr) { - console.log(arr[i] * MULTIPLIER); - } -}()); +let MULTIPLIER = 5; + +for (var i in arr) { + console.log(arr[i] * MULTIPLIER); +} diff --git a/test/fixtures/syntax/for-of/let/expected.js b/test/fixtures/syntax/for-of/let/expected.js index ee144f6932..914c1a2ec2 100644 --- a/test/fixtures/syntax/for-of/let/expected.js +++ b/test/fixtures/syntax/for-of/let/expected.js @@ -1,5 +1,3 @@ -(function () { - for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { - var i = _step.value; - } -}()); +for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + let i = _step.value; +} diff --git a/test/fixtures/syntax/modules/exports-variable/expected.js b/test/fixtures/syntax/modules/exports-variable/expected.js index ed5e8ee4b6..fad2fb03e0 100644 --- a/test/fixtures/syntax/modules/exports-variable/expected.js +++ b/test/fixtures/syntax/modules/exports-variable/expected.js @@ -1,32 +1,27 @@ -var foo; -var foo2; +exports.foo7 = foo7; + +var foo = 1; +exports.foo = foo; + +var foo2 = function () {}; +exports.foo2 = foo2; + var foo3; -var foo8; -(function () { - exports.foo7 = foo7; +exports.foo3 = foo3; - foo = 1; - exports.foo = foo; +let foo4 = 2; +exports.foo4 = foo4; - foo2 = function () {}; - exports.foo2 = foo2; +let foo5; +exports.foo5 = foo5; - exports.foo3 = foo3; +let foo6 = 3; +exports.foo6 = foo6; - var foo4 = 2; - exports.foo4 = foo4; +function foo7 () {} - var foo5; - exports.foo5 = foo5; - - var foo6 = 3; - exports.foo6 = foo6; - - function foo7 () {} - - foo8 = function () { - var foo8 = function foo8() {}; - return foo8; - }(); - exports.foo8 = foo8; -}()); +var foo8 = function () { + var foo8 = function foo8() {}; + return foo8; +}(); +exports.foo8 = foo8;