From dc97bc199d90c7fcdcb392dc47dffd07965b5910 Mon Sep 17 00:00:00 2001 From: debsourav33 Date: Fri, 8 Mar 2024 19:47:04 -0700 Subject: [PATCH] fix matching beyond skipPos --- universalmutator/mutator.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/universalmutator/mutator.py b/universalmutator/mutator.py index 330e182..8222f23 100644 --- a/universalmutator/mutator.py +++ b/universalmutator/mutator.py @@ -180,10 +180,12 @@ def mutants(source, ruleFiles=["universal.rules"], mutateTestCode=False, mutateB skipp = skipRule.search(l, 0) if skipp and (skipp.start() < skipPos): skipPos = skipp.start() - pos = 0 - p = lhs.search(l, pos) - while p and (pos < skipPos): - pos = p.start() + 1 + + + p = lhs.search(l, 0) + + # skip mutating if match occurs at index >= skipPos + while p and (p.start() < skipPos): try: mutant = l[:p.start()] + lhs.sub(rhs, l[p.start():], count=1) except KeyboardInterrupt: @@ -233,7 +235,8 @@ def mutants(source, ruleFiles=["universal.rules"], mutateTestCode=False, mutateB if (mutant != l) and ((lineno, mutant) not in produced) and (not skipDueToString): mutants.append((lineno, mutant, ruleUsed, (lhs,rhs))) produced[(lineno, mutant)] = True - p = lhs.search(l, pos) + + p = lhs.search(l, p.start()+1) #search from the next position of the current match if abandon: break