Skip to content

Commit

Permalink
Fix Swift 4.2 compatibility on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesyo committed Jan 17, 2019
1 parent 8a5e6b8 commit 6f47da1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Sources/Nimble/Matchers/BeIdenticalTo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import Foundation
/// as the expected instance.
public func beIdenticalTo(_ expected: Any?) -> Predicate<Any> {
return Predicate.define { actualExpression in
#if os(Linux)
#if os(Linux) && !swift(>=4.1.50)
let actual = try actualExpression.evaluate() as? AnyObject
#else
let actual = try actualExpression.evaluate() as AnyObject?
#endif

let bool: Bool
#if os(Linux)
#if os(Linux) && !swift(>=4.1.50)
bool = actual === (expected as? AnyObject) && actual !== nil
#else
bool = actual === (expected as AnyObject?) && actual !== nil
Expand Down
2 changes: 1 addition & 1 deletion Sources/Nimble/Utils/Await.swift
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ internal class AwaitPromiseBuilder<T> {
self.trigger.timeoutSource.resume()
while self.promise.asyncResult.isIncomplete() {
// Stopping the run loop does not work unless we run only 1 mode
#if swift(>=4.2)
#if swift(>=4.2) && (os(macOS) || os(iOS) || os(tvOS))
_ = RunLoop.current.run(mode: .default, before: .distantFuture)
#else
_ = RunLoop.current.run(mode: .defaultRunLoopMode, before: .distantFuture)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Nimble/Utils/Stringers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

internal func identityAsString(_ value: Any?) -> String {
let anyObject: AnyObject?
#if os(Linux)
#if os(Linux) && !swift(>=4.1.50)
anyObject = value as? AnyObject
#else
anyObject = value as AnyObject?
Expand Down
2 changes: 1 addition & 1 deletion test
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function test_podspec {

function test_swiftpm {
if [ -d .build ]; then
run swift build --clean
run swift package clean
fi
run swift build && swift test
}
Expand Down

0 comments on commit 6f47da1

Please sign in to comment.