Adopt typed throws in the implementation of #expect()
/#require()
.
#1336
+281
−195
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adopts typed throws (
throws(E)
instead ofthrows
) in the#expect()
and#require()
macros' declarations and in their implementations. In particular, the return type of the implementation functions changes fromResult<R, any Error>
toResult<R, ExpectationFailedError>
and all implementation functions that take a closure have been updated with an additional genericE
parameter.#expect(throws:)
and#require(throws:)
take two generic error types,EExpected
andEActual
. The former is the error type specified by the test author, while the latter is the actual error type inferred from the body closure. In common usage, both will resolve toany Error
.The deprecated
#expect {} throws: {}
and#require {} throws: {}
variants are marked@_unavailableInEmbedded
and continue to useany Error
.If you see
throws(any Error)
in the diff, take it as meaning that section of the code was audited, but for now we don't have something better to use thanany Error
.Checklist: