enhance evaluate, functions & inline (#3931)
This commit is contained in:
@@ -62,7 +62,7 @@ collapse_vars_side_effects_1: {
|
||||
expect: {
|
||||
function f1() {
|
||||
var s = "abcdef", i = 2;
|
||||
console.log.bind(console)(s.charAt(i++), s.charAt(i++), s.charAt(i++), 7);
|
||||
console.log.bind(console)(s.charAt(i++), s.charAt(i++), s.charAt(4), 7);
|
||||
}
|
||||
function f2() {
|
||||
var s = "abcdef", i = 2;
|
||||
@@ -74,13 +74,14 @@ collapse_vars_side_effects_1: {
|
||||
log = console.log.bind(console),
|
||||
x = s.charAt(i++),
|
||||
y = s.charAt(i++);
|
||||
log(x, s.charAt(i++), y, 7);
|
||||
log(x, s.charAt(4), y, 7);
|
||||
}
|
||||
function f4() {
|
||||
var i = 10,
|
||||
x = i += 2,
|
||||
y = i += 3;
|
||||
console.log.bind(console)(x, i += 4, y, 19);
|
||||
var i = 10;
|
||||
i += 2,
|
||||
i += 3,
|
||||
i += 4;
|
||||
console.log.bind(console)(12, 19, 15, 19);
|
||||
}
|
||||
f1(), f2(), f3(), f4();
|
||||
}
|
||||
|
||||
@@ -2485,3 +2485,62 @@ issue_3920: {
|
||||
}
|
||||
expect_stdout: "false"
|
||||
}
|
||||
|
||||
inlined_increment_prefix: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
inline: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
var a = 0;
|
||||
(function() {
|
||||
++a;
|
||||
})();
|
||||
console.log(a += 0);
|
||||
}
|
||||
expect: {
|
||||
var a = 0;
|
||||
void ++a;
|
||||
console.log(a += 0);
|
||||
}
|
||||
expect_stdout: "1"
|
||||
}
|
||||
|
||||
inlined_increment_postfix: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
inline: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
}
|
||||
input: {
|
||||
var a = 0;
|
||||
(function() {
|
||||
a++;
|
||||
})();
|
||||
console.log(a += 0);
|
||||
}
|
||||
expect: {
|
||||
var a = 0;
|
||||
void a++;
|
||||
console.log(a += 0);
|
||||
}
|
||||
expect_stdout: "1"
|
||||
}
|
||||
|
||||
compound_assignment_to_property: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
unsafe: true,
|
||||
}
|
||||
input: {
|
||||
1 + (0..p >>= 0) && console.log("PASS");
|
||||
}
|
||||
expect: {
|
||||
1 + (0..p >>= 0),
|
||||
console.log("PASS");
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
@@ -2724,8 +2724,8 @@ issue_1814_1: {
|
||||
expect: {
|
||||
!function() {
|
||||
!function(a) {
|
||||
console.log(a++, 42);
|
||||
}(0);
|
||||
console.log(0, 42);
|
||||
}();
|
||||
}();
|
||||
}
|
||||
expect_stdout: "0 42"
|
||||
@@ -2751,8 +2751,8 @@ issue_1814_2: {
|
||||
expect: {
|
||||
!function() {
|
||||
!function(a) {
|
||||
console.log("321", a++);
|
||||
}(0);
|
||||
console.log("321", 0);
|
||||
}();
|
||||
}();
|
||||
}
|
||||
expect_stdout: "321 0"
|
||||
|
||||
Reference in New Issue
Block a user