File tree Expand file tree Collapse file tree 4 files changed +14
-2
lines changed
Tests/NimbleTests/Matchers Expand file tree Collapse file tree 4 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ private func matcherMessage(forClass expectedClass: AnyClass) -> String {
66}
77
88/// A Nimble matcher that succeeds when the actual value is an instance of the given class.
9- public func beAKindOf< T> ( _ expectedType: T . Type ) -> Matcher < Any > {
9+ public func beAKindOf< T, U > ( _ expectedType: T . Type ) -> Matcher < U > {
1010 return Matcher . define { actualExpression in
1111 let message : ExpectationMessage
1212
Original file line number Diff line number Diff line change 11import Foundation
22
33/// A Nimble matcher that succeeds when the actual value is an _exact_ instance of the given class.
4- public func beAnInstanceOf< T> ( _ expectedType: T . Type ) -> Matcher < Any > {
4+ public func beAnInstanceOf< T, U > ( _ expectedType: T . Type ) -> Matcher < U > {
55 let errorMessage = " be an instance of \( String ( describing: expectedType) ) "
66 return Matcher . define { actualExpression in
77 let instance = try actualExpression. evaluate ( )
Original file line number Diff line number Diff line change @@ -34,6 +34,12 @@ final class BeAKindOfSwiftTest: XCTestCase {
3434 expect ( testProtocolStruct) . toNot ( beAKindOf ( TestClassConformingToProtocol . self) )
3535 }
3636
37+ func testNestedMatchers( ) {
38+ // This test is successful if it even compiles.
39+ let result : Result < Int , Error > = . success( 1 )
40+ expect ( result) . to ( beSuccess ( beAKindOf ( Int . self) ) )
41+ }
42+
3743 func testFailureMessages( ) {
3844 failsWithErrorMessage ( " expected to not be a kind of Int, got <Int instance> " ) {
3945 expect ( 1 ) . toNot ( beAKindOf ( Int . self) )
Original file line number Diff line number Diff line change @@ -36,6 +36,12 @@ final class BeAnInstanceOfTest: XCTestCase {
3636 expect ( testProtocolStruct) . toNot ( beAnInstanceOf ( TestClassConformingToProtocol . self) )
3737 }
3838
39+ func testNestedMatchers( ) {
40+ // This test is successful if it even compiles.
41+ let result : Result < Int , Error > = . success( 1 )
42+ expect ( result) . to ( beSuccess ( beAnInstanceOf ( Int . self) ) )
43+ }
44+
3945 func testFailureMessages( ) {
4046 failsWithErrorMessageForNil ( " expected to not be an instance of NSNull, got <nil> " ) {
4147 expect ( nil as NSNull ? ) . toNot ( beAnInstanceOf ( NSNull . self) )
You can’t perform that action at this time.
0 commit comments