diff --git a/src/tint/fuzzers/tint_regex_fuzzer/wgsl_mutator.cc b/src/tint/fuzzers/tint_regex_fuzzer/wgsl_mutator.cc index c5125a4143..7d16aadc72 100644 --- a/src/tint/fuzzers/tint_regex_fuzzer/wgsl_mutator.cc +++ b/src/tint/fuzzers/tint_regex_fuzzer/wgsl_mutator.cc @@ -416,7 +416,7 @@ std::string WgslMutator::ChooseRandomReplacementForOperator(const std::string& e "=", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>="}; std::vector expression_operators{"+", "-", "*", "/", "%", "&&", "||", "&", "|", "^", "<<", ">>", "<", ">", - "<=", ">=", "!", "!=", "~"}; + "<=", ">=", "!", "==", "!=", "~"}; std::vector increment_operators{"++", "--"}; for (auto operators : {assignment_operators, expression_operators, increment_operators}) { auto it = std::find(operators.begin(), operators.end(), existing_operator); @@ -471,6 +471,12 @@ std::optional> WgslMutator::FindOperatorOccurrence switch (first_character) { case '!': case '^': + case '*': + case '/': + case '%': + case '=': + // The above cases are all stand-alone operators, and if followed by '=' are also + // operators. switch (second_character) { case '=': return {{current_index, 2}}; @@ -481,26 +487,15 @@ std::optional> WgslMutator::FindOperatorOccurrence case '&': case '+': case '-': + // The above cases are all stand-alone operators, and if repeated or followed by '=' + // are also operators. if (second_character == first_character || second_character == '=') { return {{current_index, 2}}; } return {{current_index, 1}}; - case '*': - case '/': - case '%': - switch (second_character) { - case '=': - return {{current_index, 2}}; - default: - return {{current_index, 1}}; - } - case '=': - if (second_character == '=') { - return {{current_index, 2}}; - } - return {{current_index, 1}}; case '<': case '>': + // The following caters for '<', '<=', '<<', '<<=', '>', '>=', '>>' and '>>='. if (second_character == '=') { return {{current_index, 2}}; }