diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/loops.js | 32 | ||||
-rw-r--r-- | test/ufuzz/index.js | 15 |
2 files changed, 41 insertions, 6 deletions
diff --git a/test/compress/loops.js b/test/compress/loops.js index aef1b90b..4a276b9e 100644 --- a/test/compress/loops.js +++ b/test/compress/loops.js @@ -756,7 +756,37 @@ empty_for_in_side_effects: { expect_warnings: [ "WARN: Dropping unused variable b [test/compress/loops.js:4,16]", "INFO: Dropping unused loop variable a [test/compress/loops.js:1,17]", - "WARN: Side effects in object of for-in loop [test/compress/loops.js:1,17]", + "WARN: Side effects in object of for-in loop [test/compress/loops.js:2,17]", + ] +} + +empty_for_in_prop_init: { + options = { + loops: true, + pure_getters: "strict", + unused: true, + } + input: { + console.log(function f() { + var a = "bar"; + for ((a, f)[a] in console.log("foo")); + return a; + }()); + } + expect: { + console.log(function() { + var a = "bar"; + console.log("foo"); + return a; + }()); + } + expect_stdout: [ + "foo", + "bar", + ] + expect_warnings: [ + "INFO: Dropping unused loop variable f [test/compress/loops.js:3,21]", + "WARN: Side effects in object of for-in loop [test/compress/loops.js:3,30]", ] } 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: |