diff options
Diffstat (limited to 'test/sandbox.js')
-rw-r--r-- | test/sandbox.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/sandbox.js b/test/sandbox.js index 1aee7753..1585c988 100644 --- a/test/sandbox.js +++ b/test/sandbox.js @@ -49,6 +49,14 @@ exports.same_stdout = semver.satisfies(process.version, "0.12") ? function(expec } : function(expected, actual) { return typeof expected == typeof actual && strip_func_ids(expected) == strip_func_ids(actual); }; +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; + return header.slice(0, -1) + " _" + ++count + header.slice(-1); + }); +}; function is_error(result) { return result && typeof result.name == "string" && typeof result.message == "string"; |