@@ -1477,7 +1477,7 @@ TEST(FunctionReflectionTest, JitCallAdvanced) {
14771477 Ctor.Invoke (&object);
14781478 EXPECT_TRUE (object) << " Failed to call the ctor." ;
14791479 // Building a wrapper with a typedef decl must be possible.
1480- Cpp::Destruct (object, Decls[1 ]);
1480+ EXPECT_TRUE ( Cpp::Destruct (object, Decls[1 ]) );
14811481
14821482 // C API
14831483 auto * I = clang_createInterpreterFromRawPtr (Cpp::GetInterpreter ());
@@ -2342,7 +2342,7 @@ TEST(FunctionReflectionTest, ConstructArray) {
23422342 obj = reinterpret_cast <int *>(reinterpret_cast <char *>(where) +
23432343 (Cpp::SizeOf (scope) * 4 ));
23442344 EXPECT_TRUE (*obj == 42 );
2345- Cpp::Destruct (where, scope, /* withFree=*/ false , 5 );
2345+ EXPECT_TRUE ( Cpp::Destruct (where, scope, /* withFree=*/ false , 5 ) );
23462346 Cpp::Deallocate (scope, where, 5 );
23472347 output = testing::internal::GetCapturedStdout ();
23482348 EXPECT_EQ (output,
@@ -2379,7 +2379,7 @@ TEST(FunctionReflectionTest, Destruct) {
23792379 testing::internal::CaptureStdout ();
23802380 Cpp::TCppScope_t scope = Cpp::GetNamed (" C" );
23812381 Cpp::TCppObject_t object = Cpp::Construct (scope);
2382- Cpp::Destruct (object, scope);
2382+ EXPECT_TRUE ( Cpp::Destruct (object, scope) );
23832383 std::string output = testing::internal::GetCapturedStdout ();
23842384
23852385 EXPECT_EQ (output, " Destructor Executed" );
@@ -2389,7 +2389,7 @@ TEST(FunctionReflectionTest, Destruct) {
23892389 object = Cpp::Construct (scope);
23902390 // Make sure we do not call delete by adding an explicit Deallocate. If we
23912391 // called delete the Deallocate will cause a double deletion error.
2392- Cpp::Destruct (object, scope, /* withFree=*/ false );
2392+ EXPECT_TRUE ( Cpp::Destruct (object, scope, /* withFree=*/ false ) );
23932393 Cpp::Deallocate (scope, object);
23942394 output = testing::internal::GetCapturedStdout ();
23952395 EXPECT_EQ (output, " Destructor Executed" );
@@ -2406,6 +2406,20 @@ TEST(FunctionReflectionTest, Destruct) {
24062406 // Clean up resources
24072407 clang_Interpreter_takeInterpreterAsPtr (I);
24082408 clang_Interpreter_dispose (I);
2409+
2410+ // Failure test, this wrapper should not compile since we explicitly delete
2411+ // the destructor
2412+ Interp->declare (R"(
2413+ class D {
2414+ public:
2415+ D() {}
2416+ ~D() = delete;
2417+ };
2418+ )" );
2419+
2420+ scope = Cpp::GetNamed (" D" );
2421+ object = Cpp::Construct (scope);
2422+ EXPECT_FALSE (Cpp::Destruct (object, scope));
24092423}
24102424
24112425TEST (FunctionReflectionTest, DestructArray) {
@@ -2454,7 +2468,7 @@ TEST(FunctionReflectionTest, DestructArray) {
24542468
24552469 testing::internal::CaptureStdout ();
24562470 // destruct 3 out of 5 objects
2457- Cpp::Destruct (where, scope, false , 3 );
2471+ EXPECT_TRUE ( Cpp::Destruct (where, scope, false , 3 ) );
24582472 output = testing::internal::GetCapturedStdout ();
24592473
24602474 EXPECT_EQ (
@@ -2466,7 +2480,7 @@ TEST(FunctionReflectionTest, DestructArray) {
24662480 // destruct the rest
24672481 auto *new_head = reinterpret_cast <void *>(reinterpret_cast <char *>(where) +
24682482 (Cpp::SizeOf (scope) * 3 ));
2469- Cpp::Destruct (new_head, scope, false , 2 );
2483+ EXPECT_TRUE ( Cpp::Destruct (new_head, scope, false , 2 ) );
24702484
24712485 output = testing::internal::GetCapturedStdout ();
24722486 EXPECT_EQ (output, " \n Destructor Executed\n\n Destructor Executed\n " );
@@ -2481,7 +2495,7 @@ TEST(FunctionReflectionTest, DestructArray) {
24812495 testing::internal::CaptureStdout ();
24822496 // FIXME : This should work with the array of objects as well
24832497 // Cpp::Destruct(where, scope, true, 5);
2484- Cpp::Destruct (where, scope, true );
2498+ EXPECT_TRUE ( Cpp::Destruct (where, scope, true ) );
24852499 output = testing::internal::GetCapturedStdout ();
24862500 EXPECT_EQ (output, " \n Destructor Executed\n " );
24872501 output.clear ();
0 commit comments