File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ extension Mutation {
3333 replacement: $0. mutate ( )
3434 )
3535 }
36+ . drop { $0. replacement == file. code }
3637 . uniqued ( on: \. replacement)
3738
3839 return Array ( mutants)
Original file line number Diff line number Diff line change @@ -16,8 +16,8 @@ struct MutationTests {
1616 #expect( mutants. isEmpty)
1717 }
1818
19- @Test ( " no change" )
20- func noChange ( ) throws {
19+ @Test ( " change " )
20+ func change ( ) throws {
2121
2222 let mutation = Mutation ( name: " test " ) { file in
2323 [ Mutation . Change ( start: . start, end: . end) { " replacement " } ]
@@ -34,6 +34,18 @@ struct MutationTests {
3434 #expect( mutants [ 0 ] . original == " original " )
3535 #expect( mutants [ 0 ] . replacement == " replacement " )
3636 }
37+
38+ @Test ( " no changes " )
39+ func noChanges( ) throws {
40+
41+ let mutation = Mutation ( name: " test " ) { file in
42+ [ Mutation . Change ( start: . start, end: . end) { file. code } ]
43+ }
44+
45+ let file = Source . File ( name: " name " , path: " path " , code: " original " )
46+ let mutants = mutation. mutants ( for: file)
47+ #expect( mutants. isEmpty)
48+ }
3749 }
3850
3951 @Suite ( " Name " )
Original file line number Diff line number Diff line change @@ -70,4 +70,24 @@ struct SyntaxMutationTests {
7070 let name = " Daniel "
7171 """ )
7272 }
73+
74+ @Test ( " non changes are not counted " )
75+ func nonChanges( ) {
76+
77+ final class Visitor : MutationVisitor {
78+
79+ override func visit( _ node: CodeBlockItemListSyntax ) -> SyntaxVisitorContinueKind {
80+ record ( before: node, after: node)
81+ return super. visit ( node)
82+ }
83+ }
84+
85+ let mutation = Mutation ( name: " Replace File " , visitor: Visitor . self)
86+ let file = Source . File ( name: " name " , path: " path " , code: """
87+ let name = " Daniel "
88+ """ )
89+
90+ let mutants = mutation. mutants ( for: file)
91+ #expect( mutants. isEmpty)
92+ }
7393}
You can’t perform that action at this time.
0 commit comments