aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2013-09-22 13:12:34 +0300
committerMihai Bazon <mihai@bazon.net>2013-09-22 13:14:42 +0300
commit583fac0a0f4f5ae9b71a051730b4834a190f6387 (patch)
treeefb640e25e282cc9dac18052dc7c18f179121f87 /test
parente8158279ff08af915c634eeec4cfabda1ff4022e (diff)
downloadtracifyjs-583fac0a0f4f5ae9b71a051730b4834a190f6387.tar.gz
tracifyjs-583fac0a0f4f5ae9b71a051730b4834a190f6387.zip
More dirty handling of [ ... ].join() in unsafe mode
Close #300
Diffstat (limited to 'test')
-rw-r--r--test/compress/arrays.js41
1 files changed, 40 insertions, 1 deletions
diff --git a/test/compress/arrays.js b/test/compress/arrays.js
index 06e03ae4..5fb21a8b 100644
--- a/test/compress/arrays.js
+++ b/test/compress/arrays.js
@@ -20,16 +20,55 @@ constant_join: {
};
input: {
var a = [ "foo", "bar", "baz" ].join("");
+ var a1 = [ "foo", "bar", "baz" ].join();
var b = [ "foo", 1, 2, 3, "bar" ].join("");
var c = [ boo(), "foo", 1, 2, 3, "bar", bar() ].join("");
+ var c1 = [ boo(), bar(), "foo", 1, 2, 3, "bar", bar() ].join("");
+ var c2 = [ 1, 2, "foo", "bar", baz() ].join("");
var d = [ "foo", 1 + 2 + "bar", "baz" ].join("-");
var e = [].join(foo + bar);
+ var f = [].join("");
+ var g = [].join("foo");
}
expect: {
var a = "foobarbaz";
+ var a1 = "foo,bar,baz";
var b = "foo123bar";
- var c = [ boo(), "foo", 1, 2, 3, "bar", bar() ].join(""); // we could still shorten this one, but oh well.
+ var c = boo() + "foo123bar" + bar();
+ var c1 = "" + boo() + bar() + "foo123bar" + bar();
+ var c2 = "12foobar" + baz();
var d = "foo-3bar-baz";
var e = [].join(foo + bar);
+ var f = "";
+ var g = "";
+ }
+}
+
+constant_join_2: {
+ options = {
+ unsafe : true,
+ evaluate : true
+ };
+ input: {
+ var a = [ "foo", "bar", boo(), "baz", "x", "y" ].join("");
+ var b = [ "foo", "bar", boo(), "baz", "x", "y" ].join("-");
+ var c = [ "foo", "bar", boo(), "baz", "x", "y" ].join("really-long-separator");
+ var d = [ "foo", "bar", boo(),
+ [ "foo", 1, 2, 3, "bar" ].join("+"),
+ "baz", "x", "y" ].join("-");
+ var e = [ "foo", "bar", boo(),
+ [ "foo", 1, 2, 3, "bar" ].join("+"),
+ "baz", "x", "y" ].join("really-long-separator");
+ var f = [ "str", "str" + variable, "foo", "bar", "moo" + foo ].join("");
+ }
+ expect: {
+ var a = "foobar" + boo() + "bazxy";
+ var b = [ "foo-bar", boo(), "baz-x-y" ].join("-");
+ var c = [ "foo", "bar", boo(), "baz", "x", "y" ].join("really-long-separator");
+ var d = [ "foo-bar", boo(), "foo+1+2+3+bar-baz-x-y" ].join("-");
+ var e = [ "foo", "bar", boo(),
+ "foo+1+2+3+bar",
+ "baz", "x", "y" ].join("really-long-separator");
+ var f = "str" + ("str" + variable) + "foobar" + ("moo" + foo);
}
}