diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-02-27 02:15:14 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-27 10:15:14 +0800 |
commit | e6ebf827ce8eaf75b0ad137aa19d09da2c03df46 (patch) | |
tree | 5a7ea57681bcd5de18e465b3ed44b6e01631801f /test | |
parent | 0a42457df64944187a069b26491fcebd8ce55ce0 (diff) | |
download | tracifyjs-e6ebf827ce8eaf75b0ad137aa19d09da2c03df46.tar.gz tracifyjs-e6ebf827ce8eaf75b0ad137aa19d09da2c03df46.zip |
fix corner cases with `export` (#4699)
fixes #4698
fixes #4700
fixes #4701
fixes #4702
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/exports.js | 21 | ||||
-rw-r--r-- | test/sandbox.js | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/test/compress/exports.js b/test/compress/exports.js index c573223d..2da1ee33 100644 --- a/test/compress/exports.js +++ b/test/compress/exports.js @@ -70,6 +70,27 @@ defaults_parentheses_4: { expect_exact: "export default(function f(){});" } +defaults_parentheses_5: { + input: { + export default (function(a) { + console.log(a[0]); + }`PASS`); + } + expect_exact: "export default(function(a){console.log(a[0])})`PASS`;" +} + +defaults_parentheses_6: { + options = { + conditionals: true, + } + input: { + export default !function() { + while (!console); + }() ? "PASS" : "FAIL"; + } + expect_exact: 'export default(function(){while(!console);})()?"FAIL":"PASS";' +} + foreign: { input: { export * from "foo"; diff --git a/test/sandbox.js b/test/sandbox.js index 1585c988..ceaf0088 100644 --- a/test/sandbox.js +++ b/test/sandbox.js @@ -53,7 +53,7 @@ exports.strip_exports = function(code) { var count = 0; return code.replace(/\bexport(?:\s*\{[^}]*};|\s+default\b(?:\s*(\(|\{|class\s*\{|class\s+(?=extends\b)|(?:async\s+)?function\s*(?:\*\s*)?\())?|\b)/g, function(match, header) { if (!header) return ""; - if (header.length == 1) return "~" + header; + if (header.length == 1) return "!!" + header; return header.slice(0, -1) + " _" + ++count + header.slice(-1); }); }; |