mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Runtime] Add a function pointer for intercepting swift_willThrow calls.
rdar://problem/53400364
This commit is contained in:
@@ -191,5 +191,23 @@ ErrorTests.test("test dealloc empty error box") {
|
||||
}
|
||||
}
|
||||
|
||||
var errors: [Error] = []
|
||||
ErrorTests.test("willThrow") {
|
||||
typealias WillThrow = @convention(c) (Error) -> Void
|
||||
let willThrow = pointerToSwiftCoreSymbol(name: "_swift_willThrow")!
|
||||
willThrow.storeBytes(of: { errors.append($0) }, 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!))
|
||||
}
|
||||
|
||||
runAllTests()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user