-
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.
Fix coverage analysis sometimes being placed incorrectly (#866)
- Loading branch information
1 parent
ebe102f
commit b467533
Showing
3 changed files
with
61 additions
and
12 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
47 changes: 47 additions & 0 deletions
47
core/src/test/scala/stryker4s/mutants/applymutants/CoverageMatchBuilderTest.scala
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,47 @@ | ||
package stryker4s.mutants.applymutants | ||
|
||
import stryker4s.extension.TreeExtensions.IsEqualExtension | ||
import stryker4s.extension.mutationtype.GreaterThan | ||
import stryker4s.model.{Mutant, TransformedMutants} | ||
import stryker4s.scalatest.LogMatchers | ||
import stryker4s.testutil.Stryker4sSuite | ||
|
||
import scala.meta._ | ||
|
||
class CoverageMatchBuilderTest extends Stryker4sSuite with LogMatchers { | ||
describe("buildMatch") { | ||
it("should add coverage analysis to the default case") { | ||
// Arrange | ||
val ids = Iterator.from(0) | ||
val originalStatement = q"x >= 15" | ||
val mutants = List(q"x > 15", q"x <= 15") | ||
.map(Mutant(ids.next(), originalStatement, _, GreaterThan)) | ||
val sut = new CoverageMatchBuilder(ActiveMutationContext.testRunner) | ||
|
||
// Act | ||
val result = sut.buildMatch(TransformedMutants(originalStatement, mutants)).cases.last | ||
|
||
// Assert | ||
assert(result.isEqual(p"case _ if _root_.stryker4s.coverage.coverMutant(0, 1) => x >= 15"), result) | ||
} | ||
|
||
it("should set the mutation switch match to Ints") { | ||
// Arrange | ||
val ids = Iterator.from(0) | ||
val originalStatement = q"x >= 15" | ||
val mutants = List(q"x > 15", q"x <= 15") | ||
.map(Mutant(ids.next(), originalStatement, _, GreaterThan)) | ||
val sut = new CoverageMatchBuilder(ActiveMutationContext.testRunner) | ||
|
||
// Act | ||
val result = sut.buildMatch(TransformedMutants(originalStatement, mutants)).cases.init | ||
|
||
// Assert | ||
result.map(_.syntax) should (contain | ||
.inOrderOnly( | ||
p"case 0 => x > 15".syntax, | ||
p"case 1 => x <= 15".syntax | ||
)) | ||
} | ||
} | ||
} |
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