enhance assignments (#3612)
This commit is contained in:
@@ -6720,8 +6720,8 @@ merge(Compressor.prototype, {
|
|||||||
self.right = self.right.left;
|
self.right = self.right.left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((self.operator == "+=" || self.operator == "-=")
|
if ((self.operator == "-=" || self.operator == "+="
|
||||||
&& self.left.is_number(compressor)
|
&& (self.left.is_boolean(compressor) || self.left.is_number(compressor)))
|
||||||
&& self.right instanceof AST_Number
|
&& self.right instanceof AST_Number
|
||||||
&& self.right.getValue() === 1) {
|
&& self.right.getValue() === 1) {
|
||||||
var op = self.operator.slice(0, -1);
|
var op = self.operator.slice(0, -1);
|
||||||
|
|||||||
@@ -290,26 +290,60 @@ increment_decrement_2: {
|
|||||||
expect_stdout: "42"
|
expect_stdout: "42"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_3375: {
|
issue_3375_1: {
|
||||||
options = {
|
options = {
|
||||||
assignments: true,
|
assignments: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(typeof function(b) {
|
function p(o) {
|
||||||
|
console.log(typeof o, o);
|
||||||
|
}
|
||||||
|
p(function(b) {
|
||||||
var a = b += 1;
|
var a = b += 1;
|
||||||
--b;
|
--b;
|
||||||
return a;
|
return a;
|
||||||
}("object"));
|
}("object"));
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
console.log(typeof function(b) {
|
function p(o) {
|
||||||
|
console.log(typeof o, o);
|
||||||
|
}
|
||||||
|
p(function(b) {
|
||||||
var a = b += 1;
|
var a = b += 1;
|
||||||
--b;
|
--b;
|
||||||
return a;
|
return a;
|
||||||
}("object"));
|
}("object"));
|
||||||
}
|
}
|
||||||
expect_stdout: "string"
|
expect_stdout: "string object1"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3375_2: {
|
||||||
|
options = {
|
||||||
|
assignments: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function p(o) {
|
||||||
|
console.log(typeof o, o);
|
||||||
|
}
|
||||||
|
p(function(b) {
|
||||||
|
var a = b -= 1;
|
||||||
|
--b;
|
||||||
|
return a;
|
||||||
|
}("object"));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function p(o) {
|
||||||
|
console.log(typeof o, o);
|
||||||
|
}
|
||||||
|
p(function(b) {
|
||||||
|
var a = --b;
|
||||||
|
--b;
|
||||||
|
return a;
|
||||||
|
}("object"));
|
||||||
|
}
|
||||||
|
expect_stdout: "number NaN"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_3427: {
|
issue_3427: {
|
||||||
|
|||||||
Reference in New Issue
Block a user