Skip to content

Commit

Permalink
Merge pull request #24 from debsourav33/master
Browse files Browse the repository at this point in the history
Fix matching beyond skipPos
  • Loading branch information
agroce authored Mar 9, 2024
2 parents 2fcda9b + dc97bc1 commit ae68084
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions universalmutator/mutator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ae68084

Please sign in to comment.