[Test] Don't test _swift_willThrow on older runtimes.

rdar://problem/56752866
This commit is contained in:
Mike Ash
2019-10-30 15:07:37 -04:00
parent 33dfb94eec
commit a2cf576d4a

View File

@@ -193,25 +193,27 @@ ErrorTests.test("test dealloc empty error box") {
var errors: [Error] = []
ErrorTests.test("willThrow") {
// Error isn't allowed in a @convention(c) function when ObjC interop is
// not available, so pass it through an OpaquePointer.
typealias WillThrow = @convention(c) (OpaquePointer) -> Void
let willThrow = pointerToSwiftCoreSymbol(name: "_swift_willThrow")!
let callback: WillThrow = {
errors.append(unsafeBitCast($0, to: Error.self))
}
willThrow.storeBytes(of: callback, as: WillThrow.self)
expectTrue(errors.isEmpty)
do {
throw UnsignedError.negativeOne
} catch {}
expectEqual(UnsignedError.self, type(of: errors.last!))
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
// Error isn't allowed in a @convention(c) function when ObjC interop is
// not available, so pass it through an OpaquePointer.
typealias WillThrow = @convention(c) (OpaquePointer) -> Void
let willThrow = pointerToSwiftCoreSymbol(name: "_swift_willThrow")!
let callback: WillThrow = {
errors.append(unsafeBitCast($0, to: Error.self))
}
willThrow.storeBytes(of: callback, as: WillThrow.self)
expectTrue(errors.isEmpty)
do {
throw UnsignedError.negativeOne
} catch {}
expectEqual(UnsignedError.self, type(of: errors.last!))
do {
throw SillyError.JazzHands
} catch {}
expectEqual(2, errors.count)
expectEqual(SillyError.self, type(of: errors.last!))
do {
throw SillyError.JazzHands
} catch {}
expectEqual(2, errors.count)
expectEqual(SillyError.self, type(of: errors.last!))
}
}
runAllTests()