Make mutations patch-based
This commit is contained in:
parent
10ddbef963
commit
2dc2c288fb
3 changed files with 21 additions and 20 deletions
|
|
@ -6,17 +6,22 @@ open Xunit
|
||||||
|
|
||||||
type CalculatorTests() =
|
type CalculatorTests() =
|
||||||
[<Fact>]
|
[<Fact>]
|
||||||
[<MutationCase("calc-add-one", "Example.Tests/Calculator.fs", 4, "value + 1", "value - 1")>]
|
[<MutationCase("""
|
||||||
member _.AddOne_increments() =
|
diff --git a/Example.Tests/Calculator.fs b/Example.Tests/Calculator.fs
|
||||||
Assert.Equal(42, Calculator.addOne 41)
|
index cfcce3b..39be7f3 100644
|
||||||
|
--- a/Example.Tests/Calculator.fs
|
||||||
|
+++ b/Example.Tests/Calculator.fs
|
||||||
|
@@ -1,7 +1,7 @@
|
||||||
|
namespace Example
|
||||||
|
|
||||||
[<Fact>]
|
module Calculator =
|
||||||
[<MutationCase("calc-abs-diff-branch", "Example.Tests/Calculator.fs", 7, "left - right", "right - left")>]
|
- let addOne value = value + 1
|
||||||
member _.AbsoluteDifference_preserves_order() =
|
+ let addOne value = value - 1
|
||||||
Assert.Equal(7, Calculator.absoluteDifference 10 3)
|
|
||||||
|
|
||||||
[<Fact>]
|
let absoluteDifference left right =
|
||||||
[<MutationCase("calc-leap-year-century", "Example.Tests/Calculator.fs", 10, "year % 100 <> 0", "year % 100 = 0")>]
|
if left >= right then left - right else right - left
|
||||||
member _.LeapYear_handles_centuries() =
|
|
||||||
Assert.True(Calculator.isLeapYear 2000)
|
member _.AddOne_increments() =
|
||||||
Assert.False(Calculator.isLeapYear 1900)
|
Assert.Equal(42, Calculator.addOne 41)
|
||||||
|
""")>]
|
||||||
|
member _.AddOne_increments() = Assert.Equal(42, Calculator.addOne 41)
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,7 @@ namespace Mutannot
|
||||||
open System
|
open System
|
||||||
|
|
||||||
[<AttributeUsage(AttributeTargets.Method, AllowMultiple = true)>]
|
[<AttributeUsage(AttributeTargets.Method, AllowMultiple = true)>]
|
||||||
type MutationCaseAttribute(id: string, file: string, line: int, find: string, replace: string) =
|
type MutationCaseAttribute(patch: string) =
|
||||||
inherit Attribute()
|
inherit Attribute()
|
||||||
|
|
||||||
member _.Id = id
|
member _.Patch = patch
|
||||||
member _.File = file
|
|
||||||
member _.Line = line
|
|
||||||
member _.Find = find
|
|
||||||
member _.Replace = replace
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ open System.Reflection
|
||||||
open System.Runtime.InteropServices
|
open System.Runtime.InteropServices
|
||||||
open Fli
|
open Fli
|
||||||
|
|
||||||
type MutationCase = { TestName: string; Id: string }
|
type MutationCase = { TestName: string; Patch: string }
|
||||||
|
|
||||||
let ensureBuilt projectPath =
|
let ensureBuilt projectPath =
|
||||||
cli {
|
cli {
|
||||||
|
|
@ -60,7 +60,7 @@ let getMutationCases projectPath =
|
||||||
| "Mutannot.MutationCaseAttribute" ->
|
| "Mutannot.MutationCaseAttribute" ->
|
||||||
Some
|
Some
|
||||||
{ TestName = $"{m.DeclaringType.FullName}.{m.Name}"
|
{ TestName = $"{m.DeclaringType.FullName}.{m.Name}"
|
||||||
Id = attr.ConstructorArguments[0].Value :?> string }
|
Patch = attr.ConstructorArguments[0].Value :?> string }
|
||||||
| _ -> None))
|
| _ -> None))
|
||||||
|> Seq.toList
|
|> Seq.toList
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue