Skip to content
mutastic

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.

OperatorChangesSet
mutastic/boundary< and <=, > and >=defaults
mutastic/remove-conditionala condition to always true, and to always falsedefaults
mutastic/logical-connector&& and ||defaults
mutastic/comparisona comparison to the one that agrees at the edge and on one sidestronger
mutastic/other-comparisona comparison to each of the othersstronger
swift/remove-guarda guard on a condition taken out, with its elseextended

The mutants each makes, on samples/operators/Sources/Operators/Conditions.swift:

Terminal window
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-guard
Terminal window
mced1b670 Sources/Operators/Conditions.swift:3:6 mutastic/remove-conditional total >= 50 is always false in freeDelivery
m52348099 Sources/Operators/Conditions.swift:3:6 mutastic/remove-conditional total >= 50 is always true in freeDelivery
m7b6a7a8e Sources/Operators/Conditions.swift:3:12 mutastic/boundary >= becomes > in freeDelivery
m8ce8692c Sources/Operators/Conditions.swift:3:12 mutastic/comparison >= becomes == in freeDelivery
me4b328a9 Sources/Operators/Conditions.swift:3:12 mutastic/other-comparison >= becomes != in freeDelivery
m90bd8a78 Sources/Operators/Conditions.swift:3:12 mutastic/other-comparison >= becomes < in freeDelivery
m386f0727 Sources/Operators/Conditions.swift:3:12 mutastic/other-comparison >= becomes <= in freeDelivery
m32e2f3eb Sources/Operators/Conditions.swift:11:8 mutastic/logical-connector paid && inStock becomes paid || inStock in canShip
m10ada993 Sources/Operators/Conditions.swift:16:9 mutastic/remove-conditional let name is always false in greeting
m5d1ad21f Sources/Operators/Conditions.swift:24:3 swift/remove-guard guard items > 0 else { return 0 } is removed in cost
m624e90cc Sources/Operators/Conditions.swift:24:9 mutastic/remove-conditional items > 0 is always false in cost
m56d15c17 Sources/Operators/Conditions.swift:24:15 mutastic/boundary > becomes >= in cost
m2aa3aaab Sources/Operators/Conditions.swift:24:15 mutastic/comparison > becomes != in cost
me793191d Sources/Operators/Conditions.swift:24:15 mutastic/other-comparison > becomes < in cost
mf0dfdc04 Sources/Operators/Conditions.swift:24:15 mutastic/other-comparison > becomes <= in cost
m16d2a8b1 Sources/Operators/Conditions.swift:24:15 mutastic/other-comparison > becomes == in cost
no estimate: no run is recorded here yet; run once to get estimates, or add --estimate
16 mutants

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.

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.

mutastic/logical-connector, in the defaults. && becomes ||, and || becomes &&. It asks for a test where one condition holds and the other doesn’t.

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.

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.

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.