aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-07-12 21:10:59 +0100
committerGitHub <noreply@github.com>2021-07-13 04:10:59 +0800
commit8e2dff632e2c6e696b8bd874f61ec1685306da41 (patch)
tree38c2d170fb6d92abe4f085b833f95d8004cbcb1a /test
parent92c3fddd7ae57a69de6f4e3448ae4a06b18f2fc6 (diff)
downloadtracifyjs-8e2dff632e2c6e696b8bd874f61ec1685306da41.tar.gz
tracifyjs-8e2dff632e2c6e696b8bd874f61ec1685306da41.zip
suppress false positives in `ufuzz` (#5078)
Diffstat (limited to 'test')
-rw-r--r--test/ufuzz/index.js26
1 files changed, 23 insertions, 3 deletions
diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js
index 09375ecb..b10367e8 100644
--- a/test/ufuzz/index.js
+++ b/test/ufuzz/index.js
@@ -2256,7 +2256,7 @@ function sort_globals(code) {
return (typeof global[n] == "function") - (typeof global[m] == "function")
|| (m < n ? -1 : m > n ? 1 : 0);
};
- } + "(this));" + code);
+ } + "(this));\n" + code);
if (!Array.isArray(globals)) {
errorln();
errorln();
@@ -2294,6 +2294,20 @@ function fuzzy_match(original, uglified) {
}
}
+function patch_proto() {
+ [ Array, Boolean, Error, Function, Number, Object, RegExp, String ].forEach(function(type) {
+ [ "toString", "valueOf" ].forEach(function(prop) {
+ type.prototype[prop] = function(fn) {
+ return function() {
+ try {
+ return fn.apply(this, arguments);
+ } catch (e) {}
+ };
+ }(type.prototype[prop]);
+ });
+ });
+}
+
function is_error_timeout(ex) {
return /timed out/.test(ex.message);
}
@@ -2500,8 +2514,8 @@ for (var round = 1; round <= num_iterations; round++) {
if (!ok && errored && uglify_result.name == "ReferenceError" && original_result.name == "ReferenceError") ok = true;
// ignore difference due to implicit strict-mode in `class`
if (!ok && /\bclass\b/.test(original_code)) {
- var original_strict = run_code('"use strict";' + original_code, toplevel);
- var uglify_strict = run_code('"use strict";' + uglify_code, toplevel);
+ var original_strict = run_code('"use strict";\n' + original_code, toplevel);
+ var uglify_strict = run_code('"use strict";\n' + uglify_code, toplevel);
if (typeof original_strict != "string") {
ok = typeof uglify_strict != "string";
} else {
@@ -2512,6 +2526,12 @@ for (var round = 1; round <= num_iterations; round++) {
if (!ok && errored && /\bimport\b/.test(original_code)) {
if (is_error_redeclaration(uglify_result) && is_error_redeclaration(original_result)) ok = true;
}
+ // ignore difference due to `__proto__` assignment
+ if (!ok && /\b__proto__\b/.test(original_code)) {
+ var original_proto = run_code("(" + patch_proto + ")();\n" + original_code, toplevel);
+ var uglify_proto = run_code("(" + patch_proto + ")();\n" + uglify_code, toplevel);
+ ok = sandbox.same_stdout(original_proto, uglify_proto);
+ }
// ignore difference in error message caused by `in`
if (!ok && errored && is_error_in(uglify_result) && is_error_in(original_result)) ok = true;
// ignore difference in error message caused by spread syntax