From e1b2026929623b3b0a771f2297c98c0f5e1ba1c9 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Mon, 21 Dec 2020 07:32:50 +0000 Subject: improve object function generation in `ufuzz` (#4434) --- test/ufuzz/index.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'test/ufuzz/index.js') diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js index 73f78300..d554d644 100644 --- a/test/ufuzz/index.js +++ b/test/ufuzz/index.js @@ -1267,10 +1267,10 @@ function createObjectFunction(recurmax, stmtDepth, canThrow) { var nameLenBefore = VAR_NAMES.length; var save_async = async; var s; + var name = createObjectKey(recurmax, stmtDepth, canThrow); createBlockVariables(recurmax, stmtDepth, canThrow, function(defns) { switch (rng(SUPPORT.computed_key ? 3 : 2)) { case 0: - var name = createObjectKey(recurmax, stmtDepth, canThrow); async = false; s = [ "get " + name + "(){", @@ -1282,23 +1282,21 @@ function createObjectFunction(recurmax, stmtDepth, canThrow) { ]; break; case 1: - var prop1 = createObjectKey(recurmax, stmtDepth, canThrow); - var prop2; + var prop; do { - prop2 = getDotKey(); - } while (prop1 == prop2); + prop = getDotKey(); + } while (name == prop); async = false; s = [ - "set " + prop1 + "(" + createVarName(MANDATORY) + "){", + "set " + name + "(" + createVarName(MANDATORY) + "){", strictMode(), defns(), _createStatements(2, recurmax, canThrow, CANNOT_BREAK, CANNOT_CONTINUE, CAN_RETURN, stmtDepth), - "this." + prop2 + createAssignment() + _createBinaryExpr(recurmax, COMMA_OK, stmtDepth, canThrow) + ";", + "this." + prop + createAssignment() + _createBinaryExpr(recurmax, COMMA_OK, stmtDepth, canThrow) + ";", "},", ]; break; default: - var name = createObjectKey(recurmax, stmtDepth, canThrow); async = SUPPORT.async && rng(50) == 0; s = [ (async ? "async " : "") + name + "(" + createParams(save_async, NO_DUPLICATE) + "){", -- cgit v1.2.3