diff --git a/Sources/Nimble/Matchers/BeAKindOf.swift b/Sources/Nimble/Matchers/BeAKindOf.swift index 6b010ece0..48261b3e0 100644 --- a/Sources/Nimble/Matchers/BeAKindOf.swift +++ b/Sources/Nimble/Matchers/BeAKindOf.swift @@ -6,7 +6,7 @@ private func matcherMessage(forClass expectedClass: AnyClass) -> String { } /// A Nimble matcher that succeeds when the actual value is an instance of the given class. -public func beAKindOf(_ expectedType: T.Type) -> Matcher { +public func beAKindOf(_ expectedType: T.Type) -> Matcher { return Matcher.define { actualExpression in let message: ExpectationMessage diff --git a/Sources/Nimble/Matchers/BeAnInstanceOf.swift b/Sources/Nimble/Matchers/BeAnInstanceOf.swift index d8a13112f..9d55b9efa 100644 --- a/Sources/Nimble/Matchers/BeAnInstanceOf.swift +++ b/Sources/Nimble/Matchers/BeAnInstanceOf.swift @@ -1,7 +1,7 @@ import Foundation /// A Nimble matcher that succeeds when the actual value is an _exact_ instance of the given class. -public func beAnInstanceOf(_ expectedType: T.Type) -> Matcher { +public func beAnInstanceOf(_ expectedType: T.Type) -> Matcher { let errorMessage = "be an instance of \(String(describing: expectedType))" return Matcher.define { actualExpression in let instance = try actualExpression.evaluate() diff --git a/Tests/NimbleTests/Matchers/BeAKindOfTest.swift b/Tests/NimbleTests/Matchers/BeAKindOfTest.swift index 93bf7b9fa..3d8fa1609 100644 --- a/Tests/NimbleTests/Matchers/BeAKindOfTest.swift +++ b/Tests/NimbleTests/Matchers/BeAKindOfTest.swift @@ -34,6 +34,12 @@ final class BeAKindOfSwiftTest: XCTestCase { expect(testProtocolStruct).toNot(beAKindOf(TestClassConformingToProtocol.self)) } + func testNestedMatchers() { + // This test is successful if it even compiles. + let result: Result = .success(1) + expect(result).to(beSuccess(beAKindOf(Int.self))) + } + func testFailureMessages() { failsWithErrorMessage("expected to not be a kind of Int, got ") { expect(1).toNot(beAKindOf(Int.self)) diff --git a/Tests/NimbleTests/Matchers/BeAnInstanceOfTest.swift b/Tests/NimbleTests/Matchers/BeAnInstanceOfTest.swift index 820ee5d50..393fba1ae 100644 --- a/Tests/NimbleTests/Matchers/BeAnInstanceOfTest.swift +++ b/Tests/NimbleTests/Matchers/BeAnInstanceOfTest.swift @@ -36,6 +36,12 @@ final class BeAnInstanceOfTest: XCTestCase { expect(testProtocolStruct).toNot(beAnInstanceOf(TestClassConformingToProtocol.self)) } + func testNestedMatchers() { + // This test is successful if it even compiles. + let result: Result = .success(1) + expect(result).to(beSuccess(beAnInstanceOf(Int.self))) + } + func testFailureMessages() { failsWithErrorMessageForNil("expected to not be an instance of NSNull, got ") { expect(nil as NSNull?).toNot(beAnInstanceOf(NSNull.self))