diff --git a/Sources/Nimble/Matchers/BeginWith.swift b/Sources/Nimble/Matchers/BeginWith.swift index 31cbe5dfc..276fd3bbc 100644 --- a/Sources/Nimble/Matchers/BeginWith.swift +++ b/Sources/Nimble/Matchers/BeginWith.swift @@ -50,7 +50,7 @@ extension NMBObjCMatcher { public class func beginWithMatcher(_ expected: Any) -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in let actual = try! actualExpression.evaluate() - if let _ = actual as? String { + if (actual as? String) != nil { let expr = actualExpression.cast { $0 as? String } return try! beginWith(expected as! String).matches(expr, failureMessage: failureMessage) } else { diff --git a/Sources/Nimble/Matchers/EndWith.swift b/Sources/Nimble/Matchers/EndWith.swift index 00c7e2024..e56890517 100644 --- a/Sources/Nimble/Matchers/EndWith.swift +++ b/Sources/Nimble/Matchers/EndWith.swift @@ -59,7 +59,7 @@ extension NMBObjCMatcher { public class func endWithMatcher(_ expected: Any) -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in let actual = try! actualExpression.evaluate() - if let _ = actual as? String { + if (actual as? String) != nil { let expr = actualExpression.cast { $0 as? String } return try! endWith(expected as! String).matches(expr, failureMessage: failureMessage) } else { diff --git a/Sources/Nimble/Matchers/RaisesException.swift b/Sources/Nimble/Matchers/RaisesException.swift index 2867a1b16..b59b6f493 100644 --- a/Sources/Nimble/Matchers/RaisesException.swift +++ b/Sources/Nimble/Matchers/RaisesException.swift @@ -52,7 +52,7 @@ internal func setFailureMessageForException( if let userInfo = userInfo { failureMessage.postfixMessage += " with userInfo <\(userInfo)>" } - if let _ = closure { + if closure != nil { failureMessage.postfixMessage += " that satisfies block" } if named == nil && reason == nil && userInfo == nil && closure == nil { diff --git a/Sources/Nimble/Utils/Errors.swift b/Sources/Nimble/Utils/Errors.swift index 6caab9e6e..5cd5c5367 100644 --- a/Sources/Nimble/Utils/Errors.swift +++ b/Sources/Nimble/Utils/Errors.swift @@ -16,7 +16,7 @@ internal func setFailureMessageForError( } else if errorType != nil || closure != nil { failureMessage.postfixMessage += " from type <\(T.self)>" } - if let _ = closure { + if closure != nil { failureMessage.postfixMessage += " that satisfies block" } if error == nil && errorType == nil && closure == nil { @@ -101,7 +101,7 @@ internal func setFailureMessageForError( closure: ((Error) -> Void)?) { failureMessage.postfixMessage = "throw error" - if let _ = closure { + if closure != nil { failureMessage.postfixMessage += " that satisfies block" } else { failureMessage.postfixMessage = "throw any error"