diff --git a/Nimble.xcodeproj/project.pbxproj b/Nimble.xcodeproj/project.pbxproj index 318a85a6c..c11d5ebc7 100644 --- a/Nimble.xcodeproj/project.pbxproj +++ b/Nimble.xcodeproj/project.pbxproj @@ -54,11 +54,8 @@ 1F1871E11CA89EF600A34BF2 /* NMBExceptionCapture.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F1871BE1CA89EDB00A34BF2 /* NMBExceptionCapture.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1F1871E21CA89EF600A34BF2 /* NMBStringify.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F1871C01CA89EDB00A34BF2 /* NMBStringify.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1F1871E41CA89FB600A34BF2 /* Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F1871E31CA89FB600A34BF2 /* Async.swift */; }; - 1F1871E61CA89FCD00A34BF2 /* MatcherFunc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F1871E51CA89FCD00A34BF2 /* MatcherFunc.swift */; }; 1F1871E71CA8A18400A34BF2 /* Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F1871E31CA89FB600A34BF2 /* Async.swift */; }; 1F1871E81CA8A18400A34BF2 /* Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F1871E31CA89FB600A34BF2 /* Async.swift */; }; - 1F1871E91CA8A18700A34BF2 /* MatcherFunc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F1871E51CA89FCD00A34BF2 /* MatcherFunc.swift */; }; - 1F1871EB1CA8A18800A34BF2 /* MatcherFunc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F1871E51CA89FCD00A34BF2 /* MatcherFunc.swift */; }; 1F1A742F1940169200FFFC47 /* Nimble.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F1A742E1940169200FFFC47 /* Nimble.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1F1A74351940169200FFFC47 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1A74291940169200FFFC47 /* Nimble.framework */; }; 1F1B5AD41963E13900CA8BF9 /* BeAKindOfTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F1B5AD31963E13900CA8BF9 /* BeAKindOfTest.swift */; }; @@ -357,9 +354,6 @@ B20058C620E92CE400C1264D /* ElementsEqualTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B20058C420E92CE400C1264D /* ElementsEqualTest.swift */; }; B20058C720E92CE400C1264D /* ElementsEqualTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B20058C420E92CE400C1264D /* ElementsEqualTest.swift */; }; CD3D9A79232647BC00802581 /* CwlCatchBadInstructionPosix.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD3D9A78232647BC00802581 /* CwlCatchBadInstructionPosix.swift */; }; - CD4C8F092464365300A7BDE0 /* SynchronousDeprecatedTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD4C8F082464365300A7BDE0 /* SynchronousDeprecatedTest.swift */; }; - CD4C8F0A2464365300A7BDE0 /* SynchronousDeprecatedTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD4C8F082464365300A7BDE0 /* SynchronousDeprecatedTest.swift */; }; - CD4C8F0B2464365300A7BDE0 /* SynchronousDeprecatedTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD4C8F082464365300A7BDE0 /* SynchronousDeprecatedTest.swift */; }; CD79C99E1D2CC832004B6F9A /* ObjCAsyncTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F4A56651A3B305F009E1637 /* ObjCAsyncTest.m */; }; CD79C99F1D2CC835004B6F9A /* ObjCSyncTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F8A37AF1B7C5042001C8357 /* ObjCSyncTest.m */; }; CD79C9A01D2CC839004B6F9A /* ObjCBeAnInstanceOfTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F4A56691A3B3108009E1637 /* ObjCBeAnInstanceOfTest.m */; }; @@ -514,7 +508,6 @@ 1F1871C31CA89EDB00A34BF2 /* NMBObjCMatcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NMBObjCMatcher.swift; sourceTree = ""; }; 1F1871CD1CA89EE000A34BF2 /* ExceptionCapture.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExceptionCapture.swift; sourceTree = ""; }; 1F1871E31CA89FB600A34BF2 /* Async.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Async.swift; sourceTree = ""; }; - 1F1871E51CA89FCD00A34BF2 /* MatcherFunc.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MatcherFunc.swift; sourceTree = ""; }; 1F1A74291940169200FFFC47 /* Nimble.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Nimble.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 1F1A742D1940169200FFFC47 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1F1A742E1940169200FFFC47 /* Nimble.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Nimble.h; sourceTree = ""; }; @@ -630,7 +623,6 @@ B20058C020E92C7500C1264D /* ElementsEqual.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElementsEqual.swift; sourceTree = ""; }; B20058C420E92CE400C1264D /* ElementsEqualTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElementsEqualTest.swift; sourceTree = ""; }; CD3D9A78232647BC00802581 /* CwlCatchBadInstructionPosix.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CwlCatchBadInstructionPosix.swift; sourceTree = ""; }; - CD4C8F082464365300A7BDE0 /* SynchronousDeprecatedTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SynchronousDeprecatedTest.swift; sourceTree = ""; }; CDBC39B82462EA7D00069677 /* PredicateTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PredicateTest.swift; sourceTree = ""; }; CDC157902511957100EAA480 /* DSLTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DSLTest.swift; sourceTree = ""; }; CDFB6A1E1F7E07C600AD8CC7 /* CwlCatchException.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CwlCatchException.swift; sourceTree = ""; }; @@ -787,7 +779,6 @@ CDC157902511957100EAA480 /* DSLTest.swift */, CDBC39B82462EA7D00069677 /* PredicateTest.swift */, 1F0648D31963AAB2001F9C46 /* SynchronousTest.swift */, - CD4C8F082464365300A7BDE0 /* SynchronousDeprecatedTest.swift */, 1F925EE5195C121200ED456B /* AsynchronousTest.swift */, 965B0D0B1B62C06D0005AE66 /* UserDescriptionTest.swift */, 6CAEDD091CAEA86F003F1584 /* LinuxSupport.swift */, @@ -887,7 +878,6 @@ 1FD8CD1C1968AB07008ED995 /* Equal.swift */, 472FD1341B9E085700C7B8DA /* HaveCount.swift */, DDB4D5EC19FE43C200E9D9FE /* Match.swift */, - 1F1871E51CA89FCD00A34BF2 /* MatcherFunc.swift */, 1FD8CD1D1968AB07008ED995 /* MatcherProtocols.swift */, AE7ADE441C80BF8000B94CD3 /* MatchError.swift */, 1FCF91521C61C8A400B15DCB /* PostNotification.swift */, @@ -1377,7 +1367,6 @@ 1FD8CD441968AB07008ED995 /* BeginWith.swift in Sources */, 1FD8CD4A1968AB07008ED995 /* BeIdenticalTo.swift in Sources */, 1FE661581E6574E30035F243 /* ExpectationMessage.swift in Sources */, - 1F1871E61CA89FCD00A34BF2 /* MatcherFunc.swift in Sources */, 1FD8CD421968AB07008ED995 /* BeEmpty.swift in Sources */, 1F1871E41CA89FB600A34BF2 /* Async.swift in Sources */, 1F1871CA1CA89EDB00A34BF2 /* NMBStringify.m in Sources */, @@ -1433,7 +1422,6 @@ 1F925EF9195C175000ED456B /* BeNilTest.swift in Sources */, CDC157922511957100EAA480 /* DSLTest.swift in Sources */, 7A6AB2C31E7F547E00A2F694 /* ToSucceedTest.swift in Sources */, - CD4C8F0A2464365300A7BDE0 /* SynchronousDeprecatedTest.swift in Sources */, A8A3B707207368F000E25A08 /* ObjCSatisfyAllOfTest.m in Sources */, 1F4A56701A3B319F009E1637 /* ObjCBeCloseToTest.m in Sources */, 1F4A56971A3B34AA009E1637 /* ObjCEndWithTest.m in Sources */, @@ -1520,7 +1508,6 @@ 1F5DF16D1BDCA0F500C3A531 /* AdapterProtocols.swift in Sources */, 1F5DF17B1BDCA0F500C3A531 /* BeginWith.swift in Sources */, 1F5DF17E1BDCA0F500C3A531 /* BeIdenticalTo.swift in Sources */, - 1F1871E91CA8A18700A34BF2 /* MatcherFunc.swift in Sources */, 1F5DF17A1BDCA0F500C3A531 /* BeEmpty.swift in Sources */, 1F5DF18C1BDCA0F500C3A531 /* Await.swift in Sources */, 1F1871D81CA89EEF00A34BF2 /* NMBStringify.m in Sources */, @@ -1574,7 +1561,6 @@ 1F5DF1921BDCA10200C3A531 /* AsynchronousTest.swift in Sources */, CDC157932511957100EAA480 /* DSLTest.swift in Sources */, 1F5DF1A91BDCA10200C3A531 /* MatchTest.swift in Sources */, - CD4C8F0B2464365300A7BDE0 /* SynchronousDeprecatedTest.swift in Sources */, A8A3B708207368F100E25A08 /* ObjCSatisfyAllOfTest.m in Sources */, 1F5DF1A81BDCA10200C3A531 /* HaveCountTest.swift in Sources */, 1F5DF1971BDCA10200C3A531 /* AllPassTest.swift in Sources */, @@ -1664,7 +1650,6 @@ 1FD8CD491968AB07008ED995 /* BeGreaterThanOrEqualTo.swift in Sources */, 1FE661571E6574E30035F243 /* ExpectationMessage.swift in Sources */, 1FD8CD451968AB07008ED995 /* BeginWith.swift in Sources */, - 1F1871EB1CA8A18800A34BF2 /* MatcherFunc.swift in Sources */, 1FD8CD4B1968AB07008ED995 /* BeIdenticalTo.swift in Sources */, 1FD8CD431968AB07008ED995 /* BeEmpty.swift in Sources */, 1F1871D41CA89EEE00A34BF2 /* NMBStringify.m in Sources */, @@ -1720,7 +1705,6 @@ 1F4A56771A3B3253009E1637 /* ObjCBeGreaterThanTest.m in Sources */, CDC157912511957100EAA480 /* DSLTest.swift in Sources */, 1F925EFA195C175000ED456B /* BeNilTest.swift in Sources */, - CD4C8F092464365300A7BDE0 /* SynchronousDeprecatedTest.swift in Sources */, 7A6AB2C21E7F547E00A2F694 /* ToSucceedTest.swift in Sources */, A8A3B706207368EF00E25A08 /* ObjCSatisfyAllOfTest.m in Sources */, 1F4A56711A3B319F009E1637 /* ObjCBeCloseToTest.m in Sources */, diff --git a/Sources/Nimble/Expectation.swift b/Sources/Nimble/Expectation.swift index 9906c70f2..a365b417b 100644 --- a/Sources/Nimble/Expectation.swift +++ b/Sources/Nimble/Expectation.swift @@ -64,48 +64,6 @@ public struct Expectation { handler.assert(pass, message: message, location: expression.location) } - ////////////////// OLD API ///////////////////// - - /// DEPRECATED: Tests the actual value using a matcher to match. - @available(*, deprecated, message: "Use Predicate instead") - @discardableResult - public func to(_ matcher: U, description: String? = nil) -> Self - where U: Matcher, U.ValueType == T { - let (pass, msg) = execute( - expression, - .toMatch, - matcher.predicate, - to: "to", - description: description, - captureExceptions: false - ) - verify(pass, msg) - return self - } - - /// DEPRECATED: Tests the actual value using a matcher to not match. - @available(*, deprecated, message: "Use Predicate instead") - @discardableResult - public func toNot(_ matcher: U, description: String? = nil) -> Self - where U: Matcher, U.ValueType == T { - // swiftlint:disable:next line_length - let (pass, msg) = expressionDoesNotMatch(expression, matcher: matcher, toNot: "to not", description: description) - verify(pass, msg) - return self - } - - /// DEPRECATED: Tests the actual value using a matcher to not match. - /// - /// Alias to toNot(). - @available(*, deprecated, message: "Use Predicate instead") - @discardableResult - public func notTo(_ matcher: U, description: String? = nil) -> Self - where U: Matcher, U.ValueType == T { - return toNot(matcher, description: description) - } - - ////////////////// NEW API ///////////////////// - /// Tests the actual value using a matcher to match. @discardableResult public func to(_ predicate: Predicate, description: String? = nil) -> Self { diff --git a/Sources/Nimble/Matchers/AllPass.swift b/Sources/Nimble/Matchers/AllPass.swift index f067aff3e..0e041c749 100644 --- a/Sources/Nimble/Matchers/AllPass.swift +++ b/Sources/Nimble/Matchers/AllPass.swift @@ -17,11 +17,6 @@ public func allPass( return createPredicate(matcher) } -@available(*, deprecated, message: "Use Predicate instead") -public func allPass(_ elementMatcher: M) -> Predicate where S.Element == M.ValueType { - return createPredicate(elementMatcher.predicate) -} - public func allPass(_ elementPredicate: Predicate) -> Predicate { return createPredicate(elementPredicate) } diff --git a/Sources/Nimble/Matchers/Async.swift b/Sources/Nimble/Matchers/Async.swift index dc5e5eddd..02f2535a2 100644 --- a/Sources/Nimble/Matchers/Async.swift +++ b/Sources/Nimble/Matchers/Async.swift @@ -115,75 +115,3 @@ extension Expectation { return toEventuallyNot(predicate, timeout: timeout, pollInterval: pollInterval, description: description) } } - -@available(*, deprecated, message: "Use Predicate instead") -extension Expectation { - /// Tests the actual value using a matcher to match by checking continuously - /// at each pollInterval until the timeout is reached. - /// - /// @discussion - /// This function manages the main run loop (`NSRunLoop.mainRunLoop()`) while this function - /// is executing. Any attempts to touch the run loop may cause non-deterministic behavior. - public func toEventually(_ matcher: U, timeout: DispatchTimeInterval = AsyncDefaults.timeout, pollInterval: DispatchTimeInterval = AsyncDefaults.pollInterval, description: String? = nil) - where U: Matcher, U.ValueType == T { - if expression.isClosure { - let (pass, msg) = execute( - expression, - .toMatch, - async( - style: .toMatch, - predicate: matcher.predicate, - timeout: timeout, - poll: pollInterval, - fnName: "toEventually" - ), - to: "to eventually", - description: description, - captureExceptions: false - ) - verify(pass, msg) - } else { - verify(false, toEventuallyRequiresClosureError) - } - } - - /// Tests the actual value using a matcher to not match by checking - /// continuously at each pollInterval until the timeout is reached. - /// - /// @discussion - /// This function manages the main run loop (`NSRunLoop.mainRunLoop()`) while this function - /// is executing. Any attempts to touch the run loop may cause non-deterministic behavior. - public func toEventuallyNot(_ matcher: U, timeout: DispatchTimeInterval = AsyncDefaults.timeout, pollInterval: DispatchTimeInterval = AsyncDefaults.pollInterval, description: String? = nil) - where U: Matcher, U.ValueType == T { - if expression.isClosure { - let (pass, msg) = expressionDoesNotMatch( - expression, - matcher: async( - style: .toNotMatch, - predicate: matcher.predicate, - timeout: timeout, - poll: pollInterval, - fnName: "toEventuallyNot" - ), - toNot: "to eventually not", - description: description - ) - verify(pass, msg) - } else { - verify(false, toEventuallyRequiresClosureError) - } - } - - /// Tests the actual value using a matcher to not match by checking - /// continuously at each pollInterval until the timeout is reached. - /// - /// Alias of toEventuallyNot() - /// - /// @discussion - /// This function manages the main run loop (`NSRunLoop.mainRunLoop()`) while this function - /// is executing. Any attempts to touch the run loop may cause non-deterministic behavior. - public func toNotEventually(_ matcher: U, timeout: DispatchTimeInterval = AsyncDefaults.timeout, pollInterval: DispatchTimeInterval = AsyncDefaults.pollInterval, description: String? = nil) - where U: Matcher, U.ValueType == T { - return toEventuallyNot(matcher, timeout: timeout, pollInterval: pollInterval, description: description) - } -} diff --git a/Sources/Nimble/Matchers/MatcherFunc.swift b/Sources/Nimble/Matchers/MatcherFunc.swift deleted file mode 100644 index cba4d33d5..000000000 --- a/Sources/Nimble/Matchers/MatcherFunc.swift +++ /dev/null @@ -1,87 +0,0 @@ -/// DEPRECATED: A convenience API to build matchers that don't need special negation -/// behavior. The toNot() behavior is the negation of to(). -/// -/// @see NonNilMatcherFunc if you prefer to have this matcher fail when nil -/// values are received in an expectation. -/// -/// You may use this when implementing your own custom matchers. -/// -/// Use the Matcher protocol instead of this type to accept custom matchers as -/// input parameters. -/// @see allPass for an example that uses accepts other matchers as input. -@available(*, deprecated, message: "Use Predicate instead") -public struct MatcherFunc: Matcher { - public let matcher: (Expression, FailureMessage) throws -> Bool - - public init(_ matcher: @escaping (Expression, FailureMessage) throws -> Bool) { - self.matcher = matcher - } - - public func matches(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { - return try matcher(actualExpression, failureMessage) - } - - public func doesNotMatch(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { - return try !matcher(actualExpression, failureMessage) - } - - /// Compatibility layer to new Matcher API. Converts an old-style matcher to a new one. - /// Note: You should definitely spend the time to convert to the new api as soon as possible - /// since this struct type is deprecated. - @available(*, deprecated, message: "Use Predicate directly instead") - public var predicate: Predicate { - return Predicate.fromDeprecatedMatcher(self) - } -} - -/// DEPRECATED: A convenience API to build matchers that don't need special negation -/// behavior. The toNot() behavior is the negation of to(). -/// -/// Unlike MatcherFunc, this will always fail if an expectation contains nil. -/// This applies regardless of using to() or toNot(). -/// -/// You may use this when implementing your own custom matchers. -/// -/// Use the Matcher protocol instead of this type to accept custom matchers as -/// input parameters. -/// @see allPass for an example that uses accepts other matchers as input. -@available(*, deprecated, message: "Use Predicate instead") -public struct NonNilMatcherFunc: Matcher { - public let matcher: (Expression, FailureMessage) throws -> Bool - - public init(_ matcher: @escaping (Expression, FailureMessage) throws -> Bool) { - self.matcher = matcher - } - - public func matches(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { - let pass = try matcher(actualExpression, failureMessage) - if try attachNilErrorIfNeeded(actualExpression, failureMessage: failureMessage) { - return false - } - return pass - } - - public func doesNotMatch(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { - let pass = try !matcher(actualExpression, failureMessage) - if try attachNilErrorIfNeeded(actualExpression, failureMessage: failureMessage) { - return false - } - return pass - } - - internal func attachNilErrorIfNeeded(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { - if try actualExpression.evaluate() == nil { - failureMessage.postfixActual = " (use beNil() to match nils)" - return true - } - return false - } - - /// Compatibility layer to new Matcher API. Converts an old-style matcher to a new one. - /// Note: You should definitely spend the time to convert to the new api as soon as possible - /// since this struct type is deprecated. - @available(*, deprecated, message: "Use Predicate directly instead") - public var predicate: Predicate { - return Predicate.fromDeprecatedMatcher(self) - } -} diff --git a/Sources/Nimble/Matchers/PostNotification.swift b/Sources/Nimble/Matchers/PostNotification.swift index cf2018624..efa5b17b6 100644 --- a/Sources/Nimble/Matchers/PostNotification.swift +++ b/Sources/Nimble/Matchers/PostNotification.swift @@ -105,43 +105,4 @@ public func postDistributedNotifications( } #endif -@available(*, deprecated, message: "Use Predicate instead") -public func postNotifications( - _ notificationsMatcher: T, - from center: NotificationCenter = .default -) -> Predicate where T: Matcher, T.ValueType == [Notification] { - _ = mainThread // Force lazy-loading of this value - let collector = NotificationCollector(notificationCenter: center) - collector.startObserving() - var once: Bool = false - - return Predicate { actualExpression in - let collectorNotificationsExpression = Expression(memoizedExpression: { _ in - return collector.observedNotifications - }, location: actualExpression.location, withoutCaching: true) - - assert(pthread_equal(mainThread, pthread_self()) != 0, "Only expecting closure to be evaluated on main thread.") - if !once { - once = true - _ = try actualExpression.evaluate() - } - - let failureMessage = FailureMessage() - let match = try notificationsMatcher.matches(collectorNotificationsExpression, failureMessage: failureMessage) - if collector.observedNotifications.isEmpty { - failureMessage.actualValue = "no notifications" - } else { - failureMessage.actualValue = "<\(stringify(collector.observedNotifications))>" - } - return PredicateResult(bool: match, message: failureMessage.toExpectationMessage()) - } -} - -@available(*, deprecated, renamed: "postNotifications(_:from:)") -public func postNotifications( - _ notificationsMatcher: T, - fromNotificationCenter center: NotificationCenter -) -> Predicate where T: Matcher, T.ValueType == [Notification] { - return postNotifications(notificationsMatcher, from: center) -} #endif diff --git a/Sources/Nimble/Matchers/SatisfyAllOf.swift b/Sources/Nimble/Matchers/SatisfyAllOf.swift index 7fbeeef69..cda7b7d9d 100644 --- a/Sources/Nimble/Matchers/SatisfyAllOf.swift +++ b/Sources/Nimble/Matchers/SatisfyAllOf.swift @@ -4,14 +4,6 @@ public func satisfyAllOf(_ predicates: Predicate...) -> Predicate { return satisfyAllOf(predicates) } -/// A Nimble matcher that succeeds when the actual value matches with all of the matchers -/// provided in the variable list of matchers. -@available(*, deprecated, message: "Use Predicate instead") -public func satisfyAllOf(_ matchers: U...) -> Predicate - where U: Matcher, U.ValueType == T { - return satisfyAllOf(matchers.map { $0.predicate }) -} - internal func satisfyAllOf(_ predicates: [Predicate]) -> Predicate { return Predicate.define { actualExpression in var postfixMessages = [String]() diff --git a/Sources/Nimble/Matchers/SatisfyAnyOf.swift b/Sources/Nimble/Matchers/SatisfyAnyOf.swift index 44615dce7..67bbc64da 100644 --- a/Sources/Nimble/Matchers/SatisfyAnyOf.swift +++ b/Sources/Nimble/Matchers/SatisfyAnyOf.swift @@ -4,14 +4,6 @@ public func satisfyAnyOf(_ predicates: Predicate...) -> Predicate { return satisfyAnyOf(predicates) } -/// A Nimble matcher that succeeds when the actual value matches with any of the matchers -/// provided in the variable list of matchers. -@available(*, deprecated, message: "Use Predicate instead") -public func satisfyAnyOf(_ matchers: U...) -> Predicate - where U: Matcher, U.ValueType == T { - return satisfyAnyOf(matchers.map { $0.predicate }) -} - internal func satisfyAnyOf(_ predicates: [Predicate]) -> Predicate { return Predicate.define { actualExpression in var postfixMessages = [String]() @@ -44,16 +36,6 @@ public func || (left: Predicate, right: Predicate) -> Predicate { return satisfyAnyOf(left, right) } -@available(*, deprecated, message: "Use Predicate instead") -public func || (left: NonNilMatcherFunc, right: NonNilMatcherFunc) -> Predicate { - return satisfyAnyOf(left, right) -} - -@available(*, deprecated, message: "Use Predicate instead") -public func || (left: MatcherFunc, right: MatcherFunc) -> Predicate { - return satisfyAnyOf(left, right) -} - #if canImport(Darwin) import class Foundation.NSObject diff --git a/Tests/NimbleTests/SynchronousDeprecatedTest.swift b/Tests/NimbleTests/SynchronousDeprecatedTest.swift deleted file mode 100644 index ed305f067..000000000 --- a/Tests/NimbleTests/SynchronousDeprecatedTest.swift +++ /dev/null @@ -1,98 +0,0 @@ -import Foundation -import XCTest -import Nimble - -@available(*, deprecated) -final class SynchronousDeprecatedTest: XCTestCase { - func testToMatchesIfMatcherReturnsTrue() { - expect(1).to(MatcherFunc { _, _ in true }) - expect {1}.to(MatcherFunc { _, _ in true }) - - expect(1).to(MatcherFunc { _, _ in true }.predicate) - expect {1}.to(MatcherFunc { _, _ in true }.predicate) - } - - func testToProvidesActualValueExpression() { - var value: Int? - expect(1).to(MatcherFunc { expr, _ in value = try expr.evaluate(); return true }) - expect(value).to(equal(1)) - } - - func testToProvidesAMemoizedActualValueExpression() { - var callCount = 0 - expect { callCount += 1 }.to(MatcherFunc { expr, _ in - _ = try expr.evaluate() - _ = try expr.evaluate() - return true - }) - expect(callCount).to(equal(1)) - } - - func testToProvidesAMemoizedActualValueExpressionIsEvaluatedAtMatcherControl() { - var callCount = 0 - expect { callCount += 1 }.to(MatcherFunc { expr, _ in - expect(callCount).to(equal(0)) - _ = try expr.evaluate() - return true - }) - expect(callCount).to(equal(1)) - } - - // repeated tests from to() for toNot() - func testToNotMatchesIfMatcherReturnsTrue() { - expect(1).toNot(MatcherFunc { _, _ in false }) - expect {1}.toNot(MatcherFunc { _, _ in false }) - - expect(1).toNot(MatcherFunc { _, _ in false }.predicate) - expect {1}.toNot(MatcherFunc { _, _ in false }.predicate) - } - - func testToNotProvidesActualValueExpression() { - var value: Int? - expect(1).toNot(MatcherFunc { expr, _ in value = try expr.evaluate(); return false }) - expect(value).to(equal(1)) - } - - func testToNotProvidesAMemoizedActualValueExpression() { - var callCount = 0 - expect { callCount += 1 }.toNot(MatcherFunc { expr, _ in - _ = try expr.evaluate() - _ = try expr.evaluate() - return false - }) - expect(callCount).to(equal(1)) - } - - func testToNotProvidesAMemoizedActualValueExpressionIsEvaluatedAtMatcherControl() { - var callCount = 0 - expect { callCount += 1 }.toNot(MatcherFunc { expr, _ in - expect(callCount).to(equal(0)) - _ = try expr.evaluate() - return false - }) - expect(callCount).to(equal(1)) - } - - func testToNegativeMatches() { - failsWithErrorMessage("expected to match, got <1>") { - expect(1).to(MatcherFunc { _, _ in false }) - } - failsWithErrorMessage("expected to match, got <1>") { - expect(1).to(MatcherFunc { _, _ in false }.predicate) - } - } - - func testToNotNegativeMatches() { - failsWithErrorMessage("expected to not match, got <1>") { - expect(1).toNot(MatcherFunc { _, _ in true }) - } - failsWithErrorMessage("expected to not match, got <1>") { - expect(1).toNot(MatcherFunc { _, _ in true }.predicate) - } - } - - func testNotToMatchesLikeToNot() { - expect(1).notTo(MatcherFunc { _, _ in false }) - expect(1).notTo(MatcherFunc { _, _ in false }.predicate) - } -}