aboutsummaryrefslogtreecommitdiff
path: root/test/ufuzz
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-08-26 02:32:55 +0100
committerGitHub <noreply@github.com>2020-08-26 09:32:55 +0800
commitc7a3e09407fbed928ccd874609c63c31b27f052a (patch)
treefd7275ff6e548d206439ba3d1461a7f73b014596 /test/ufuzz
parent09525c7530fb305c7b60c470ee9bab3510beb8f0 (diff)
downloadtracifyjs-c7a3e09407fbed928ccd874609c63c31b27f052a.tar.gz
tracifyjs-c7a3e09407fbed928ccd874609c63c31b27f052a.zip
enhance `loops` & `unused` (#4074)
- extend `ufuzz` generation of for-in loops
Diffstat (limited to 'test/ufuzz')
-rw-r--r--test/ufuzz/index.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js
index 9e8ca8dc..60f86667 100644
--- a/test/ufuzz/index.js
+++ b/test/ufuzz/index.js
@@ -496,11 +496,16 @@ function createStatement(recurmax, canThrow, canBreak, canContinue, cannotReturn
var label = createLabel(canBreak, canContinue);
canBreak = label.break || enableLoopControl(canBreak, CAN_BREAK);
canContinue = label.continue || enableLoopControl(canContinue, CAN_CONTINUE);
- var optElementVar = "";
- if (rng(5) > 1) {
- optElementVar = "c = 1 + c; var " + createVarName(MANDATORY) + " = expr" + loop + "[key" + loop + "]; ";
- }
- return "{var expr" + loop + " = " + createExpression(recurmax, COMMA_OK, stmtDepth, canThrow) + "; " + label.target + " for (var key" + loop + " in expr" + loop + ") {" + optElementVar + createStatement(recurmax, canThrow, canBreak, canContinue, cannotReturn, stmtDepth) + "}}";
+ var key = rng(10) ? "key" + loop : getVarName();
+ return [
+ "{var expr" + loop + " = " + createExpression(recurmax, COMMA_OK, stmtDepth, canThrow) + "; ",
+ label.target + " for (",
+ /^key/.test(key) ? "var " : "",
+ key + " in expr" + loop + ") {",
+ rng(5) > 1 ? "c = 1 + c; var " + createVarName(MANDATORY) + " = expr" + loop + "[" + key + "]; " : "",
+ createStatement(recurmax, canThrow, canBreak, canContinue, cannotReturn, stmtDepth),
+ "}}",
+ ].join("");
case STMT_SEMI:
return use_strict && rng(20) === 0 ? '"use strict";' : ";";
case STMT_EXPR: