Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions test/stdlib/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down