enhance join_vars (#5739)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
require("../tools/tty");
|
||||
var createHash = require("crypto").createHash;
|
||||
var fetch = require("./fetch");
|
||||
var spawn = require("child_process").spawn;
|
||||
|
||||
@@ -1130,6 +1130,130 @@ default_init: {
|
||||
node_version: ">=4"
|
||||
}
|
||||
|
||||
join_let_var_1: {
|
||||
options = {
|
||||
join_vars: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
"use strict";
|
||||
var a = "foo";
|
||||
let b = "bar";
|
||||
for (var c of [ a, b ])
|
||||
console.log(c);
|
||||
}
|
||||
expect: {
|
||||
"use strict";
|
||||
let a = "foo", b = "bar";
|
||||
for (var c of [ a, b ])
|
||||
console.log(c);
|
||||
}
|
||||
expect_stdout: [
|
||||
"foo",
|
||||
"bar",
|
||||
]
|
||||
node_version: ">=4"
|
||||
}
|
||||
|
||||
join_let_var_2: {
|
||||
options = {
|
||||
join_vars: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
"use strict";
|
||||
let a = "foo";
|
||||
var b = "bar";
|
||||
for (let c of [ a, b ])
|
||||
console.log(c);
|
||||
}
|
||||
expect: {
|
||||
"use strict";
|
||||
let a = "foo", b = "bar";
|
||||
for (let c of [ a, b ])
|
||||
console.log(c);
|
||||
}
|
||||
expect_stdout: [
|
||||
"foo",
|
||||
"bar",
|
||||
]
|
||||
node_version: ">=4"
|
||||
}
|
||||
|
||||
keep_let_var_1: {
|
||||
options = {
|
||||
join_vars: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
"use strict";
|
||||
var a = "foo";
|
||||
let b = "bar";
|
||||
for (var c of [ a, b ])
|
||||
console.log(c);
|
||||
function f() {
|
||||
return a;
|
||||
}
|
||||
console.log(f(f));
|
||||
}
|
||||
expect: {
|
||||
"use strict";
|
||||
var a = "foo", c;
|
||||
let b = "bar";
|
||||
for (c of [ a, b ])
|
||||
console.log(c);
|
||||
function f() {
|
||||
return a;
|
||||
}
|
||||
console.log(f(f));
|
||||
}
|
||||
expect_stdout: [
|
||||
"foo",
|
||||
"bar",
|
||||
"foo",
|
||||
]
|
||||
node_version: ">=4"
|
||||
}
|
||||
|
||||
keep_let_var_2: {
|
||||
options = {
|
||||
join_vars: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
"use strict";
|
||||
let a = "foo";
|
||||
var b = "bar";
|
||||
for (let c of [ a, b ])
|
||||
console.log(c);
|
||||
function f() {
|
||||
return b;
|
||||
}
|
||||
console.log(f(f));
|
||||
}
|
||||
expect: {
|
||||
"use strict";
|
||||
let a = "foo";
|
||||
var b = "bar";
|
||||
for (let c of [ a, b ])
|
||||
console.log(c);
|
||||
function f() {
|
||||
return b;
|
||||
}
|
||||
console.log(f(f));
|
||||
}
|
||||
expect_stdout: [
|
||||
"foo",
|
||||
"bar",
|
||||
"bar",
|
||||
]
|
||||
node_version: ">=4"
|
||||
}
|
||||
|
||||
issue_4191: {
|
||||
options = {
|
||||
functions: true,
|
||||
|
||||
@@ -41,6 +41,11 @@ rm -rf tmp/buble \
|
||||
@@ -309 +309 @@ export default class BlockStatement extends Node {
|
||||
- let cont = false; // TODO implement proper continue...
|
||||
+ let cont = !declarations; // TODO implement proper continue...
|
||||
--- a/src/program/types/VariableDeclaration.js
|
||||
+++ b/src/program/types/VariableDeclaration.js
|
||||
@@ -38 +38 @@ export default class VariableDeclaration extends Node {
|
||||
- code.remove(c, declarator.id.start);
|
||||
+ code.remove(c, declarator.id.start, lastDeclaratorIsPattern);
|
||||
EOF
|
||||
ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi
|
||||
minify_in_situ "src" \
|
||||
|
||||
Reference in New Issue
Block a user