-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify canPlace algorithm and fix instrumenter recursively placing …
…mutants (#1432) - canPlace algorithm is simpler, only matching on certain blocks (we might've missed some types, but this is definitely a simpler implementation) - Instrumenter now properly recursively places mutants. Before when a mutation switch was placed, it would not properly place mutations inside or above that node
- Loading branch information
1 parent
ab60d9f
commit 9a18b44
Showing
13 changed files
with
181 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package stryker4s.mutants | ||
|
||
import cats.syntax.all.* | ||
import stryker4s.extension.TreeExtensions.TreeIsInExtension | ||
import stryker4s.extension.mutationtype.ParentIsTypeLiteral | ||
|
||
import scala.meta.* | ||
|
||
trait TreeTraverser { | ||
|
||
/** If the currently visiting node is a node where mutations can be placed, that node is returned, otherwise None | ||
*/ | ||
def canPlace(currentTree: Tree): Option[Term] | ||
|
||
} | ||
|
||
final class TreeTraverserImpl() extends TreeTraverser { | ||
|
||
def canPlace(currentTree: Tree): Option[Term] = { | ||
currentTree.parent | ||
.filter { | ||
case ParentIsTypeLiteral() => false | ||
case name: Name => !name.isDefinition | ||
case t if t.is[Init] => false | ||
|
||
case d: Defn.Def if d.body == currentTree => true | ||
case d: Defn.Val if d.rhs == currentTree => true | ||
case d: Defn.Var if d.body == currentTree => true | ||
case _: Term.Block => true | ||
case t: Term.Function if t.body == currentTree => true | ||
case t: Case if t.body == currentTree => true | ||
case t: Term.ForYield if t.body == currentTree => true | ||
case t: Template if t.stats.contains(currentTree) => true | ||
case _ => false | ||
} | ||
.filterNot(_.isIn[Mod.Annot]) | ||
.as(currentTree) | ||
.collect { case t: Term => t } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.