From 44b63e663b23e3784b0d89e0befcd8e70275595b Mon Sep 17 00:00:00 2001 From: Sho Ikeda Date: Fri, 31 May 2019 23:55:48 +0900 Subject: [PATCH] [CI] Use the latest Swift 5.1 snapshot --- .travis.yml | 2 +- Sources/Nimble/Matchers/BeGreaterThan.swift | 10 ++++++---- Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift | 10 ++++++---- Sources/Nimble/Matchers/BeLessThan.swift | 10 ++++++---- Sources/Nimble/Matchers/BeLessThanOrEqual.swift | 10 ++++++---- Sources/Nimble/Matchers/MatcherProtocols.swift | 4 +++- 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 491369916..90aeff5ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Sources/Nimble/Matchers/BeGreaterThan.swift b/Sources/Nimble/Matchers/BeGreaterThan.swift index 4a4cdd281..782c771ce 100644 --- a/Sources/Nimble/Matchers/BeGreaterThan.swift +++ b/Sources/Nimble/Matchers/BeGreaterThan.swift @@ -11,6 +11,11 @@ public func beGreaterThan(_ expectedValue: T?) -> Predicate { } } +public func >(lhs: Expectation, 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 { let errorMessage = "be greater than <\(stringify(expectedValue))>" @@ -22,13 +27,10 @@ public func beGreaterThan(_ expectedValue: NMBComparable?) -> Predicate(lhs: Expectation, rhs: T) { - lhs.to(beGreaterThan(rhs)) -} - public func > (lhs: Expectation, rhs: NMBComparable?) { lhs.to(beGreaterThan(rhs)) } +#endif #if canImport(Darwin) extension NMBObjCMatcher { diff --git a/Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift b/Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift index 39d9e63ee..c3fc52387 100644 --- a/Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift +++ b/Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift @@ -13,6 +13,11 @@ public func beGreaterThanOrEqualTo(_ expectedValue: T?) -> Predic } } +public func >=(lhs: Expectation, 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(_ expectedValue: T?) -> Predicate { @@ -24,13 +29,10 @@ public func beGreaterThanOrEqualTo(_ expectedValue: T?) -> Pre } } -public func >=(lhs: Expectation, rhs: T) { - lhs.to(beGreaterThanOrEqualTo(rhs)) -} - public func >=(lhs: Expectation, rhs: T) { lhs.to(beGreaterThanOrEqualTo(rhs)) } +#endif #if canImport(Darwin) extension NMBObjCMatcher { diff --git a/Sources/Nimble/Matchers/BeLessThan.swift b/Sources/Nimble/Matchers/BeLessThan.swift index ef0a7d48e..12fc9c20f 100644 --- a/Sources/Nimble/Matchers/BeLessThan.swift +++ b/Sources/Nimble/Matchers/BeLessThan.swift @@ -11,6 +11,11 @@ public func beLessThan(_ expectedValue: T?) -> Predicate { } } +public func <(lhs: Expectation, 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 { let message = "be less than <\(stringify(expectedValue))>" @@ -21,13 +26,10 @@ public func beLessThan(_ expectedValue: NMBComparable?) -> Predicate(lhs: Expectation, rhs: T) { - lhs.to(beLessThan(rhs)) -} - public func < (lhs: Expectation, rhs: NMBComparable?) { lhs.to(beLessThan(rhs)) } +#endif #if canImport(Darwin) extension NMBObjCMatcher { diff --git a/Sources/Nimble/Matchers/BeLessThanOrEqual.swift b/Sources/Nimble/Matchers/BeLessThanOrEqual.swift index 30ce04315..bf6ba1640 100644 --- a/Sources/Nimble/Matchers/BeLessThanOrEqual.swift +++ b/Sources/Nimble/Matchers/BeLessThanOrEqual.swift @@ -11,6 +11,11 @@ public func beLessThanOrEqualTo(_ expectedValue: T?) -> Predicate } } +public func <=(lhs: Expectation, 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(_ expectedValue: T?) -> Predicate { @@ -21,13 +26,10 @@ public func beLessThanOrEqualTo(_ expectedValue: T?) -> Predic } } -public func <=(lhs: Expectation, rhs: T) { - lhs.to(beLessThanOrEqualTo(rhs)) -} - public func <=(lhs: Expectation, rhs: T) { lhs.to(beLessThanOrEqualTo(rhs)) } +#endif #if canImport(Darwin) extension NMBObjCMatcher { diff --git a/Sources/Nimble/Matchers/MatcherProtocols.swift b/Sources/Nimble/Matchers/MatcherProtocols.swift index 38bb29708..202e6db1f 100644 --- a/Sources/Nimble/Matchers/MatcherProtocols.swift +++ b/Sources/Nimble/Matchers/MatcherProtocols.swift @@ -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 @@ -155,3 +156,4 @@ extension NSString: NMBComparable { return compare(otherObject as! String) } } +#endif