self = make_node(AST_Binary, self, {
operator: "+",
left: make_node(AST_String, null, {
- value: self.left.getValue() + self.right.left.getValue(),
+ value: "" + self.left.getValue() + self.right.left.getValue(),
start: self.left.start,
end: self.right.left.end
}),
operator: "+",
left: self.left.left,
right: make_node(AST_String, null, {
- value: self.left.right.getValue() + self.right.getValue(),
+ value: "" + self.left.right.getValue() + self.right.getValue(),
start: self.left.right.start,
end: self.right.end
})
});
}
+ if (self.left instanceof AST_Binary
+ && self.left.operator == "+"
+ && self.left.is_string(compressor)
+ && self.left.right instanceof AST_Constant
+ && self.right instanceof AST_Binary
+ && self.right.operator == "+"
+ && self.right.left instanceof AST_Constant) {
+ self = make_node(AST_Binary, self, {
+ operator: "+",
+ left: make_node(AST_Binary, self.left, {
+ operator: "+",
+ left: self.left.left,
+ right: make_node(AST_String, null, {
+ value: "" + self.left.right.getValue() + self.right.left.getValue(),
+ start: self.left.right.start,
+ end: self.right.left.end
+ })
+ }),
+ right: self.right.right
+ });
+ }
}
}
return self.evaluate(compressor)[0];
var e = [ "foo", "bar", boo(),
"foo+1+2+3+bar",
"baz", "x", "y" ].join("really-long-separator");
- var f = "strstr" + variable + "foobar" + ("moo" + foo);
+ var f = "strstr" + variable + "foobarmoo" + foo;
}
}
--- /dev/null
+concat_1: {
+ options = {
+ evaluate: true
+ };
+ input: {
+ var a = "foo" + "bar" + x() + "moo" + "foo" + y() + "x" + "y" + "z" + q();
+ var b = "foo" + 1 + x() + 2 + "boo";
+ var c = 1 + x() + 2 + "boo";
+
+ // this CAN'T safely be shortened to 1 + x() + "5boo"
+ var d = 1 + x() + 2 + 3 + "boo";
+
+ var e = 1 + x() + 2 + "X" + 3 + "boo";
+ }
+ expect: {
+ var a = "foobar" + x() + "moofoo" + y() + "xyz" + q();
+ var b = "foo1" + x() + "2boo";
+ var c = 1 + x() + 2 + "boo";
+ var d = 1 + x() + 2 + 3 + "boo";
+ var e = 1 + x() + 2 + "X3boo";
+ }
+}