From 2dc2c288fb41e984c1e7f25d48615e32816c3681 Mon Sep 17 00:00:00 2001 From: Sven van Heugten Date: Tue, 12 May 2026 08:07:43 +0200 Subject: [PATCH] Make mutations patch-based --- Example.Tests/CalculatorTests.fs | 29 +++++++++++++++----------- Example.Tests/MutationCaseAttribute.fs | 8 ++----- Mutannot/Program.fs | 4 ++-- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Example.Tests/CalculatorTests.fs b/Example.Tests/CalculatorTests.fs index 40f9b66..0a96e10 100644 --- a/Example.Tests/CalculatorTests.fs +++ b/Example.Tests/CalculatorTests.fs @@ -6,17 +6,22 @@ open Xunit type CalculatorTests() = [] - [] - member _.AddOne_increments() = - Assert.Equal(42, Calculator.addOne 41) + [] - [] - member _.AbsoluteDifference_preserves_order() = - Assert.Equal(7, Calculator.absoluteDifference 10 3) + module Calculator = + - let addOne value = value + 1 + + let addOne value = value - 1 - [] - [ 0", "year % 100 = 0")>] - member _.LeapYear_handles_centuries() = - Assert.True(Calculator.isLeapYear 2000) - Assert.False(Calculator.isLeapYear 1900) + let absoluteDifference left right = + if left >= right then left - right else right - left + + member _.AddOne_increments() = + Assert.Equal(42, Calculator.addOne 41) + """)>] + member _.AddOne_increments() = Assert.Equal(42, Calculator.addOne 41) diff --git a/Example.Tests/MutationCaseAttribute.fs b/Example.Tests/MutationCaseAttribute.fs index 12e6475..f1175e4 100644 --- a/Example.Tests/MutationCaseAttribute.fs +++ b/Example.Tests/MutationCaseAttribute.fs @@ -3,11 +3,7 @@ namespace Mutannot open System [] -type MutationCaseAttribute(id: string, file: string, line: int, find: string, replace: string) = +type MutationCaseAttribute(patch: string) = inherit Attribute() - member _.Id = id - member _.File = file - member _.Line = line - member _.Find = find - member _.Replace = replace + member _.Patch = patch diff --git a/Mutannot/Program.fs b/Mutannot/Program.fs index 5c3a1ac..6cd78aa 100644 --- a/Mutannot/Program.fs +++ b/Mutannot/Program.fs @@ -4,7 +4,7 @@ open System.Reflection open System.Runtime.InteropServices open Fli -type MutationCase = { TestName: string; Id: string } +type MutationCase = { TestName: string; Patch: string } let ensureBuilt projectPath = cli { @@ -60,7 +60,7 @@ let getMutationCases projectPath = | "Mutannot.MutationCaseAttribute" -> Some { TestName = $"{m.DeclaringType.FullName}.{m.Name}" - Id = attr.ConstructorArguments[0].Value :?> string } + Patch = attr.ConstructorArguments[0].Value :?> string } | _ -> None)) |> Seq.toList