mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Test] Don't test _swift_willThrow on older runtimes.
rdar://problem/56752866
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user