diff options
author | Ashley (Scirra) <ashley@scirra.com> | 2016-10-27 11:23:04 -0400 |
---|---|---|
committer | Richard van Velzen <rvanvelzen1@gmail.com> | 2016-11-29 20:25:39 +0100 |
commit | 2a9989dd18c01081c486fe9089e3bb64079c773b (patch) | |
tree | be59842ce6761ae625bd9a0d7f79b88c6f38ae2b /test/compress | |
parent | 79b98a9fe87f950607c601a45a3566a46c32f425 (diff) | |
download | tracifyjs-2a9989dd18c01081c486fe9089e3bb64079c773b.tar.gz tracifyjs-2a9989dd18c01081c486fe9089e3bb64079c773b.zip |
Add --mangle-props-debug and fix --mangle-props=unquoted collision
Patch by @AshleyScirra
Based on: PR #1316
Renamed the CLI debug option to --mangle-props-debug
Fixes: #1321 name collision in --mangle-props=unquoted
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/issue-1321.js | 54 | ||||
-rw-r--r-- | test/compress/properties.js | 92 |
2 files changed, 146 insertions, 0 deletions
diff --git a/test/compress/issue-1321.js b/test/compress/issue-1321.js new file mode 100644 index 00000000..2b6f17bf --- /dev/null +++ b/test/compress/issue-1321.js @@ -0,0 +1,54 @@ +issue_1321_no_debug: { + mangle_props = { + ignore_quoted: true + } + input: { + var x = {}; + x.foo = 1; + x["a"] = 2 * x.foo; + console.log(x.foo, x["a"]); + } + expect: { + var x = {}; + x.b = 1; + x["a"] = 2 * x.b; + console.log(x.b, x["a"]); + } +} + +issue_1321_debug: { + mangle_props = { + ignore_quoted: true, + debug: "" + } + input: { + var x = {}; + x.foo = 1; + x["_$foo$_"] = 2 * x.foo; + console.log(x.foo, x["_$foo$_"]); + } + expect: { + var x = {}; + x.a = 1; + x["_$foo$_"] = 2 * x.a; + console.log(x.a, x["_$foo$_"]); + } +} + +issue_1321_with_quoted: { + mangle_props = { + ignore_quoted: false + } + input: { + var x = {}; + x.foo = 1; + x["a"] = 2 * x.foo; + console.log(x.foo, x["a"]); + } + expect: { + var x = {}; + x.a = 1; + x["b"] = 2 * x.a; + console.log(x.a, x["b"]); + } +} diff --git a/test/compress/properties.js b/test/compress/properties.js index f1680808..22f2c339 100644 --- a/test/compress/properties.js +++ b/test/compress/properties.js @@ -142,6 +142,98 @@ mangle_unquoted_properties: { } } +mangle_debug: { + mangle_props = { + debug: "" + }; + input: { + a.foo = "bar"; + x = { baz: "ban" }; + } + expect: { + a._$foo$_ = "bar"; + x = { _$baz$_: "ban" }; + } +} + +mangle_debug_true: { + mangle_props = { + debug: true + }; + input: { + a.foo = "bar"; + x = { baz: "ban" }; + } + expect: { + a._$foo$_ = "bar"; + x = { _$baz$_: "ban" }; + } +} + +mangle_debug_suffix: { + mangle_props = { + debug: "XYZ" + }; + input: { + a.foo = "bar"; + x = { baz: "ban" }; + } + expect: { + a._$foo$XYZ_ = "bar"; + x = { _$baz$XYZ_: "ban" }; + } +} + +mangle_debug_suffix_ignore_quoted: { + options = { + properties: false + } + mangle_props = { + ignore_quoted: true, + debug: "XYZ", + reserved: [] + } + beautify = { + beautify: false, + quote_style: 3, + keep_quoted_props: true, + } + input: { + a.top = 1; + function f1() { + a["foo"] = "bar"; + a.color = "red"; + a.stuff = 2; + x = {"bar": 10, size: 7}; + a.size = 9; + } + function f2() { + a.foo = "bar"; + a['color'] = "red"; + x = {bar: 10, size: 7}; + a.size = 9; + a.stuff = 3; + } + } + expect: { + a._$top$XYZ_ = 1; + function f1() { + a["foo"] = "bar"; + a.color = "red"; + a._$stuff$XYZ_ = 2; + x = {"bar": 10, _$size$XYZ_: 7}; + a._$size$XYZ_ = 9; + } + function f2() { + a.foo = "bar"; + a['color'] = "red"; + x = {bar: 10, _$size$XYZ_: 7}; + a._$size$XYZ_ = 9; + a._$stuff$XYZ_ = 3; + } + } +} + first_256_chars_as_properties: { beautify = { ascii_only: true, |