When unsafe is set, evaluate [...].join() if possible

Close #298
This commit is contained in:
Mihai Bazon
2013-09-19 18:20:45 +03:00
parent 8d14efe818
commit 78e98d2611
2 changed files with 33 additions and 1 deletions

View File

@@ -12,3 +12,22 @@ holes_and_undefined: {
z=[1,void 0,3];
}
}
constant_join: {
options = {
unsafe : true,
evaluate : true
};
input: {
var a = [ "foo", "bar", "baz" ].join("");
var b = [ "foo", 1, 2, 3, "bar" ].join("");
var c = [ boo(), "foo", 1, 2, 3, "bar", bar() ].join("");
var d = [ "foo", 1 + 2 + "bar", "baz" ].join("-");
}
expect: {
var a = "foobarbaz";
var b = "foo123bar";
var c = [ boo(), "foo", 1, 2, 3, "bar", bar() ].join(""); // we could still shorten this one, but oh well.
var d = "foo-3bar-baz";
}
}