expand `ufuzz` patterns (#3761)
authorAlex Lam S.L <alexlamsl@gmail.com>
Sun, 5 Apr 2020 14:12:46 +0000 (15:12 +0100)
committerGitHub <noreply@github.com>
Sun, 5 Apr 2020 14:12:46 +0000 (22:12 +0800)
test/ufuzz/index.js

index 76a782e..24bf86d 100644 (file)
@@ -704,7 +704,6 @@ function _createExpression(recurmax, noComma, stmtDepth, canThrow) {
             break;
         }
         VAR_NAMES.length = nameLenBefore;
-        if (canThrow && rng(8) == 0 && !/^new /.test(s[0])) s[s.length - 1] += "()";
         return filterDirective(s).join("\n");
       case p++:
       case p++:
@@ -773,6 +772,12 @@ function _createExpression(recurmax, noComma, stmtDepth, canThrow) {
       case p++:
       case p++:
       case p++:
+        if (rng(16) == 0) {
+            var name = getVarName();
+            var fn = name + "." + getDotKey();
+            called[name] = true;
+            return name + " && " + "typeof " + fn + ' == "function" && --_calls_ >= 0 && ' + fn + "(" + createArgs(recurmax, stmtDepth, canThrow) + ")";
+        }
         var name = rng(3) == 0 ? getVarName() : "f" + rng(funcs + 2);
         called[name] = true;
         return "typeof " + name + ' == "function" && --_calls_ >= 0 && ' + name + "(" + createArgs(recurmax, stmtDepth, canThrow) + ")";