diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-07-13 01:51:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-13 01:51:10 +0800 |
commit | bcebacbb9e7ddac7d9c0e4ca2c7e0faf0e0bca7c (patch) | |
tree | fcc19ae9f916dc819753245261f685ac8bb9d34b /test/compress/preserve_line.js | |
parent | 018a5a750a16dce58ab50d943c47ea6cf01a0fbb (diff) | |
download | tracifyjs-bcebacbb9e7ddac7d9c0e4ca2c7e0faf0e0bca7c.tar.gz tracifyjs-bcebacbb9e7ddac7d9c0e4ca2c7e0faf0e0bca7c.zip |
fix corner cases in `preserve_line` (#3212)
Diffstat (limited to 'test/compress/preserve_line.js')
-rw-r--r-- | test/compress/preserve_line.js | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/test/compress/preserve_line.js b/test/compress/preserve_line.js new file mode 100644 index 00000000..5b1638ca --- /dev/null +++ b/test/compress/preserve_line.js @@ -0,0 +1,181 @@ +return_1: { + beautify = { + beautify: false, + preserve_line: true, + } + input: { + console.log(function f() { + return ( + f.toString() != 42 + ); + }()); + } + expect_exact: [ + "console.log(function f(){", + "", + "return 42!=f.toString()}());", + ] + expect_stdout: "true" +} + +return_2: { + beautify = { + beautify: true, + preserve_line: true, + } + input: { + console.log(function f() { + return ( + f.toString() != 42 + ); + }()); + } + expect_exact: [ + "console.log(function f() {", + "", + " return 42 != f.toString();", + "}());", + ] + expect_stdout: "true" +} + +return_3: { + options = {} + beautify = { + beautify: false, + preserve_line: true, + } + input: { + console.log(function f() { + return ( + f.toString() != 42 + ); + }()); + } + expect_exact: [ + "console.log(function f(){", + "", + "return 42!=f.toString()}());", + ] + expect_stdout: "true" +} + +return_4: { + options = {} + beautify = { + beautify: true, + preserve_line: true, + } + input: { + console.log(function f() { + return ( + f.toString() != 42 + ); + }()); + } + expect_exact: [ + "console.log(function f() {", + "", + " return 42 != f.toString();", + "}());", + ] + expect_stdout: "true" +} + +return_5: { + beautify = { + beautify: false, + preserve_line: true, + } + input: { + _is_selected = function(tags, slug) { + var ref; + return (ref = _.find(tags, { + slug: slug + })) != null ? ref.selected : void 0; + }; + } + expect_exact: [ + "_is_selected=function(tags,slug){", + "var ref", + "", + "", + ";return null!=(ref=_.find(tags,{slug:slug}))?ref.selected:void 0};", + ] +} + +return_6: { + beautify = { + beautify: true, + preserve_line: true, + } + input: { + _is_selected = function(tags, slug) { + var ref; + return (ref = _.find(tags, { + slug: slug + })) != null ? ref.selected : void 0; + }; + } + expect_exact: [ + "_is_selected = function(tags, slug) {", + " var ref;", + "", + "", + " return null != (ref = _.find(tags, {", + " slug: slug", + " })) ? ref.selected : void 0;", + "};", + ] +} + +return_7: { + options = {} + mangle = {} + beautify = { + beautify: false, + preserve_line: true, + } + input: { + _is_selected = function(tags, slug) { + var ref; + return (ref = _.find(tags, { + slug: slug + })) != null ? ref.selected : void 0; + }; + } + expect_exact: [ + "_is_selected=function(e,l){", + "var n", + "", + "", + ";return null!=(n=_.find(e,{slug:l}))?n.selected:void 0};", + ] +} + +return_8: { + options = {} + mangle = {} + beautify = { + beautify: true, + preserve_line: true, + } + input: { + _is_selected = function(tags, slug) { + var ref; + return (ref = _.find(tags, { + slug: slug + })) != null ? ref.selected : void 0; + }; + } + expect_exact: [ + "_is_selected = function(e, l) {", + " var n;", + "", + "", + " return null != (n = _.find(e, {", + " slug: l", + " })) ? n.selected : void 0;", + "};", + ] +} |