diff --git a/modules/core/src/main/scala/stryker4s/mutants/tree/InstrumenterOptions.scala b/modules/core/src/main/scala/stryker4s/mutants/tree/InstrumenterOptions.scala index 9fc4f2ad2..cf0e816cd 100644 --- a/modules/core/src/main/scala/stryker4s/mutants/tree/InstrumenterOptions.scala +++ b/modules/core/src/main/scala/stryker4s/mutants/tree/InstrumenterOptions.scala @@ -20,7 +20,7 @@ object InstrumenterOptions { def testRunner = InstrumenterOptions( ActiveMutationContext.testRunner, - pattern = i => p"$i", + pattern = Lit.Int(_), condition = Some(ids => q"_root_.stryker4s.coverage.coverMutant(..${ids.map(Lit.Int(_)).toList})") ) } diff --git a/modules/core/src/test/scala/stryker4s/mutants/AddAllMutationsTest.scala b/modules/core/src/test/scala/stryker4s/mutants/AddAllMutationsTest.scala index 0c29687c6..2e145f69d 100644 --- a/modules/core/src/test/scala/stryker4s/mutants/AddAllMutationsTest.scala +++ b/modules/core/src/test/scala/stryker4s/mutants/AddAllMutationsTest.scala @@ -116,7 +116,7 @@ class AddAllMutationsTest extends Stryker4sIOSuite with LogMatchers { file.mutants.toVector.map { mutant => file.mutatedSource .find(mutant.mutatedCode.mutatedStatement) - .flatMap(_ => file.mutatedSource.find(p"${Lit.Int(mutant.id.value)}")) + .flatMap(_ => file.mutatedSource.find(Lit.Int(mutant.id.value))) .getOrElse( fail( s"Could not find mutant ${mutant.id} `${mutant.mutatedCode.metadata.replacement}` (original `${mutant.mutatedCode.metadata.original}`) in mutated tree ${file.mutatedSource}" diff --git a/modules/core/src/test/scala/stryker4s/mutants/tree/MutantInstrumenterTest.scala b/modules/core/src/test/scala/stryker4s/mutants/tree/MutantInstrumenterTest.scala index 4d27f32f3..d6c679e0c 100644 --- a/modules/core/src/test/scala/stryker4s/mutants/tree/MutantInstrumenterTest.scala +++ b/modules/core/src/test/scala/stryker4s/mutants/tree/MutantInstrumenterTest.scala @@ -30,18 +30,18 @@ class MutantInstrumenterTest extends Stryker4sSuite with TestData with LogMatche ) val sut = new MutantInstrumenter(InstrumenterOptions.testRunner) - // // Act + // Act val mutatedSource = sut.instrumentFile(context, mutants).mutatedSource val result = mutatedSource.collectFirst { case t: Term.Match => t }.value - // // Assert + // Assert assertEquals(result.expr, q"_root_.stryker4s.activeMutation") assertEquals( - result.cases.map(_.syntax), + result.cases, List( - p"case 0 => x > 15".syntax, - p"case 1 => x <= 15".syntax, - p"case _ if _root_.stryker4s.coverage.coverMutant(0, 1) => x >= 15".syntax + p"case 0 => x > 15", + p"case 1 => x <= 15", + p"case _ if _root_.stryker4s.coverage.coverMutant(0, 1) => x >= 15" ) ) val expected = source"""class Foo { @@ -82,11 +82,11 @@ class MutantInstrumenterTest extends Stryker4sSuite with TestData with LogMatche // // Assert assertEquals(result.expr, q"_root_.stryker4s.activeMutation") assertEquals( - result.cases.map(_.syntax), + result.cases, List( - p"case 0 => true".syntax, - p"case 1 => false".syntax, - p"case _ if _root_.stryker4s.coverage.coverMutant(0, 1) => bar".syntax + p"case 0 => true", + p"case 1 => false", + p"case _ if _root_.stryker4s.coverage.coverMutant(0, 1) => bar" ) ) val expected = source"""class Foo { @@ -123,8 +123,14 @@ class MutantInstrumenterTest extends Stryker4sSuite with TestData with LogMatche // // Assert assertEquals(result.expr, q"_root_.scala.sys.env.get(${Lit.String("ACTIVE_MUTATION")})") - assertEquals(result.cases.head.pat, p"Some(${Lit.String("0")})") - assertEquals(result.cases.map(_.syntax).last, p"case _ => x >= 15".syntax) + assertEquals( + result.cases, + List( + p"case Some(${Lit.String("0")}) => x > 15", + p"case Some(${Lit.String("1")}) => x <= 15", + p"case _ => x >= 15" + ) + ) } // describe("buildNewSource") { diff --git a/modules/testkit/src/main/scala/stryker4s/testkit/Stryker4sSuite.scala b/modules/testkit/src/main/scala/stryker4s/testkit/Stryker4sSuite.scala index 3e638bcee..c91926dc4 100644 --- a/modules/testkit/src/main/scala/stryker4s/testkit/Stryker4sSuite.scala +++ b/modules/testkit/src/main/scala/stryker4s/testkit/Stryker4sSuite.scala @@ -90,9 +90,15 @@ sealed trait Stryker4sAssertions { /** Compare 2 trees by structure. */ - implicit def treeCompare[A <: Tree, B <: Tree]: Compare[A, B] = (obtained: A, expected: B) => + implicit def treeCompare[A <: Tree, B <: Tree]: Compare[A, B] = (obtained, expected) => obtained == expected || obtained.structure == expected.structure + implicit def listCompare[A, B](implicit compare: Compare[A, B]): Compare[List[A], List[B]] = + (obtained, expected) => + obtained.size == expected.size && + obtained.zip(expected).forall { case (obtained, expected) => + compare.isEqual(obtained, expected) + } } abstract protected[stryker4s] class Stryker4sSuite extends FunSuite with Stryker4sAssertions diff --git a/project/Dependencies.scala b/project/Dependencies.scala index a923f2f04..3df9acb9b 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -3,7 +3,9 @@ import sbt.* object Dependencies { object versions { val scala212 = "2.12.18" + val scala213 = "2.13.12" + val scala3 = "3.3.1" /** Cross-versions for main projects @@ -16,21 +18,34 @@ object Dependencies { // Test dependencies val munit = "1.0.0-M11" + val munitCatsEffect = "2.0.0-M4" // Direct dependencies val catsCore = "2.10.0" + val catsEffect = "3.5.3" + val circe = "0.14.6" + val fansi = "0.4.0" + val fs2 = "3.9.4" + val mutationTestingElements = "3.0.2" + val mutationTestingMetrics = "3.0.2" + val pureconfig = "0.17.5" - val scalameta = "4.8.15" + + val scalameta = "4.9.0" + val slf4j = "2.0.12" + val sttp = "3.9.3" + val testInterface = "1.0" + val weaponRegeX = "1.3.1" }