diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-12-05 02:43:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-05 02:43:25 +0800 |
commit | 04fbb1f94978884128ef1582405a77a1974c6522 (patch) | |
tree | eef527edb15a5cc142ce04eb49ae93936c9c8070 /test/compress | |
parent | bf7e4ca1a3b1305308c66fcdf188d31a398c4ba2 (diff) | |
download | tracifyjs-04fbb1f94978884128ef1582405a77a1974c6522.tar.gz tracifyjs-04fbb1f94978884128ef1582405a77a1974c6522.zip |
avoid collision with HTML comments (#3625)
fixes #3624
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/html_comments.js | 92 |
1 files changed, 72 insertions, 20 deletions
diff --git a/test/compress/html_comments.js b/test/compress/html_comments.js index fe6ff8ac..e208b36d 100644 --- a/test/compress/html_comments.js +++ b/test/compress/html_comments.js @@ -1,55 +1,107 @@ html_comment_in_expression: { input: { - function f(a, b, x, y) { return a < !--b && x-- > y; } + (function(a, b) { + console.log(a < !--b && a-- > b, a, b); + })(1, 2); } - expect_exact: "function f(a,b,x,y){return a< !--b&&x-- >y}"; + expect_exact: "(function(a,b){console.log(a<! --b&&a-- >b,a,b)})(1,2);" + expect_stdout: "false 1 1" } html_comment_in_less_than: { input: { - function f(a, b) { return a < !--b; } + (function(a, b, c) { + console.log( + a < !--b, + a < !--b + c, + a + b < !--c, + a, b, c + ); + })(1, 2, 3); } - expect_exact: "function f(a,b){return a< !--b}"; + expect_exact: "(function(a,b,c){console.log(a<! --b,a<! --b+c,a+b<! --c,a,b,c)})(1,2,3);" + expect_stdout: "false true false 1 0 2" } html_comment_in_left_shift: { input: { - function f(a, b) { return a << !--b; } + (function(a, b, c) { + console.log( + a << !--b, + a << !--b + c, + a + b << !--c, + a, b, c + ); + })(1, 2, 3); } - expect_exact: "function f(a,b){return a<< !--b}"; + expect_exact: "(function(a,b,c){console.log(a<<! --b,a<<! --b+c,a+b<<! --c,a,b,c)})(1,2,3);" + expect_stdout: "1 16 1 1 0 2" } -html_comment_in_right_shift: { +html_comment_in_greater_than: { input: { - function f(a, b) { return a-- >> b; } + (function(a, b, c) { + console.log( + a-- > b, + a-- > b + c, + a + b-- > c, + a, b, c + ); + })(1, 2, 3); } - expect_exact: "function f(a,b){return a-- >>b}"; + expect_exact: "(function(a,b,c){console.log(a-- >b,a-- >b+c,a+b-- >c,a,b,c)})(1,2,3);" + expect_stdout: "false false false -1 1 3" } -html_comment_in_zero_fill_right_shift: { +html_comment_in_greater_than_or_equal: { input: { - function f(a, b) { return a-- >>> b; } + (function(a, b, c) { + console.log( + a-- >= b, + a-- >= b + c, + a + b-- >= c, + a, b, c + ); + })(1, 2, 3); } - expect_exact: "function f(a,b){return a-- >>>b}"; + expect_exact: "(function(a,b,c){console.log(a-- >=b,a-- >=b+c,a+b-- >=c,a,b,c)})(1,2,3);" + expect_stdout: "false false false -1 1 3" } -html_comment_in_greater_than: { +html_comment_in_right_shift: { input: { - function f(a, b) { return a-- > b; } + (function(a, b, c) { + console.log( + a-- >> b, + a-- >> b + c, + a + b-- >> c, + a, b, c + ); + })(1, 2, 3); } - expect_exact: "function f(a,b){return a-- >b}"; + expect_exact: "(function(a,b,c){console.log(a-- >>b,a-- >>b+c,a+b-- >>c,a,b,c)})(1,2,3);" + expect_stdout: "0 0 0 -1 1 3" } -html_comment_in_greater_than_or_equal: { +html_comment_in_zero_fill_right_shift: { input: { - function f(a, b) { return a-- >= b; } + (function(a, b, c) { + console.log( + a-- >>> b, + a-- >>> b + c, + a + b-- >>> c, + a, b, c + ); + })(1, 2, 3); } - expect_exact: "function f(a,b){return a-- >=b}"; + expect_exact: "(function(a,b,c){console.log(a-- >>>b,a-- >>>b+c,a+b-- >>>c,a,b,c)})(1,2,3);" + expect_stdout: "0 0 0 -1 1 3" } html_comment_in_string_literal: { input: { - function f() { return "<!--HTML-->comment in<!--string literal-->"; } + console.log("<!--HTML-->comment in<!--string literal-->".length); } - expect_exact: 'function f(){return"\\x3c!--HTML--\\x3ecomment in\\x3c!--string literal--\\x3e"}'; + expect_exact: 'console.log("\\x3c!--HTML--\\x3ecomment in\\x3c!--string literal--\\x3e".length);' + expect_stdout: "42" } |