Closed huwr closed 4 years ago
Sounds like a good idea @huwr . Although, I think that might break compatibility with swift 4.2, so we'd need to drop support for it in a new version with this change...?
I think rethrows
has been around since before 4.2. The rethrows
in flatMap
has been there for 3 years: https://github.com/apple/swift/blame/master/stdlib/public/core/SequenceAlgorithms.swift#L756
I believe we can do it while maintaining compatibility.
haha, right. I read "Swift version: 5.1" on https://www.hackingwithswift.com/example-code/language/how-to-use-the-rethrows-keyword and thought that was when it was introduced 😊
Hi,
It'd be great if the
testFunction
from theMockService
could be marked asrethrows
.This will allow us to call throwing functions inside
testFunction
, and for that error to be thrown in turn by theXCTest
function. Errors thrown fromXCTest
funcs fail the test. It is likely that an exception inside thetestFunction
would be a good enough reason to fail the test. This means we won't have to catch the error if all we wanted to do was fail the test.Example of usage would be:
Also means we don't need to use
try!
, which would crash the test.The standard library uses
rethrows
inside sequence algorithms for things likeflatMap
: https://github.com/apple/swift/blob/master/stdlib/public/core/SequenceAlgorithms.swift#L756More on
rethrows
: https://docs.swift.org/swift-book/ReferenceManual/Declarations.html and https://www.hackingwithswift.com/example-code/language/how-to-use-the-rethrows-keyword