Swift edition
Conditions
Operators that change a comparison, a condition, or how two conditions combine. Together they ask whether your tests look at both sides of every decision, and at its edge.
| Operator | Changes | Set |
|---|---|---|
mutastic/boundary | < and <=, > and >= | defaults |
mutastic/remove-conditional | a condition to always true, and to always false | defaults |
mutastic/logical-connector | && and || | defaults |
mutastic/comparison | a comparison to the one that agrees at the edge and on one side | stronger |
mutastic/other-comparison | a comparison to each of the others | stronger |
swift/remove-guard | a guard on a condition taken out, with its else | extended |
The mutants each makes, on samples/operators/Sources/Operators/Conditions.swift:
mutastic mutants samples/operators --at=Sources/Operators/Conditions.swift:1-99 --operators=mutastic/boundary,mutastic/remove-conditional,mutastic/logical-connector,mutastic/comparison,mutastic/other-comparison,swift/remove-guardmced1b670 Sources/Operators/Conditions.swift:3:6 mutastic/remove-conditional total >= 50 is always false in freeDeliverym52348099 Sources/Operators/Conditions.swift:3:6 mutastic/remove-conditional total >= 50 is always true in freeDeliverym7b6a7a8e Sources/Operators/Conditions.swift:3:12 mutastic/boundary >= becomes > in freeDeliverym8ce8692c Sources/Operators/Conditions.swift:3:12 mutastic/comparison >= becomes == in freeDeliveryme4b328a9 Sources/Operators/Conditions.swift:3:12 mutastic/other-comparison >= becomes != in freeDeliverym90bd8a78 Sources/Operators/Conditions.swift:3:12 mutastic/other-comparison >= becomes < in freeDeliverym386f0727 Sources/Operators/Conditions.swift:3:12 mutastic/other-comparison >= becomes <= in freeDeliverym32e2f3eb Sources/Operators/Conditions.swift:11:8 mutastic/logical-connector paid && inStock becomes paid || inStock in canShipm10ada993 Sources/Operators/Conditions.swift:16:9 mutastic/remove-conditional let name is always false in greetingm5d1ad21f Sources/Operators/Conditions.swift:24:3 swift/remove-guard guard items > 0 else { return 0 } is removed in costm624e90cc Sources/Operators/Conditions.swift:24:9 mutastic/remove-conditional items > 0 is always false in costm56d15c17 Sources/Operators/Conditions.swift:24:15 mutastic/boundary > becomes >= in costm2aa3aaab Sources/Operators/Conditions.swift:24:15 mutastic/comparison > becomes != in costme793191d Sources/Operators/Conditions.swift:24:15 mutastic/other-comparison > becomes < in costmf0dfdc04 Sources/Operators/Conditions.swift:24:15 mutastic/other-comparison > becomes <= in costm16d2a8b1 Sources/Operators/Conditions.swift:24:15 mutastic/other-comparison > becomes == in costno estimate: no run is recorded here yet; run once to get estimates, or add --estimate16 mutantsBoundary
Section titled “Boundary”mutastic/boundary, in the defaults. < becomes <=, >= becomes >, and the other way round. It finds the off-by-one at the edge of a rule, free delivery from 50 say, which tests that only try values far from the edge never notice.
Remove conditional
Section titled “Remove conditional”mutastic/remove-conditional, in the defaults. A condition is made always true, and in another mutant always false, so both sides of the decision have to matter to a test. An if let or a guard let is made never to bind, as if the value were nil.
Logical connector
Section titled “Logical connector”mutastic/logical-connector, in the defaults. && becomes ||, and || becomes &&. It asks for a test where one condition holds and the other doesn’t.
Comparison
Section titled “Comparison”mutastic/comparison, in stronger. < and > become !=, <= and >= become ==, == becomes <= and >=, and != becomes < and >: each agrees with the original on one side of the edge, so only a test on the other side tells them apart.
Other comparison
Section titled “Other comparison”mutastic/other-comparison, in stronger. Each comparison that mutastic/boundary and mutastic/comparison don’t make, >= to < and != say. Most are caught by the tests that catch those two; the ones that aren’t are worth a look.
Remove guard
Section titled “Remove guard”swift/remove-guard, in extended and all, not in the defaults or stronger. Swift’s own. A guard on a condition is removed, so the code after it runs whatever the condition says. A guard let isn’t removed, as the code after it uses what it binds: mutastic/remove-conditional makes it never bind instead.
- Every operator, in one table.