diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-06-10 00:28:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-10 07:28:56 +0800 |
commit | 2a9d0fc6fb06a55b878551326aa8b72f21fbfa91 (patch) | |
tree | f178295269b0cecb721b6ee9a98bbc901cc92893 /test/ufuzz/index.js | |
parent | 45db96679ea1a4c8ce943874178a1d26ad0abc5c (diff) | |
download | tracifyjs-2a9d0fc6fb06a55b878551326aa8b72f21fbfa91.tar.gz tracifyjs-2a9d0fc6fb06a55b878551326aa8b72f21fbfa91.zip |
improve false positive detection in `ufuzz` (#3982)
Diffstat (limited to 'test/ufuzz/index.js')
-rw-r--r-- | test/ufuzz/index.js | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js index b8a09c06..006b4ca7 100644 --- a/test/ufuzz/index.js +++ b/test/ufuzz/index.js @@ -1167,6 +1167,10 @@ function log(options) { } } +function sort_globals(code) { + return "var " + sandbox.run_code("throw Object.keys(this).sort();" + code).join(",") + ";" + code; +} + function fuzzy_match(original, uglified) { uglified = uglified.split(" "); var i = uglified.length; @@ -1245,14 +1249,6 @@ var fallback_options = [ JSON.stringify({ mangle: false }) ]; var minify_options = require("./options.json").map(JSON.stringify); -var sort_globals = [ - "Object.keys(this).sort().forEach(function(name) {", - " var value = this[name];", - " delete this[name];", - " this[name] = value;", - "});", - "", -].join("\n"); var original_code, original_result, errored; var uglify_code, uglify_result, ok; for (var round = 1; round <= num_iterations; round++) { @@ -1274,7 +1270,7 @@ for (var round = 1; round <= num_iterations; round++) { ok = sandbox.same_stdout(original_result, uglify_result); // ignore declaration order of global variables if (!ok && !toplevel) { - ok = sandbox.same_stdout(sandbox.run_code(sort_globals + original_code), sandbox.run_code(sort_globals + uglify_code)); + ok = sandbox.same_stdout(sandbox.run_code(sort_globals(original_code)), sandbox.run_code(sort_globals(uglify_code))); } // ignore numerical imprecision caused by `unsafe_math` if (!ok && typeof uglify_result == "string" && o.compress && o.compress.unsafe_math) { |