aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authoralexlamsl <alexlamsl@gmail.com>2017-02-18 19:05:11 +0800
committeralexlamsl <alexlamsl@gmail.com>2017-02-21 13:29:57 +0800
commit100307ab31e89075a5b0e56d47597a0525dd43a6 (patch)
tree64b64c7d372d17caac14f441fb0790bde1be3703 /test/compress
parent148047fbbf1951a52e69170edf510c59b3899e6c (diff)
downloadtracifyjs-100307ab31e89075a5b0e56d47597a0525dd43a6.tar.gz
tracifyjs-100307ab31e89075a5b0e56d47597a0525dd43a6.zip
fixes & improvements to [].join()
fixes - [a].join() => "" + a - ["a", , "b"].join() => "a,,b" - ["a", null, "b"].join() => "a,,b" - ["a", undefined, "b"].join() => "a,,b" improvements - ["a", "b"].join(null) => "anullb" - ["a", "b"].join(undefined) => "a,b" - [a + "b", c].join("") => a + "b" + c closes #1453
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/arrays.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/compress/arrays.js b/test/compress/arrays.js
index 77ef761a..2e1f86ed 100644
--- a/test/compress/arrays.js
+++ b/test/compress/arrays.js
@@ -21,10 +21,19 @@ constant_join: {
input: {
var a = [ "foo", "bar", "baz" ].join("");
var a1 = [ "foo", "bar", "baz" ].join();
+ var a2 = [ "foo", "bar", "baz" ].join(null);
+ var a3 = [ "foo", "bar", "baz" ].join(void 0);
+ var a4 = [ "foo", , "baz" ].join();
+ var a5 = [ "foo", null, "baz" ].join();
+ var a6 = [ "foo", void 0, "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 c3 = [ boo() + bar() + "foo", 1, 2, 3, "bar", bar() + "foo" ].join("");
+ var c4 = [ 1, 2, null, undefined, "foo", "bar", baz() ].join("");
+ var c5 = [ boo() + bar() + "foo", 1, 2, 3, "bar", bar() + "foo" ].join();
+ var c6 = [ 1, 2, null, undefined, "foo", "bar", baz() ].join();
var d = [ "foo", 1 + 2 + "bar", "baz" ].join("-");
var e = [].join(foo + bar);
var f = [].join("");
@@ -33,10 +42,19 @@ constant_join: {
expect: {
var a = "foobarbaz";
var a1 = "foo,bar,baz";
+ var a2 = "foonullbarnullbaz";
+ var a3 = "foo,bar,baz";
+ var a4 = "foo,,baz";
+ var a5 = "foo,,baz";
+ var a6 = "foo,,baz";
var b = "foo123bar";
var c = boo() + "foo123bar" + bar();
var c1 = "" + boo() + bar() + "foo123bar" + bar();
var c2 = "12foobar" + baz();
+ var c3 = boo() + bar() + "foo123bar" + (bar() + "foo");
+ var c4 = "12foobar" + baz();
+ var c5 = [ boo() + bar() + "foo", 1, 2, 3, "bar", bar() + "foo" ].join();
+ var c6 = [ "1,2,,,foo,bar", baz() ].join();
var d = "foo-3bar-baz";
var e = [].join(foo + bar);
var f = "";
@@ -73,6 +91,41 @@ constant_join_2: {
}
}
+constant_join_3: {
+ options = {
+ unsafe: true,
+ evaluate: true,
+ };
+ input: {
+ var a = [ null ].join();
+ var b = [ , ].join();
+ var c = [ , 1, , 3 ].join();
+ var d = [ foo ].join();
+ var e = [ foo, null, undefined, bar ].join("-");
+ var f = [ foo, bar ].join("");
+ var g = [ null, "foo", null, bar + "baz" ].join("");
+ var h = [ null, "foo", null, bar + "baz" ].join("-");
+ var i = [ "foo" + bar, null, baz + "moo" ].join("");
+ var j = [ foo + "bar", baz ].join("");
+ var k = [ foo, "bar" + baz ].join("");
+ var l = [ foo, bar + "baz" ].join("");
+ }
+ expect: {
+ var a = "";
+ var b = "";
+ var c = ",1,,3";
+ var d = "" + foo;
+ var e = [ foo, "-", bar ].join("-");
+ var f = "" + foo + bar;
+ var g = "foo" + (bar + "baz");
+ var h = [ "-foo-", bar + "baz" ].join("-");
+ var i = "foo" + bar + (baz + "moo");
+ var j = foo + "bar" + baz;
+ var k = foo + ("bar" + baz);
+ var l = foo + (bar + "baz");
+ }
+}
+
for_loop: {
options = {
unsafe : true,