Skip to content

Commit 35f9cc9

Browse files
committed
Improve OS check
1 parent 6bee47d commit 35f9cc9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Sources/Nimble/Matchers/BeginWith.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ public func beginWith(_ startingElement: Any) -> Predicate<NMBOrderedCollection>
1717
return Predicate.simple("begin with <\(startingElement)>") { actualExpression in
1818
guard let collection = try actualExpression.evaluate() else { return .fail }
1919
guard collection.count > 0 else { return .doesNotMatch }
20-
#if os(Linux)
20+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
21+
let collectionValue = collection.object(at: 0) as AnyObject
22+
#else
2123
guard let collectionValue = collection.object(at: 0) as? NSObject else {
2224
return .fail
2325
}
24-
#else
25-
let collectionValue = collection.object(at: 0) as AnyObject
2626
#endif
2727
return PredicateStatus(bool: collectionValue.isEqual(startingElement))
2828
}

Sources/Nimble/Matchers/EndWith.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public func endWith(_ endingElement: Any) -> Predicate<NMBOrderedCollection> {
2525
guard let collection = try actualExpression.evaluate() else { return .fail }
2626

2727
guard collection.count > 0 else { return PredicateStatus(bool: false) }
28-
#if os(Linux)
28+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
29+
let collectionValue = collection.object(at: collection.count - 1) as AnyObject
30+
#else
2931
guard let collectionValue = collection.object(at: collection.count - 1) as? NSObject else {
3032
return .fail
3133
}
32-
#else
33-
let collectionValue = collection.object(at: collection.count - 1) as AnyObject
3434
#endif
3535

3636
return PredicateStatus(bool: collectionValue.isEqual(endingElement))

0 commit comments

Comments
 (0)