aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-05-07 20:21:44 +0100
committerGitHub <noreply@github.com>2020-05-08 03:21:44 +0800
commita441b009517125fa2e0cdf10150c6fd77bbb54ae (patch)
tree7f44b081d37361aafc7d7ffcae9859722fe755ba
parent88985a46ed771f312f799853740ec2ba4f87ea03 (diff)
downloadtracifyjs-a441b009517125fa2e0cdf10150c6fd77bbb54ae.tar.gz
tracifyjs-a441b009517125fa2e0cdf10150c6fd77bbb54ae.zip
suppress `ufuzz` false positives (#3855)
-rw-r--r--test/ufuzz/index.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js
index 83823cee..9ccbef1f 100644
--- a/test/ufuzz/index.js
+++ b/test/ufuzz/index.js
@@ -1141,6 +1141,14 @@ 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++) {
@@ -1159,6 +1167,11 @@ for (var round = 1; round <= num_iterations; round++) {
uglify_code = uglify_code.code;
uglify_result = sandbox.run_code(uglify_code, toplevel);
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));
+ }
+ // ignore numerical imprecision caused by `unsafe_math`
if (!ok && typeof uglify_result == "string" && o.compress && o.compress.unsafe_math) {
ok = fuzzy_match(original_result, uglify_result);
if (!ok) {