Swift edition
Returns and errors
Operators that change what a function gives back, or what happens when the code it calls throws.
| Operator | Changes | Set |
|---|---|---|
mutastic/return-value | a returned value to a plain one | defaults |
mutastic/unwrap-try | try to try! | defaults |
swift/try-nil | try? to nil | extended |
The mutants each makes, on samples/operators/Sources/Operators/Returns.swift:
mutastic mutants samples/operators --at=Sources/Operators/Returns.swift:1-99 --operators=mutastic/return-value,mutastic/unwrap-try,swift/try-nilm744350a0 Sources/Operators/Returns.swift:9:10 mutastic/return-value returns 0 instead in quantitym9f1b2d06 Sources/Operators/Returns.swift:14:14 mutastic/unwrap-try try becomes try! in doubledmec14e21a Sources/Operators/Returns.swift:15:10 mutastic/return-value returns 0 instead in doubledm7af31f52 Sources/Operators/Returns.swift:20:15 swift/try-nil try? quantity(text) becomes nil in maybeQuantitym19078168 Sources/Operators/Returns.swift:21:10 mutastic/return-value returns nil instead in maybeQuantityno estimate: no run is recorded here yet; run once to get estimates, or add --estimate5 mutantsReturn value
Section titled “Return value”mutastic/return-value, in the defaults. A returned value is replaced by a plain one of its type: 0, or 1 where the code returns 0; true or false; ""; nil for an optional. It asks whether any test looks at what the function returns.
Unwrap try
Section titled “Unwrap try”mutastic/unwrap-try, in the defaults. A try becomes try!, so an error thrown there crashes instead of reaching the code that handles it. It asks for a test where the call throws.
Try nil
Section titled “Try nil”swift/try-nil, in extended and all, not in the defaults or stronger. Swift’s own. A try? whose value is used gives nil, as if what it tried had thrown. It asks for a test where the call works, and one where it doesn’t.
- Every operator, in one table.