test/Interop/SwiftToCxx/functions/swift-functions-errors.swift

This commit is contained in:
Roberto Rosmaninho
2022-10-18 18:53:30 -03:00
parent 0f8b42a7f6
commit 5af07a470c
3 changed files with 88 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend %s -typecheck -module-name Functions -clang-header-expose-decls=all-public -emit-clang-header-path %t/functions.h
// RUN: %target-swift-frontend %s -typecheck -module-name Functions -clang-header-expose-decls=has-expose-attr -emit-clang-header-path %t/functions.h
// RUN: %FileCheck %s < %t/functions.h
// RUN: %check-interop-cxx-header-in-clang(%t/functions.h)
@@ -13,11 +13,19 @@
// CHECK: }
enum NaiveErrors : Error {
// XFAIL: *
@_expose(Cxx)
public enum NaiveErrors : Error {
case returnError
case throwError
public func getMessage() {
print(self)
}
}
@_expose(Cxx)
public func emptyThrowFunction() throws { print("passEmptyThrowFunction") }
// CHECK: inline void emptyThrowFunction() {
@@ -34,10 +42,12 @@ class TestDestroyed {
}
}
@_expose(Cxx)
public struct DestroyedError : Error {
let t = TestDestroyed()
}
@_expose(Cxx)
public func testDestroyedError() throws { throw DestroyedError() }
// CHECK: inline void testDestroyedError() {
@@ -48,6 +58,7 @@ public func testDestroyedError() throws { throw DestroyedError() }
// CHECK: throw (swift::Error(opaqueError))
// CHECK: }
@_expose(Cxx)
public func throwFunction() throws {
print("passThrowFunction")
throw NaiveErrors.throwError
@@ -61,6 +72,7 @@ public func throwFunction() throws {
// CHECK: throw (swift::Error(opaqueError))
// CHECK: }
@_expose(Cxx)
public func throwFunctionWithReturn() throws -> Int {
print("passThrowFunctionWithReturn")
throw NaiveErrors.returnError