You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is there a matcher that simultaneously asserts the type of an object and casts it? #923
Notice how I needed to force cast from Error to MyCustomError in order to gain access to the cause property. This force-cast shouldn't ever fail (because of the typecheck on the previous line), but it's still a little crufty.
Is there a build in matcher that can help with this?
Here are some other alternatives I considered:
expect(trysomethingThatThrows()).to(throwError{ error in
iflet error = error as?MyCustomError{expect(error.cause)==POSIXError(.ENOMEM)}else{fail()}
changed the title [-]Is there a matcher that simultaneously asserts the type of an object and casts?[/-][+]Is there a matcher that simultaneously asserts the type of an object and casts it?[/+]on Aug 22, 2021
Activity
[-]Is there a matcher that simultaneously asserts the type of an object and casts?[/-][+]Is there a matcher that simultaneously asserts the type of an object and casts it?[/+]ikesyo commentedon Aug 28, 2021
Nimble/Sources/Nimble/Matchers/ThrowError.swift
Lines 138 to 141 in 2c44aee
Nimble/Tests/NimbleTests/Matchers/ThrowErrorTest.swift
Lines 55 to 59 in 2c44aee
I think this overload is what you want.