Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ matrix:
- <<: *swiftpm_linux
name: SwiftPM / Linux / Swift 5.1 Development
env:
- SWIFT_VERSION=5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a
- SWIFT_VERSION=5.1-DEVELOPMENT-SNAPSHOT-2019-05-29-a
install: true
script:
- ./test $TYPE
Expand Down
10 changes: 6 additions & 4 deletions Sources/Nimble/Matchers/BeGreaterThan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public func beGreaterThan<T: Comparable>(_ expectedValue: T?) -> Predicate<T> {
}
}

public func ><T: Comparable>(lhs: Expectation<T>, rhs: T) {
lhs.to(beGreaterThan(rhs))
}

#if canImport(Darwin) || !compiler(>=5.1)
/// A Nimble matcher that succeeds when the actual value is greater than the expected value.
public func beGreaterThan(_ expectedValue: NMBComparable?) -> Predicate<NMBComparable> {
let errorMessage = "be greater than <\(stringify(expectedValue))>"
Expand All @@ -22,13 +27,10 @@ public func beGreaterThan(_ expectedValue: NMBComparable?) -> Predicate<NMBCompa
}
}

public func ><T: Comparable>(lhs: Expectation<T>, rhs: T) {
lhs.to(beGreaterThan(rhs))
}

public func > (lhs: Expectation<NMBComparable>, rhs: NMBComparable?) {
lhs.to(beGreaterThan(rhs))
}
#endif

#if canImport(Darwin)
extension NMBObjCMatcher {
Expand Down
10 changes: 6 additions & 4 deletions Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public func beGreaterThanOrEqualTo<T: Comparable>(_ expectedValue: T?) -> Predic
}
}

public func >=<T: Comparable>(lhs: Expectation<T>, rhs: T) {
lhs.to(beGreaterThanOrEqualTo(rhs))
}

#if canImport(Darwin) || !compiler(>=5.1)
/// A Nimble matcher that succeeds when the actual value is greater than
/// or equal to the expected value.
public func beGreaterThanOrEqualTo<T: NMBComparable>(_ expectedValue: T?) -> Predicate<T> {
Expand All @@ -24,13 +29,10 @@ public func beGreaterThanOrEqualTo<T: NMBComparable>(_ expectedValue: T?) -> Pre
}
}

public func >=<T: Comparable>(lhs: Expectation<T>, rhs: T) {
lhs.to(beGreaterThanOrEqualTo(rhs))
}

public func >=<T: NMBComparable>(lhs: Expectation<T>, rhs: T) {
lhs.to(beGreaterThanOrEqualTo(rhs))
}
#endif

#if canImport(Darwin)
extension NMBObjCMatcher {
Expand Down
10 changes: 6 additions & 4 deletions Sources/Nimble/Matchers/BeLessThan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public func beLessThan<T: Comparable>(_ expectedValue: T?) -> Predicate<T> {
}
}

public func <<T: Comparable>(lhs: Expectation<T>, rhs: T) {
lhs.to(beLessThan(rhs))
}

#if canImport(Darwin) || !compiler(>=5.1)
/// A Nimble matcher that succeeds when the actual value is less than the expected value.
public func beLessThan(_ expectedValue: NMBComparable?) -> Predicate<NMBComparable> {
let message = "be less than <\(stringify(expectedValue))>"
Expand All @@ -21,13 +26,10 @@ public func beLessThan(_ expectedValue: NMBComparable?) -> Predicate<NMBComparab
}
}

public func <<T: Comparable>(lhs: Expectation<T>, rhs: T) {
lhs.to(beLessThan(rhs))
}

public func < (lhs: Expectation<NMBComparable>, rhs: NMBComparable?) {
lhs.to(beLessThan(rhs))
}
#endif

#if canImport(Darwin)
extension NMBObjCMatcher {
Expand Down
10 changes: 6 additions & 4 deletions Sources/Nimble/Matchers/BeLessThanOrEqual.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public func beLessThanOrEqualTo<T: Comparable>(_ expectedValue: T?) -> Predicate
}
}

public func <=<T: Comparable>(lhs: Expectation<T>, rhs: T) {
lhs.to(beLessThanOrEqualTo(rhs))
}

#if canImport(Darwin) || !compiler(>=5.1)
/// A Nimble matcher that succeeds when the actual value is less than
/// or equal to the expected value.
public func beLessThanOrEqualTo<T: NMBComparable>(_ expectedValue: T?) -> Predicate<T> {
Expand All @@ -21,13 +26,10 @@ public func beLessThanOrEqualTo<T: NMBComparable>(_ expectedValue: T?) -> Predic
}
}

public func <=<T: Comparable>(lhs: Expectation<T>, rhs: T) {
lhs.to(beLessThanOrEqualTo(rhs))
}

public func <=<T: NMBComparable>(lhs: Expectation<T>, rhs: T) {
lhs.to(beLessThanOrEqualTo(rhs))
}
#endif

#if canImport(Darwin)
extension NMBObjCMatcher {
Expand Down
4 changes: 3 additions & 1 deletion Sources/Nimble/Matchers/MatcherProtocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,14 @@ extension NSDate: TestOutputStringConvertible {
@objc public protocol NMBComparable {
func NMB_compare(_ otherObject: NMBComparable!) -> ComparisonResult
}
#else
#elseif !compiler(>=5.1)
// This should become obsolete once Corelibs Foundation adds Comparable conformance to NSNumber
public protocol NMBComparable {
func NMB_compare(_ otherObject: NMBComparable!) -> ComparisonResult
}
#endif

#if canImport(Darwin) || !compiler(>=5.1)
extension NSNumber: NMBComparable {
public func NMB_compare(_ otherObject: NMBComparable!) -> ComparisonResult {
// swiftlint:disable:next force_cast
Expand All @@ -155,3 +156,4 @@ extension NSString: NMBComparable {
return compare(otherObject as! String)
}
}
#endif