Skip to content

Commit c8df9cd

Browse files
committed
[Test] Introduce appropriate runtime availability check
1 parent 9975572 commit c8df9cd

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

test/stdlib/ErrorBridged.swift

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -776,20 +776,22 @@ func anyToAny<T, U>(_ a: T, _ : U.Type) -> U {
776776
ErrorBridgingTests.test("error-to-NSObject casts") {
777777
let error = MyCustomizedError(code: 12345)
778778

779-
// Unconditional cast
780-
let nsErrorAsObject1 = unconditionalCast(error, to: NSObject.self)
781-
let nsError1 = unconditionalCast(nsErrorAsObject1, to: NSError.self)
782-
expectEqual("custom", nsError1.domain)
783-
expectEqual(12345, nsError1.code)
784-
785-
// Conditional cast
786-
let nsErrorAsObject2 = conditionalCast(error, to: NSObject.self)!
787-
let nsError2 = unconditionalCast(nsErrorAsObject2, to: NSError.self)
788-
expectEqual("custom", nsError2.domain)
789-
expectEqual(12345, nsError2.code)
790-
791-
// "is" check
792-
expectTrue(error is NSObject)
779+
if #available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *) {
780+
// Unconditional cast
781+
let nsErrorAsObject1 = unconditionalCast(error, to: NSObject.self)
782+
let nsError1 = unconditionalCast(nsErrorAsObject1, to: NSError.self)
783+
expectEqual("custom", nsError1.domain)
784+
expectEqual(12345, nsError1.code)
785+
786+
// Conditional cast
787+
let nsErrorAsObject2 = conditionalCast(error, to: NSObject.self)!
788+
let nsError2 = unconditionalCast(nsErrorAsObject2, to: NSError.self)
789+
expectEqual("custom", nsError2.domain)
790+
expectEqual(12345, nsError2.code)
791+
792+
// "is" check
793+
expectTrue(error is NSObject)
794+
}
793795
}
794796

795797
runAllTests()

0 commit comments

Comments
 (0)