mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Implementing a naive exception to be thrown in C++ if an Error is thrown in Swift
Creating new Interop - SwiftToCxx test
This commit is contained in:
@@ -11,16 +11,35 @@
|
||||
// REQUIRES: executable_test
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include "functions.h"
|
||||
|
||||
int main() {
|
||||
static_assert(!noexcept(Functions::emptyThrowFunction()), "noexcept function");
|
||||
static_assert(!noexcept(Functions::throwFunction()), "noexcept function");
|
||||
static_assert(!noexcept(Functions::throwFunctionWithReturn()), "noexcept function");
|
||||
|
||||
try {
|
||||
Functions::emptyThrowFunction();
|
||||
} catch (swift::_impl::NaiveException& e) {
|
||||
std::cout << e.getMessage() << "\n";
|
||||
}
|
||||
try {
|
||||
Functions::throwFunction();
|
||||
} catch (swift::_impl::NaiveException& e) {
|
||||
std::cout << e.getMessage() << "\n";
|
||||
}
|
||||
try {
|
||||
Functions::throwFunctionWithReturn();
|
||||
} catch (swift::_impl::NaiveException& e) {
|
||||
std::cout << e.getMessage() << "\n";
|
||||
}
|
||||
|
||||
Functions::emptyThrowFunction();
|
||||
Functions::throwFunction();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CHECK: passEmptyThrowFunction
|
||||
// CHECK-NEXT: passThrowFunction
|
||||
// CHECK-NEXT: Exception
|
||||
// CHECK-NEXT: passThrowFunctionWithReturn
|
||||
// CHECK-NEXT: Exception
|
||||
|
||||
Reference in New Issue
Block a user