Compare commits
4 Commits
harmony-v2
...
v2.8.12
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
919d5e3482 | ||
|
|
e3a3db73ae | ||
|
|
d9344f30b8 | ||
|
|
be80f7e706 |
@@ -279,6 +279,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
var iife;
|
var iife;
|
||||||
if (node instanceof AST_Function
|
if (node instanceof AST_Function
|
||||||
|
&& !node.name
|
||||||
&& (iife = tw.parent()) instanceof AST_Call
|
&& (iife = tw.parent()) instanceof AST_Call
|
||||||
&& iife.expression === node) {
|
&& iife.expression === node) {
|
||||||
// Virtually turn IIFE parameters into variable definitions:
|
// Virtually turn IIFE parameters into variable definitions:
|
||||||
@@ -403,7 +404,7 @@ merge(Compressor.prototype, {
|
|||||||
|
|
||||||
return make_node(AST_Number, orig, { value: val });
|
return make_node(AST_Number, orig, { value: val });
|
||||||
case "boolean":
|
case "boolean":
|
||||||
return make_node(val ? AST_True : AST_False, orig).transform(compressor);
|
return make_node(val ? AST_True : AST_False, orig).optimize(compressor);
|
||||||
case "undefined":
|
case "undefined":
|
||||||
return make_node(AST_Undefined, orig).transform(compressor);
|
return make_node(AST_Undefined, orig).transform(compressor);
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"homepage": "http://lisperator.net/uglifyjs",
|
"homepage": "http://lisperator.net/uglifyjs",
|
||||||
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"version": "2.8.11",
|
"version": "2.8.12",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -295,7 +295,15 @@ issue_186_beautify: {
|
|||||||
else
|
else
|
||||||
bar();
|
bar();
|
||||||
}
|
}
|
||||||
expect_exact: 'var x = 3;\n\nif (foo()) do {\n do {\n alert(x);\n } while (--x);\n} while (x); else bar();'
|
expect_exact: [
|
||||||
|
'var x = 3;',
|
||||||
|
'',
|
||||||
|
'if (foo()) do {',
|
||||||
|
' do {',
|
||||||
|
' alert(x);',
|
||||||
|
' } while (--x);',
|
||||||
|
'} while (x); else bar();',
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_186_beautify_ie8: {
|
issue_186_beautify_ie8: {
|
||||||
@@ -314,7 +322,17 @@ issue_186_beautify_ie8: {
|
|||||||
else
|
else
|
||||||
bar();
|
bar();
|
||||||
}
|
}
|
||||||
expect_exact: 'var x = 3;\n\nif (foo()) {\n do {\n do {\n alert(x);\n } while (--x);\n } while (x);\n} else bar();'
|
expect_exact: [
|
||||||
|
'var x = 3;',
|
||||||
|
'',
|
||||||
|
'if (foo()) {',
|
||||||
|
' do {',
|
||||||
|
' do {',
|
||||||
|
' alert(x);',
|
||||||
|
' } while (--x);',
|
||||||
|
' } while (x);',
|
||||||
|
'} else bar();',
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_186_bracketize: {
|
issue_186_bracketize: {
|
||||||
@@ -374,7 +392,19 @@ issue_186_beautify_bracketize: {
|
|||||||
else
|
else
|
||||||
bar();
|
bar();
|
||||||
}
|
}
|
||||||
expect_exact: 'var x = 3;\n\nif (foo()) {\n do {\n do {\n alert(x);\n } while (--x);\n } while (x);\n} else {\n bar();\n}'
|
expect_exact: [
|
||||||
|
'var x = 3;',
|
||||||
|
'',
|
||||||
|
'if (foo()) {',
|
||||||
|
' do {',
|
||||||
|
' do {',
|
||||||
|
' alert(x);',
|
||||||
|
' } while (--x);',
|
||||||
|
' } while (x);',
|
||||||
|
'} else {',
|
||||||
|
' bar();',
|
||||||
|
'}',
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_186_beautify_bracketize_ie8: {
|
issue_186_beautify_bracketize_ie8: {
|
||||||
@@ -394,5 +424,17 @@ issue_186_beautify_bracketize_ie8: {
|
|||||||
else
|
else
|
||||||
bar();
|
bar();
|
||||||
}
|
}
|
||||||
expect_exact: 'var x = 3;\n\nif (foo()) {\n do {\n do {\n alert(x);\n } while (--x);\n } while (x);\n} else {\n bar();\n}'
|
expect_exact: [
|
||||||
|
'var x = 3;',
|
||||||
|
'',
|
||||||
|
'if (foo()) {',
|
||||||
|
' do {',
|
||||||
|
' do {',
|
||||||
|
' alert(x);',
|
||||||
|
' } while (--x);',
|
||||||
|
' } while (x);',
|
||||||
|
'} else {',
|
||||||
|
' bar();',
|
||||||
|
'}',
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,13 @@ too_short: {
|
|||||||
return { c: 42, d: a(), e: "foo"};
|
return { c: 42, d: a(), e: "foo"};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_exact: 'function f(a){\nreturn{\nc:42,\nd:a(),\ne:"foo"}}'
|
expect_exact: [
|
||||||
|
'function f(a){',
|
||||||
|
'return{',
|
||||||
|
'c:42,',
|
||||||
|
'd:a(),',
|
||||||
|
'e:"foo"}}',
|
||||||
|
]
|
||||||
expect_warnings: [
|
expect_warnings: [
|
||||||
"WARN: Output exceeds 10 characters"
|
"WARN: Output exceeds 10 characters"
|
||||||
]
|
]
|
||||||
@@ -22,7 +28,12 @@ just_enough: {
|
|||||||
return { c: 42, d: a(), e: "foo"};
|
return { c: 42, d: a(), e: "foo"};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_exact: 'function f(a){\nreturn{c:42,\nd:a(),e:"foo"}\n}'
|
expect_exact: [
|
||||||
|
'function f(a){',
|
||||||
|
'return{c:42,',
|
||||||
|
'd:a(),e:"foo"}',
|
||||||
|
'}',
|
||||||
|
]
|
||||||
expect_warnings: [
|
expect_warnings: [
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1252,3 +1252,78 @@ iife_func_side_effects: {
|
|||||||
})(x(), 0, z());
|
})(x(), 0, z());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_1595_1: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function f(a) {
|
||||||
|
return f(a + 1);
|
||||||
|
})(2);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function f(a) {
|
||||||
|
return f(a + 1);
|
||||||
|
})(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_1595_2: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function f(a) {
|
||||||
|
return g(a + 1);
|
||||||
|
})(2);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(a) {
|
||||||
|
return g(a + 1);
|
||||||
|
})(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_1595_3: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
passes: 2,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function f(a) {
|
||||||
|
return g(a + 1);
|
||||||
|
})(2);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(a) {
|
||||||
|
return g(3);
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_1595_4: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function iife(a, b, c) {
|
||||||
|
console.log(a, b, c);
|
||||||
|
if (a) iife(a - 1, b, c);
|
||||||
|
})(3, 4, 5);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function iife(a, b, c) {
|
||||||
|
console.log(a, b, c);
|
||||||
|
if (a) iife(a - 1, b, c);
|
||||||
|
})(3, 4, 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -214,6 +214,23 @@ function parse_test(file) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function read_string(stat) {
|
||||||
|
if (stat.TYPE === "SimpleStatement") {
|
||||||
|
var body = stat.body;
|
||||||
|
out: switch(body.TYPE) {
|
||||||
|
case "String":
|
||||||
|
return body.value;
|
||||||
|
case "Array":
|
||||||
|
return body.elements.map(function(element) {
|
||||||
|
if (element.TYPE !== "String")
|
||||||
|
throw new Error("Should be array of strings");
|
||||||
|
return element.value;
|
||||||
|
}).join("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error("Should be string or array of strings");
|
||||||
|
}
|
||||||
|
|
||||||
function get_one_test(name, block) {
|
function get_one_test(name, block) {
|
||||||
var test = { name: name, options: {} };
|
var test = { name: name, options: {} };
|
||||||
var tw = new U.TreeWalker(function(node, descend){
|
var tw = new U.TreeWalker(function(node, descend){
|
||||||
@@ -240,12 +257,7 @@ function parse_test(file) {
|
|||||||
else if (stat.body.length == 0) stat = new U.AST_EmptyStatement();
|
else if (stat.body.length == 0) stat = new U.AST_EmptyStatement();
|
||||||
}
|
}
|
||||||
if (node.label.name === "expect_exact") {
|
if (node.label.name === "expect_exact") {
|
||||||
if (!(stat.TYPE === "SimpleStatement" && stat.body.TYPE === "String")) {
|
test[node.label.name] = read_string(stat);
|
||||||
throw new Error(
|
|
||||||
"The value of the expect_exact clause should be a string, " +
|
|
||||||
"like `expect_exact: \"some.exact.javascript;\"`");
|
|
||||||
}
|
|
||||||
test[node.label.name] = stat.body.start.value
|
|
||||||
} else {
|
} else {
|
||||||
test[node.label.name] = stat;
|
test[node.label.name] = stat;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user