diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-03-02 11:31:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-02 11:31:39 +0800 |
commit | fdc9b9413bfddc711fe6195bd4fd408ab1dfa95e (patch) | |
tree | 867fc780891c6e248a3510d9e34ac77b9914949d /test | |
parent | 40ceddb48a6ea8d6864667574fa9db37ccc9a6bf (diff) | |
download | tracifyjs-fdc9b9413bfddc711fe6195bd4fd408ab1dfa95e.tar.gz tracifyjs-fdc9b9413bfddc711fe6195bd4fd408ab1dfa95e.zip |
minor improvement to string optimisation (#1514)
- "" + "a" => "a"
- "" + a + "b" => a + "b"
- "a" + "" => "a" (improving on #45)
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/concat-strings.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/compress/concat-strings.js b/test/compress/concat-strings.js index d2503c6d..2f99375c 100644 --- a/test/compress/concat-strings.js +++ b/test/compress/concat-strings.js @@ -164,3 +164,53 @@ concat_6: { ); } } + +concat_7: { + input: { + console.log( + "" + 1, + "" + "1", + "" + 1 + 2, + "" + 1 + "2", + "" + "1" + 2, + "" + "1" + "2", + "" + (x += "foo") + ); + } + expect: { + console.log( + "" + 1, + "1", + "" + 1 + 2, + 1 + "2", + "1" + 2, + "1" + "2", + x += "foo" + ); + } +} + +concat_8: { + input: { + console.log( + 1 + "", + "1" + "", + 1 + 2 + "", + 1 + "2" + "", + "1" + 2 + "", + "1" + "2" + "", + (x += "foo") + "" + ); + } + expect: { + console.log( + 1 + "", + "1", + 1 + 2 + "", + 1 + "2", + "1" + 2, + "1" + "2", + x += "foo" + ); + } +} |