Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/Nimble/Expectation.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation

// Deprecated
@available(*, deprecated)
internal func expressionDoesNotMatch<T, U>(_ expression: Expression<T>, matcher: U, toNot: String, description: String?) -> (Bool, FailureMessage)
where U: Matcher, U.ValueType == T {
let msg = FailureMessage()
Expand Down Expand Up @@ -69,6 +70,7 @@ public struct Expectation<T> {
////////////////// OLD API /////////////////////

/// DEPRECATED: Tests the actual value using a matcher to match.
@available(*, deprecated)
public func to<U>(_ matcher: U, description: String? = nil)
where U: Matcher, U.ValueType == T {
let (pass, msg) = execute(
Expand All @@ -83,6 +85,7 @@ public struct Expectation<T> {
}

/// DEPRECATED: Tests the actual value using a matcher to not match.
@available(*, deprecated)
public func toNot<U>(_ matcher: U, description: String? = nil)
where U: Matcher, U.ValueType == T {
// swiftlint:disable:next line_length
Expand All @@ -93,6 +96,7 @@ public struct Expectation<T> {
/// DEPRECATED: Tests the actual value using a matcher to not match.
///
/// Alias to toNot().
@available(*, deprecated)
public func notTo<U>(_ matcher: U, description: String? = nil)
where U: Matcher, U.ValueType == T {
toNot(matcher, description: description)
Expand Down
1 change: 1 addition & 0 deletions Sources/Nimble/Matchers/AllPass.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public func allPass<T, U>
return createPredicate(matcher)
}

@available(*, deprecated)
public func allPass<S, M>(_ elementMatcher: M) -> Predicate<S>
where S: Sequence, M: Matcher, S.Iterator.Element == M.ValueType {
return createPredicate(elementMatcher.predicate)
Expand Down
3 changes: 3 additions & 0 deletions Sources/Nimble/Matchers/Async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ extension Expectation {
/// @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.
@available(*, deprecated)
public func toEventually<U>(_ matcher: U, timeout: TimeInterval = AsyncDefaults.Timeout, pollInterval: TimeInterval = AsyncDefaults.PollInterval, description: String? = nil)
where U: Matcher, U.ValueType == T {
if expression.isClosure {
Expand Down Expand Up @@ -145,6 +146,7 @@ extension Expectation {
/// @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.
@available(*, deprecated)
public func toEventuallyNot<U>(_ matcher: U, timeout: TimeInterval = AsyncDefaults.Timeout, pollInterval: TimeInterval = AsyncDefaults.PollInterval, description: String? = nil)
where U: Matcher, U.ValueType == T {
if expression.isClosure {
Expand Down Expand Up @@ -174,6 +176,7 @@ extension Expectation {
/// @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.
@available(*, deprecated)
public func toNotEventually<U>(_ matcher: U, timeout: TimeInterval = AsyncDefaults.Timeout, pollInterval: TimeInterval = AsyncDefaults.PollInterval, description: String? = nil)
where U: Matcher, U.ValueType == T {
return toEventuallyNot(matcher, timeout: timeout, pollInterval: pollInterval, description: description)
Expand Down
2 changes: 2 additions & 0 deletions Sources/Nimble/Matchers/BeCloseTo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class NMBObjCBeCloseToMatcher: NSObject, NMBMatcher {
_delta = within
}

@available(*, deprecated)
@objc public func matches(_ actualExpression: @escaping () -> NSObject?, failureMessage: FailureMessage, location: SourceLocation) -> Bool {
let actualBlock: () -> NMBDoubleConvertible? = ({
return actualExpression() as? NMBDoubleConvertible
Expand All @@ -61,6 +62,7 @@ public class NMBObjCBeCloseToMatcher: NSObject, NMBMatcher {
}
}

@available(*, deprecated)
@objc public func doesNotMatch(_ actualExpression: @escaping () -> NSObject?, failureMessage: FailureMessage, location: SourceLocation) -> Bool {
let actualBlock: () -> NMBDoubleConvertible? = ({
return actualExpression() as? NMBDoubleConvertible
Expand Down
1 change: 1 addition & 0 deletions Sources/Nimble/Matchers/MatcherProtocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public protocol Matcher {
func doesNotMatch(_ actualExpression: Expression<ValueType>, failureMessage: FailureMessage) throws -> Bool
}

@available(*, deprecated, message: "Use Predicate instead")
extension Matcher {
var predicate: Predicate<ValueType> {
return Predicate.fromDeprecatedMatcher(self)
Expand Down
1 change: 1 addition & 0 deletions Sources/Nimble/Matchers/PostNotification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ internal class NotificationCollector {

private let mainThread = pthread_self()

@available(*, deprecated)
public func postNotifications<T>(
_ notificationsMatcher: T,
fromNotificationCenter center: NotificationCenter = .default)
Expand Down
2 changes: 2 additions & 0 deletions Sources/Nimble/Matchers/Predicate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public enum PredicateStatus {
}

// Backwards compatibility until Old Matcher API removal
@available(*, deprecated)
extension Predicate: Matcher {
/// Compatibility layer for old Matcher API, deprecated
public static func fromDeprecatedFullClosure(_ matcher: @escaping (Expression<T>, FailureMessage, Bool) throws -> Bool) -> Predicate {
Expand Down Expand Up @@ -196,6 +197,7 @@ extension Predicate: Matcher {

/// Compatibility layer for old Matcher API, deprecated.
/// Same as calling .predicate on a MatcherFunc or NonNilMatcherFunc type.
@available(*, deprecated)
public static func fromDeprecatedMatcher<M>(_ matcher: M) -> Predicate where M: Matcher, M.ValueType == T {
return self.fromDeprecatedFullClosure(matcher.toClosure)
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/Nimble/Matchers/SatisfyAllOf.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation

/// A Nimble matcher that succeeds when the actual value matches with all of the matchers
/// provided in the variable list of matchers.
@available(*, deprecated)
public func satisfyAllOf<T, U>(_ matchers: U...) -> Predicate<T>
where U: Matcher, U.ValueType == T {
return satisfyAllOf(matchers.map { $0.predicate })
Expand Down Expand Up @@ -35,6 +36,7 @@ internal func satisfyAllOf<T>(_ predicates: [Predicate<T>]) -> Predicate<T> {
}
}

@available(*, deprecated)
public func && <T>(left: Predicate<T>, right: Predicate<T>) -> Predicate<T> {
return satisfyAllOf(left, right)
}
Expand Down
8 changes: 6 additions & 2 deletions Sources/Nimble/Matchers/SatisfyAnyOf.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Foundation

/// A Nimble matcher that succeeds when the actual value matches with any of the matchers
/// provided in the variable list of matchers.
/// provided in the variable list of matchers.
@available(*, deprecated)
public func satisfyAnyOf<T, U>(_ matchers: U...) -> Predicate<T>
where U: Matcher, U.ValueType == T {
return satisfyAnyOf(matchers.map { $0.predicate })
Expand Down Expand Up @@ -35,14 +36,17 @@ internal func satisfyAnyOf<T>(_ predicates: [Predicate<T>]) -> Predicate<T> {
}
}

@available(*, deprecated)
public func || <T>(left: Predicate<T>, right: Predicate<T>) -> Predicate<T> {
return satisfyAnyOf(left, right)
return satisfyAnyOf(left, right)
}

@available(*, deprecated)
public func || <T>(left: NonNilMatcherFunc<T>, right: NonNilMatcherFunc<T>) -> Predicate<T> {
return satisfyAnyOf(left, right)
}

@available(*, deprecated)
public func || <T>(left: MatcherFunc<T>, right: MatcherFunc<T>) -> Predicate<T> {
return satisfyAnyOf(left, right)
}
Expand Down