mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Interop][SwiftToCxx] Modifying tests to verify the that the dynamic cast error returns a Swift::Optional
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// RUN: %target-swift-frontend %S/swift-functions-errors.swift -typecheck -module-name Functions -clang-header-expose-decls=has-expose-attr -emit-clang-header-path %t/functions.h
|
||||
// RUN: %target-swift-frontend %S/swift-functions-errors.swift -typecheck -module-name Functions -enable-experimental-cxx-interop -emit-clang-header-path %t/functions.h
|
||||
|
||||
// RUN: %target-interop-build-clangxx -c %s -I %t -o %t/swift-functions-errors-execution.o
|
||||
// RUN: %target-interop-build-swift %S/swift-functions-errors.swift -o %t/swift-functions-errors-execution -Xlinker %t/swift-functions-errors-execution.o -module-name Functions -Xfrontend -entry-point-function-name -Xfrontend swiftMain
|
||||
@@ -25,24 +25,27 @@ int main() {
|
||||
|
||||
try {
|
||||
Functions::emptyThrowFunction();
|
||||
} catch (swift::Error& e) {
|
||||
} catch (Swift::Error& e) {
|
||||
printf("Exception\n");
|
||||
}
|
||||
try {
|
||||
Functions::throwFunction();
|
||||
} catch (swift::Error& e) {
|
||||
auto errorVal = e.as<Functions::NaiveErrors>();
|
||||
} catch (Swift::Error& e) {
|
||||
auto errorOpt = e.as<Functions::NaiveErrors>();
|
||||
assert(errorOpt.isSome());
|
||||
|
||||
auto errorVal = errorOpt.get();
|
||||
assert(errorVal == Functions::NaiveErrors::throwError);
|
||||
errorVal.getMessage();
|
||||
}
|
||||
try {
|
||||
Functions::throwFunctionWithReturn();
|
||||
} catch (swift::Error& e) {
|
||||
} catch (Swift::Error& e) {
|
||||
printf("Exception\n");
|
||||
}
|
||||
try {
|
||||
Functions::testDestroyedError();
|
||||
} catch(const swift::Error &e) { }
|
||||
} catch(const Swift::Error &e) { }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend %s -typecheck -module-name Functions -clang-header-expose-decls=has-expose-attr -emit-clang-header-path %t/functions.h
|
||||
// RUN: %target-swift-frontend %s -typecheck -module-name Functions -enable-experimental-cxx-interop -emit-clang-header-path %t/functions.h
|
||||
// RUN: %FileCheck %s < %t/functions.h
|
||||
|
||||
// RUN: %check-interop-cxx-header-in-clang(%t/functions.h)
|
||||
// RUN: %check-interop-cxx-header-in-clang(%t/functions.h -Wno-shadow -Wno-unused-function)
|
||||
|
||||
// CHECK-LABEL: namespace Functions __attribute__((swift_private)) {
|
||||
|
||||
@@ -31,7 +31,7 @@ public func emptyThrowFunction() throws { print("passEmptyThrowFunction") }
|
||||
// CHECK: void* _ctx = nullptr;
|
||||
// CHECK: _impl::$s9Functions18emptyThrowFunctionyyKF(_ctx, &opaqueError);
|
||||
// CHECK: if (opaqueError != nullptr)
|
||||
// CHECK: throw (swift::Error(opaqueError))
|
||||
// CHECK: throw (Swift::Error(opaqueError))
|
||||
// CHECK: }
|
||||
|
||||
class TestDestroyed {
|
||||
@@ -53,7 +53,7 @@ public func testDestroyedError() throws { throw DestroyedError() }
|
||||
// CHECK: void* _ctx = nullptr;
|
||||
// CHECK: _impl::$s9Functions18testDestroyedErroryyKF(_ctx, &opaqueError);
|
||||
// CHECK: if (opaqueError != nullptr)
|
||||
// CHECK: throw (swift::Error(opaqueError))
|
||||
// CHECK: throw (Swift::Error(opaqueError))
|
||||
// CHECK: }
|
||||
|
||||
@_expose(Cxx)
|
||||
@@ -67,7 +67,7 @@ public func throwFunction() throws {
|
||||
// CHECK: void* _ctx = nullptr;
|
||||
// CHECK: _impl::$s9Functions13throwFunctionyyKF(_ctx, &opaqueError);
|
||||
// CHECK: if (opaqueError != nullptr)
|
||||
// CHECK: throw (swift::Error(opaqueError))
|
||||
// CHECK: throw (Swift::Error(opaqueError))
|
||||
// CHECK: }
|
||||
|
||||
@_expose(Cxx)
|
||||
@@ -82,6 +82,6 @@ public func throwFunctionWithReturn() throws -> Int {
|
||||
// CHECK: void* _ctx = nullptr;
|
||||
// CHECK: auto returnValue = _impl::$s9Functions23throwFunctionWithReturnSiyKF(_ctx, &opaqueError);
|
||||
// CHECK: if (opaqueError != nullptr)
|
||||
// CHECK: throw (swift::Error(opaqueError))
|
||||
// CHECK: throw (Swift::Error(opaqueError))
|
||||
// CHECK: return returnValue;
|
||||
// CHECK: }
|
||||
|
||||
Reference in New Issue
Block a user