Merge branch 'master' into harmony-v3.3.10
This commit is contained in:
@@ -52,13 +52,8 @@ collapse_vars_side_effects_1: {
|
||||
console.log.bind(console)(s.charAt(i++), s.charAt(i++), s.charAt(i++), 7);
|
||||
}
|
||||
function f2() {
|
||||
var log = console.log.bind(console),
|
||||
s = "abcdef",
|
||||
i = 2,
|
||||
x = s.charAt(i++),
|
||||
y = s.charAt(i++),
|
||||
z = s.charAt(i++);
|
||||
log(x, i, y, z, 7);
|
||||
var s = "abcdef", i = 2;
|
||||
console.log.bind(console)(s.charAt(i++), 5, s.charAt(i++), s.charAt(i++), 7);
|
||||
}
|
||||
function f3() {
|
||||
var s = "abcdef",
|
||||
@@ -72,7 +67,7 @@ collapse_vars_side_effects_1: {
|
||||
var i = 10,
|
||||
x = i += 2,
|
||||
y = i += 3;
|
||||
console.log.bind(console)(x, i += 4, y, i);
|
||||
console.log.bind(console)(x, i += 4, y, 19);
|
||||
}
|
||||
f1(), f2(), f3(), f4();
|
||||
}
|
||||
@@ -4414,3 +4409,413 @@ unsafe_builtin: {
|
||||
}
|
||||
expect_stdout: "1 4"
|
||||
}
|
||||
|
||||
return_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var log = console.log;
|
||||
function f(b, c) {
|
||||
var a = c;
|
||||
if (b) return b;
|
||||
log(a);
|
||||
}
|
||||
f(false, 1);
|
||||
f(true, 2);
|
||||
}
|
||||
expect: {
|
||||
var log = console.log;
|
||||
function f(b, c) {
|
||||
if (b) return b;
|
||||
log(c);
|
||||
}
|
||||
f(false, 1);
|
||||
f(true, 2);
|
||||
}
|
||||
expect_stdout: "1"
|
||||
}
|
||||
|
||||
return_2: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var log = console.log;
|
||||
function f(b, c) {
|
||||
var a = c();
|
||||
if (b) return b;
|
||||
log(a);
|
||||
}
|
||||
f(false, function() { return 1 });
|
||||
f(true, function() { return 2 });
|
||||
}
|
||||
expect: {
|
||||
var log = console.log;
|
||||
function f(b, c) {
|
||||
var a = c();
|
||||
if (b) return b;
|
||||
log(a);
|
||||
}
|
||||
f(false, function() { return 1 });
|
||||
f(true, function() { return 2 });
|
||||
}
|
||||
expect_stdout: "1"
|
||||
}
|
||||
|
||||
return_3: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var log = console.log;
|
||||
function f(b, c) {
|
||||
var a = b <<= c;
|
||||
if (b) return b;
|
||||
log(a);
|
||||
}
|
||||
f(false, 1);
|
||||
f(true, 2);
|
||||
}
|
||||
expect: {
|
||||
var log = console.log;
|
||||
function f(b, c) {
|
||||
var a = b <<= c;
|
||||
if (b) return b;
|
||||
log(a);
|
||||
}
|
||||
f(false, 1);
|
||||
f(true, 2);
|
||||
}
|
||||
expect_stdout: "0"
|
||||
}
|
||||
|
||||
return_4: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
}
|
||||
input: {
|
||||
var a = "FAIL";
|
||||
(function(b) {
|
||||
a = "PASS";
|
||||
return;
|
||||
b(a);
|
||||
})();
|
||||
console.log(a);
|
||||
}
|
||||
expect: {
|
||||
var a = "FAIL";
|
||||
(function(b) {
|
||||
a = "PASS";
|
||||
return;
|
||||
b(a);
|
||||
})();
|
||||
console.log(a);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_2858: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var b;
|
||||
(function() {
|
||||
function f() {
|
||||
a++;
|
||||
}
|
||||
f();
|
||||
var c = f();
|
||||
var a = void 0;
|
||||
c || (b = a);
|
||||
})();
|
||||
console.log(b);
|
||||
}
|
||||
expect: {
|
||||
var b;
|
||||
(function() {
|
||||
function f() {
|
||||
a++;
|
||||
}
|
||||
f();
|
||||
var c = f();
|
||||
var a = void 0;
|
||||
c || (b = a);
|
||||
})();
|
||||
console.log(b);
|
||||
}
|
||||
expect_stdout: "undefined"
|
||||
}
|
||||
|
||||
cond_branch_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
sequences: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function f1(b, c) {
|
||||
var log = console.log;
|
||||
var a = ++c;
|
||||
if (b) b++;
|
||||
log(a, b);
|
||||
}
|
||||
function f2(b, c) {
|
||||
var log = console.log;
|
||||
var a = ++c;
|
||||
b && b++;
|
||||
log(a, b);
|
||||
}
|
||||
function f3(b, c) {
|
||||
var log = console.log;
|
||||
var a = ++c;
|
||||
b ? b++ : b--;
|
||||
log(a, b);
|
||||
}
|
||||
f1(1, 2);
|
||||
f2(3, 4);
|
||||
f3(5, 6);
|
||||
}
|
||||
expect: {
|
||||
function f1(b, c) {
|
||||
if (b) b++;
|
||||
(0, console.log)(++c, b);
|
||||
}
|
||||
function f2(b, c) {
|
||||
b && b++,
|
||||
(0, console.log)(++c, b);
|
||||
}
|
||||
function f3(b, c) {
|
||||
b ? b++ : b--,
|
||||
(0, console.log)(++c, b);
|
||||
}
|
||||
f1(1, 2),
|
||||
f2(3, 4),
|
||||
f3(5, 6);
|
||||
}
|
||||
expect_stdout: [
|
||||
"3 2",
|
||||
"5 4",
|
||||
"7 6",
|
||||
]
|
||||
}
|
||||
|
||||
cond_branch_2: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
sequences: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function f1(b, c) {
|
||||
var log = console.log;
|
||||
var a = ++c;
|
||||
if (b) b += a;
|
||||
log(a, b);
|
||||
}
|
||||
function f2(b, c) {
|
||||
var log = console.log;
|
||||
var a = ++c;
|
||||
b && (b += a);
|
||||
log(a, b);
|
||||
}
|
||||
function f3(b, c) {
|
||||
var log = console.log;
|
||||
var a = ++c;
|
||||
b ? b += a : b--;
|
||||
log(a, b);
|
||||
}
|
||||
f1(1, 2);
|
||||
f2(3, 4);
|
||||
f3(5, 6);
|
||||
}
|
||||
expect: {
|
||||
function f1(b, c) {
|
||||
var a = ++c;
|
||||
if (b) b += a;
|
||||
(0, console.log)(a, b);
|
||||
}
|
||||
function f2(b, c) {
|
||||
var a = ++c;
|
||||
b && (b += a),
|
||||
(0, console.log)(a, b);
|
||||
}
|
||||
function f3(b, c) {
|
||||
var a = ++c;
|
||||
b ? b += a : b--,
|
||||
(0, console.log)(a, b);
|
||||
}
|
||||
f1(1, 2),
|
||||
f2(3, 4),
|
||||
f3(5, 6);
|
||||
}
|
||||
expect_stdout: [
|
||||
"3 4",
|
||||
"5 8",
|
||||
"7 12",
|
||||
]
|
||||
}
|
||||
|
||||
cond_branch_switch: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
}
|
||||
input: {
|
||||
var c = 0;
|
||||
if (c = 1 + c, 0) switch (c = 1 + c) {
|
||||
}
|
||||
console.log(c);
|
||||
}
|
||||
expect: {
|
||||
var c = 0;
|
||||
if (c = 1 + c, 0) switch (c = 1 + c) {
|
||||
}
|
||||
console.log(c);
|
||||
}
|
||||
expect_stdout: "1"
|
||||
}
|
||||
|
||||
issue_2873_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
}
|
||||
input: {
|
||||
var b = 1, c = 0;
|
||||
do {
|
||||
c++;
|
||||
if (!--b) break;
|
||||
c = 1 + c;
|
||||
} while (0);
|
||||
console.log(b, c);
|
||||
}
|
||||
expect: {
|
||||
var b = 1, c = 0;
|
||||
do {
|
||||
c++;
|
||||
if (!--b) break;
|
||||
c = 1 + c;
|
||||
} while (0);
|
||||
console.log(b, c);
|
||||
}
|
||||
expect_stdout: "0 1"
|
||||
}
|
||||
|
||||
issue_2873_2: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
}
|
||||
input: {
|
||||
var b = 1, c = 0;
|
||||
do {
|
||||
c++;
|
||||
if (!--b) continue;
|
||||
c = 1 + c;
|
||||
} while (0);
|
||||
console.log(b, c);
|
||||
}
|
||||
expect: {
|
||||
var b = 1, c = 0;
|
||||
do {
|
||||
c++;
|
||||
if (!--b) continue;
|
||||
c = 1 + c;
|
||||
} while (0);
|
||||
console.log(b, c);
|
||||
}
|
||||
expect_stdout: "0 1"
|
||||
}
|
||||
|
||||
issue_2878: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
sequences: true,
|
||||
}
|
||||
input: {
|
||||
var c = 0;
|
||||
(function (a, b) {
|
||||
function f2() {
|
||||
if (a) c++;
|
||||
}
|
||||
b = f2();
|
||||
a = 1;
|
||||
b && b.b;
|
||||
f2();
|
||||
})();
|
||||
console.log(c);
|
||||
}
|
||||
expect: {
|
||||
var c = 0;
|
||||
(function (a, b) {
|
||||
function f2() {
|
||||
if (a) c++;
|
||||
}
|
||||
b = f2(),
|
||||
a = 1,
|
||||
b && b.b,
|
||||
f2();
|
||||
})(),
|
||||
console.log(c);
|
||||
}
|
||||
expect_stdout: "1"
|
||||
}
|
||||
|
||||
issue_2891_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
}
|
||||
input: {
|
||||
var a = "PASS", b;
|
||||
try {
|
||||
b = c.p = 0;
|
||||
a = "FAIL";
|
||||
b();
|
||||
} catch (e) {
|
||||
}
|
||||
console.log(a);
|
||||
}
|
||||
expect: {
|
||||
var a = "PASS", b;
|
||||
try {
|
||||
b = c.p = 0;
|
||||
a = "FAIL";
|
||||
b();
|
||||
} catch (e) {
|
||||
}
|
||||
console.log(a);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_2891_2: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
}
|
||||
input: {
|
||||
"use strict";
|
||||
var a = "PASS", b;
|
||||
try {
|
||||
b = c = 0;
|
||||
a = "FAIL";
|
||||
b();
|
||||
} catch (e) {
|
||||
}
|
||||
console.log(a);
|
||||
}
|
||||
expect: {
|
||||
"use strict";
|
||||
var a = "PASS", b;
|
||||
try {
|
||||
b = c = 0;
|
||||
a = "FAIL";
|
||||
b();
|
||||
} catch (e) {
|
||||
}
|
||||
console.log(a);
|
||||
}
|
||||
expect_stdout: true
|
||||
}
|
||||
|
||||
@@ -112,3 +112,206 @@ self_comparison_2: {
|
||||
}
|
||||
expect_stdout: "false true"
|
||||
}
|
||||
|
||||
issue_2857_1: {
|
||||
options = {
|
||||
comparisons: true,
|
||||
}
|
||||
input: {
|
||||
function f1(a) {
|
||||
a === undefined || a === null;
|
||||
a === undefined || a !== null;
|
||||
a !== undefined || a === null;
|
||||
a !== undefined || a !== null;
|
||||
a === undefined && a === null;
|
||||
a === undefined && a !== null;
|
||||
a !== undefined && a === null;
|
||||
a !== undefined && a !== null;
|
||||
}
|
||||
function f2(a) {
|
||||
a === null || a === undefined;
|
||||
a === null || a !== undefined;
|
||||
a !== null || a === undefined;
|
||||
a !== null || a !== undefined;
|
||||
a === null && a === undefined;
|
||||
a === null && a !== undefined;
|
||||
a !== null && a === undefined;
|
||||
a !== null && a !== undefined;
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
function f1(a) {
|
||||
null == a;
|
||||
void 0 === a || null !== a;
|
||||
void 0 !== a || null === a;
|
||||
void 0 !== a || null !== a;
|
||||
void 0 === a && null === a;
|
||||
void 0 === a && null !== a;
|
||||
void 0 !== a && null === a;
|
||||
null != a;
|
||||
}
|
||||
function f2(a) {
|
||||
null == a;
|
||||
null === a || void 0 !== a;
|
||||
null !== a || void 0 === a;
|
||||
null !== a || void 0 !== a;
|
||||
null === a && void 0 === a;
|
||||
null === a && void 0 !== a;
|
||||
null !== a && void 0 === a;
|
||||
null != a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
issue_2857_2: {
|
||||
options = {
|
||||
comparisons: true,
|
||||
}
|
||||
input: {
|
||||
function f(a, p) {
|
||||
a === undefined || a === null || p;
|
||||
a === undefined || a !== null || p;
|
||||
a !== undefined || a === null || p;
|
||||
a !== undefined || a !== null || p;
|
||||
a === undefined && a === null || p;
|
||||
a === undefined && a !== null || p;
|
||||
a !== undefined && a === null || p;
|
||||
a !== undefined && a !== null || p;
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
function f(a, p) {
|
||||
null == a || p;
|
||||
void 0 === a || null !== a || p;
|
||||
void 0 !== a || null === a || p;
|
||||
void 0 !== a || null !== a || p;
|
||||
void 0 === a && null === a || p;
|
||||
void 0 === a && null !== a || p;
|
||||
void 0 !== a && null === a || p;
|
||||
null != a || p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
issue_2857_3: {
|
||||
options = {
|
||||
comparisons: true,
|
||||
}
|
||||
input: {
|
||||
function f(a, p) {
|
||||
a === undefined || a === null && p;
|
||||
a === undefined || a !== null && p;
|
||||
a !== undefined || a === null && p;
|
||||
a !== undefined || a !== null && p;
|
||||
a === undefined && a === null && p;
|
||||
a === undefined && a !== null && p;
|
||||
a !== undefined && a === null && p;
|
||||
a !== undefined && a !== null && p;
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
function f(a, p) {
|
||||
void 0 === a || null === a && p;
|
||||
void 0 === a || null !== a && p;
|
||||
void 0 !== a || null === a && p;
|
||||
void 0 !== a || null !== a && p;
|
||||
void 0 === a && null === a && p;
|
||||
void 0 === a && null !== a && p;
|
||||
void 0 !== a && null === a && p;
|
||||
null != a && p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
issue_2857_4: {
|
||||
options = {
|
||||
comparisons: true,
|
||||
}
|
||||
input: {
|
||||
function f(a, p) {
|
||||
p || a === undefined || a === null;
|
||||
p || a === undefined || a !== null;
|
||||
p || a !== undefined || a === null;
|
||||
p || a !== undefined || a !== null;
|
||||
p || a === undefined && a === null;
|
||||
p || a === undefined && a !== null;
|
||||
p || a !== undefined && a === null;
|
||||
p || a !== undefined && a !== null;
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
function f(a, p) {
|
||||
p || null == a;
|
||||
p || void 0 === a || null !== a;
|
||||
p || void 0 !== a || null === a;
|
||||
p || void 0 !== a || null !== a;
|
||||
p || void 0 === a && null === a;
|
||||
p || void 0 === a && null !== a;
|
||||
p || void 0 !== a && null === a;
|
||||
p || null != a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
issue_2857_5: {
|
||||
options = {
|
||||
comparisons: true,
|
||||
}
|
||||
input: {
|
||||
function f(a, p) {
|
||||
p && a === undefined || a === null;
|
||||
p && a === undefined || a !== null;
|
||||
p && a !== undefined || a === null;
|
||||
p && a !== undefined || a !== null;
|
||||
p && a === undefined && a === null;
|
||||
p && a === undefined && a !== null;
|
||||
p && a !== undefined && a === null;
|
||||
p && a !== undefined && a !== null;
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
function f(a, p) {
|
||||
p && void 0 === a || null === a;
|
||||
p && void 0 === a || null !== a;
|
||||
p && void 0 !== a || null === a;
|
||||
p && void 0 !== a || null !== a;
|
||||
p && void 0 === a && null === a;
|
||||
p && void 0 === a && null !== a;
|
||||
p && void 0 !== a && null === a;
|
||||
p && null != a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
issue_2857_6: {
|
||||
options = {
|
||||
comparisons: true,
|
||||
pure_getters: "strict",
|
||||
reduce_vars: true,
|
||||
}
|
||||
input: {
|
||||
function f(a) {
|
||||
if (({}).b === undefined || {}.b === null)
|
||||
return a.b !== undefined && a.b !== null;
|
||||
}
|
||||
console.log(f({
|
||||
a: [ null ],
|
||||
get b() {
|
||||
return this.a.shift();
|
||||
}
|
||||
}));
|
||||
}
|
||||
expect: {
|
||||
function f(a) {
|
||||
if (null == {}.b)
|
||||
return void 0 !== a.b && null !== a.b;
|
||||
}
|
||||
console.log(f({
|
||||
a: [ null ],
|
||||
get b() {
|
||||
return this.a.shift();
|
||||
}
|
||||
}));
|
||||
}
|
||||
expect_stdout: "true"
|
||||
}
|
||||
|
||||
@@ -1178,3 +1178,41 @@ unsafe_builtin: {
|
||||
z;
|
||||
}
|
||||
}
|
||||
|
||||
issue_2860_1: {
|
||||
options = {
|
||||
dead_code: true,
|
||||
evaluate: true,
|
||||
reduce_vars: true,
|
||||
}
|
||||
input: {
|
||||
console.log(function(a) {
|
||||
return a ^= 1;
|
||||
}());
|
||||
}
|
||||
expect: {
|
||||
console.log(function(a) {
|
||||
return 1 ^ a;
|
||||
}());
|
||||
}
|
||||
expect_stdout: "1"
|
||||
}
|
||||
|
||||
issue_2860_2: {
|
||||
options = {
|
||||
dead_code: true,
|
||||
evaluate: true,
|
||||
inline: true,
|
||||
passes: 2,
|
||||
reduce_vars: true,
|
||||
}
|
||||
input: {
|
||||
console.log(function(a) {
|
||||
return a ^= 1;
|
||||
}());
|
||||
}
|
||||
expect: {
|
||||
console.log(1);
|
||||
}
|
||||
expect_stdout: "1"
|
||||
}
|
||||
|
||||
@@ -1467,3 +1467,58 @@ issue_2822: {
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
string_case: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
unsafe: true,
|
||||
}
|
||||
input: {
|
||||
console.log("İ".toLowerCase().charCodeAt(0));
|
||||
console.log("I".toLowerCase().charCodeAt(0));
|
||||
console.log("Ş".toLowerCase().charCodeAt(0));
|
||||
console.log("Ğ".toLowerCase().charCodeAt(0));
|
||||
console.log("Ü".toLowerCase().charCodeAt(0));
|
||||
console.log("Ö".toLowerCase().charCodeAt(0));
|
||||
console.log("Ç".toLowerCase().charCodeAt(0));
|
||||
console.log("i".toUpperCase().charCodeAt(0));
|
||||
console.log("ı".toUpperCase().charCodeAt(0));
|
||||
console.log("ş".toUpperCase().charCodeAt(0));
|
||||
console.log("ğ".toUpperCase().charCodeAt(0));
|
||||
console.log("ü".toUpperCase().charCodeAt(0));
|
||||
console.log("ö".toUpperCase().charCodeAt(0));
|
||||
console.log("ç".toUpperCase().charCodeAt(0));
|
||||
}
|
||||
expect: {
|
||||
console.log(105);
|
||||
console.log(105);
|
||||
console.log(351);
|
||||
console.log(287);
|
||||
console.log(252);
|
||||
console.log(246);
|
||||
console.log(231);
|
||||
console.log(73);
|
||||
console.log(73);
|
||||
console.log(350);
|
||||
console.log(286);
|
||||
console.log(220);
|
||||
console.log(214);
|
||||
console.log(199);
|
||||
}
|
||||
expect_stdout: [
|
||||
"105",
|
||||
"105",
|
||||
"351",
|
||||
"287",
|
||||
"252",
|
||||
"246",
|
||||
"231",
|
||||
"73",
|
||||
"73",
|
||||
"350",
|
||||
"286",
|
||||
"220",
|
||||
"214",
|
||||
"199",
|
||||
]
|
||||
}
|
||||
|
||||
37
test/compress/issue-2871.js
Normal file
37
test/compress/issue-2871.js
Normal file
@@ -0,0 +1,37 @@
|
||||
comparison_with_undefined: {
|
||||
options = {
|
||||
comparisons: true,
|
||||
}
|
||||
input: {
|
||||
a == undefined;
|
||||
a != undefined;
|
||||
a === undefined;
|
||||
a !== undefined;
|
||||
|
||||
undefined == a;
|
||||
undefined != a;
|
||||
undefined === a;
|
||||
undefined !== a;
|
||||
|
||||
void 0 == a;
|
||||
void 0 != a;
|
||||
void 0 === a;
|
||||
void 0 !== a;
|
||||
}
|
||||
expect: {
|
||||
null == a;
|
||||
null != a;
|
||||
void 0 === a;
|
||||
void 0 !== a;
|
||||
|
||||
null == a;
|
||||
null != a;
|
||||
void 0 === a;
|
||||
void 0 !== a;
|
||||
|
||||
null == a;
|
||||
null != a;
|
||||
void 0 === a;
|
||||
void 0 !== a;
|
||||
}
|
||||
}
|
||||
@@ -76,14 +76,12 @@ modified: {
|
||||
console.log(a + 1);
|
||||
console.log(b + 1);
|
||||
}
|
||||
|
||||
function f1() {
|
||||
var a = 1, b = 2;
|
||||
--b;
|
||||
console.log(a + 1);
|
||||
console.log(b + 1);
|
||||
}
|
||||
|
||||
function f2() {
|
||||
var a = 1, b = 2, c = 3;
|
||||
b = c;
|
||||
@@ -92,7 +90,6 @@ modified: {
|
||||
console.log(a + c);
|
||||
console.log(a + b + c);
|
||||
}
|
||||
|
||||
function f3() {
|
||||
var a = 1, b = 2, c = 3;
|
||||
b *= c;
|
||||
@@ -101,7 +98,6 @@ modified: {
|
||||
console.log(a + c);
|
||||
console.log(a + b + c);
|
||||
}
|
||||
|
||||
function f4() {
|
||||
var a = 1, b = 2, c = 3;
|
||||
if (a) {
|
||||
@@ -114,28 +110,26 @@ modified: {
|
||||
console.log(a + c);
|
||||
console.log(a + b + c);
|
||||
}
|
||||
|
||||
function f5(a) {
|
||||
B = a;
|
||||
console.log(A ? 'yes' : 'no');
|
||||
console.log(B ? 'yes' : 'no');
|
||||
console.log(typeof A ? "yes" : "no");
|
||||
console.log(typeof B ? "yes" : "no");
|
||||
}
|
||||
f0(), f1(), f2(), f3(), f4(), f5();
|
||||
}
|
||||
expect: {
|
||||
function f0() {
|
||||
var b = 2;
|
||||
b++;
|
||||
console.log(2);
|
||||
console.log(b + 1);
|
||||
console.log(4);
|
||||
}
|
||||
|
||||
function f1() {
|
||||
var b = 2;
|
||||
--b;
|
||||
console.log(2);
|
||||
console.log(b + 1);
|
||||
console.log(2);
|
||||
}
|
||||
|
||||
function f2() {
|
||||
3;
|
||||
console.log(4);
|
||||
@@ -143,16 +137,14 @@ modified: {
|
||||
console.log(4);
|
||||
console.log(7);
|
||||
}
|
||||
|
||||
function f3() {
|
||||
var b = 2;
|
||||
b *= 3;
|
||||
console.log(1 + b);
|
||||
console.log(b + 3);
|
||||
console.log(7);
|
||||
console.log(9);
|
||||
console.log(4);
|
||||
console.log(1 + b + 3);
|
||||
console.log(10);
|
||||
}
|
||||
|
||||
function f4() {
|
||||
var b = 2, c = 3;
|
||||
b = c;
|
||||
@@ -161,13 +153,33 @@ modified: {
|
||||
console.log(1 + c);
|
||||
console.log(1 + b + c);
|
||||
}
|
||||
|
||||
function f5(a) {
|
||||
B = a;
|
||||
console.log(A ? 'yes' : 'no');
|
||||
console.log(B ? 'yes' : 'no');
|
||||
console.log(typeof A ? "yes" : "no");
|
||||
console.log(typeof B ? "yes" : "no");
|
||||
}
|
||||
f0(), f1(), f2(), f3(), f4(), f5();
|
||||
}
|
||||
expect_stdout: [
|
||||
"2",
|
||||
"4",
|
||||
"2",
|
||||
"2",
|
||||
"4",
|
||||
"6",
|
||||
"4",
|
||||
"7",
|
||||
"7",
|
||||
"9",
|
||||
"4",
|
||||
"10",
|
||||
"4",
|
||||
"6",
|
||||
"4",
|
||||
"7",
|
||||
"yes",
|
||||
"yes",
|
||||
]
|
||||
}
|
||||
|
||||
unsafe_evaluate: {
|
||||
@@ -745,7 +757,7 @@ iife: {
|
||||
expect: {
|
||||
!function(a, b, c) {
|
||||
b++;
|
||||
console.log(0, 1 * b, 5);
|
||||
console.log(0, 3, 5);
|
||||
}(1, 2, 3);
|
||||
}
|
||||
expect_stdout: true
|
||||
@@ -766,7 +778,7 @@ iife_new: {
|
||||
expect: {
|
||||
var A = new function(a, b, c) {
|
||||
b++;
|
||||
console.log(0, 1 * b, 5);
|
||||
console.log(0, 3, 5);
|
||||
}(1, 2, 3);
|
||||
}
|
||||
expect_stdout: true
|
||||
@@ -5973,3 +5985,141 @@ issue_2836: {
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
lvalues_def_1: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var b = 1;
|
||||
var a = b++, b = NaN;
|
||||
console.log(a, b);
|
||||
}
|
||||
expect: {
|
||||
var b = 1;
|
||||
var a = b++;
|
||||
b = NaN;
|
||||
console.log(a, b);
|
||||
}
|
||||
expect_stdout: "1 NaN"
|
||||
}
|
||||
|
||||
lvalues_def_2: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var b = 1;
|
||||
var a = b += 1, b = NaN;
|
||||
console.log(a, b);
|
||||
}
|
||||
expect: {
|
||||
var b = 1;
|
||||
var a = b += 1;
|
||||
b = NaN;
|
||||
console.log(a, b);
|
||||
}
|
||||
expect_stdout: "2 NaN"
|
||||
}
|
||||
|
||||
chained_assignments: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
inline: true,
|
||||
reduce_vars: true,
|
||||
sequences: true,
|
||||
side_effects: true,
|
||||
toplevel: true,
|
||||
unsafe: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
function f() {
|
||||
var a = [0x5e, 0xad, 0xbe, 0xef];
|
||||
var b = 0;
|
||||
b |= a[0];
|
||||
b <<= 8;
|
||||
b |= a[1];
|
||||
b <<= 8;
|
||||
b |= a[2];
|
||||
b <<= 8;
|
||||
b |= a[3];
|
||||
return b;
|
||||
}
|
||||
console.log(f().toString(16));
|
||||
}
|
||||
expect: {
|
||||
console.log("5eadbeef");
|
||||
}
|
||||
expect_stdout: "5eadbeef"
|
||||
}
|
||||
|
||||
issue_2860_1: {
|
||||
options = {
|
||||
dead_code: true,
|
||||
evaluate: true,
|
||||
reduce_vars: true,
|
||||
}
|
||||
input: {
|
||||
console.log(function(a) {
|
||||
return a ^= 1;
|
||||
a ^= 2;
|
||||
}());
|
||||
}
|
||||
expect: {
|
||||
console.log(function(a) {
|
||||
return 1 ^ a;
|
||||
}());
|
||||
}
|
||||
expect_stdout: "1"
|
||||
}
|
||||
|
||||
issue_2860_2: {
|
||||
options = {
|
||||
dead_code: true,
|
||||
evaluate: true,
|
||||
inline: true,
|
||||
passes: 2,
|
||||
reduce_vars: true,
|
||||
}
|
||||
input: {
|
||||
console.log(function(a) {
|
||||
return a ^= 1;
|
||||
a ^= 2;
|
||||
}());
|
||||
}
|
||||
expect: {
|
||||
console.log(1);
|
||||
}
|
||||
expect_stdout: "1"
|
||||
}
|
||||
|
||||
issue_2869: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
reduce_vars: true,
|
||||
}
|
||||
input: {
|
||||
var c = "FAIL";
|
||||
(function f(a) {
|
||||
var a;
|
||||
if (!f) a = 0;
|
||||
if (a) c = "PASS";
|
||||
})(1);
|
||||
console.log(c);
|
||||
}
|
||||
expect: {
|
||||
var c = "FAIL";
|
||||
(function f(a) {
|
||||
var a;
|
||||
if (!f) a = 0;
|
||||
if (a) c = "PASS";
|
||||
})(1);
|
||||
console.log(c);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
@@ -1024,7 +1024,6 @@ function log_suspects(minify_options, component) {
|
||||
}
|
||||
|
||||
function log_rename(options) {
|
||||
if (!options.rename) return;
|
||||
var m = JSON.parse(JSON.stringify(options));
|
||||
m.rename = false;
|
||||
var result = UglifyJS.minify(original_code, m);
|
||||
|
||||
Reference in New Issue
Block a user