diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-05-13 12:57:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-13 19:57:36 +0800 |
commit | 3c1898fd65a63e1bed7fe813e69f45ee79e2019a (patch) | |
tree | d7d8a1fcec9664c948ee1f92742cb70c1b8ab733 | |
parent | e04429350f4eff1299afe84967d15093abc091ff (diff) | |
download | tracifyjs-3c1898fd65a63e1bed7fe813e69f45ee79e2019a.tar.gz tracifyjs-3c1898fd65a63e1bed7fe813e69f45ee79e2019a.zip |
suppress invalid test case generation (#4930)
-rw-r--r-- | test/reduce.js | 5 | ||||
-rw-r--r-- | test/ufuzz/index.js | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/test/reduce.js b/test/reduce.js index 4b3d3fe6..3f154fa7 100644 --- a/test/reduce.js +++ b/test/reduce.js @@ -132,6 +132,8 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options) return; } if (parent instanceof U.AST_VarDef && parent.name === node) return; + // preserve class methods + if (parent instanceof U.AST_ClassMethod && parent.value === node) return; // preserve exports if (parent instanceof U.AST_ExportDeclaration) return; if (parent instanceof U.AST_ExportDefault) return; @@ -147,6 +149,9 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options) if (parent instanceof U.AST_For && parent.init === node && node instanceof U.AST_Definitions) return node; // preserve for (xxx in/of ...) if (parent instanceof U.AST_ForEnumeration && parent.init === node) return node; + // preserve super(...) + if (node.TYPE == "Call" && node.expression instanceof U.AST_Super) return; + if (node instanceof U.AST_Super && parent.TYPE == "Call" && parent.expression === node) return node; // node specific permutations with no parent logic diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js index 55832547..09375ecb 100644 --- a/test/ufuzz/index.js +++ b/test/ufuzz/index.js @@ -356,6 +356,7 @@ var block_vars = []; var lambda_vars = []; var unique_vars = []; var classes = []; +var allow_this = true; var async = false; var has_await = false; var export_default = false; @@ -402,6 +403,7 @@ function createTopLevelCode() { lambda_vars.length = 0; unique_vars.length = 0; classes.length = 0; + allow_this = true; async = false; has_await = false; export_default = false; @@ -1731,6 +1733,8 @@ function createObjectFunction(recurmax, stmtDepth, canThrow, internal, isClazz) fn = function(defns) { if (generator) name = "*" + name; if (async) name = "async "+ name; + var save_allow = allow_this; + if (internal == "super") allow_this = false; s = [ name + "(" + createParams(save_async, save_generator, NO_DUPLICATE) + "){", strictMode(), @@ -1738,6 +1742,7 @@ function createObjectFunction(recurmax, stmtDepth, canThrow, internal, isClazz) ]; s.push(_createStatements(2, recurmax, canThrow, CANNOT_BREAK, CANNOT_CONTINUE, CANNOT_RETURN, stmtDepth)); if (internal == "super") s.push("super" + createArgs(recurmax, stmtDepth, canThrow, NO_TEMPLATE) + ";"); + allow_this = save_allow; if (/^(constructor|super)$/.test(internal) || rng(10) == 0) for (var i = rng(4); --i >= 0;) { s.push(rng(2) ? createSuperAssignment(recurmax, stmtDepth, canThrow) : createThisAssignment(recurmax, stmtDepth, canThrow)); } @@ -1974,7 +1979,7 @@ function createValue() { var v; do { v = VALUES[rng(VALUES.length)]; - } while (v == "new.target" && rng(200)); + } while (v == "new.target" && rng(200) || !allow_this && v == "this"); return v; } @@ -2298,7 +2303,7 @@ function is_error_in(ex) { } function is_error_spread(ex) { - return ex.name == "TypeError" && /Found non-callable @@iterator| is not iterable| is not a function/.test(ex.message); + return ex.name == "TypeError" && /Found non-callable @@iterator| is not iterable| not a function/.test(ex.message); } function is_error_recursion(ex) { |