Skip to content

Commit

Permalink
Minimal example of a bug from cppyy
Browse files Browse the repository at this point in the history
That needs to be fixed at CppInterOp
reference: look at comments at compiler-research/cppyy-backend#116
  • Loading branch information
Vipul-Cariappa committed Dec 3, 2024
1 parent f794dee commit 95e7b00
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions unittests/CppInterOp/VariableReflectionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,39 @@ TEST(VariableReflectionTest, DatamembersWithAnonymousStructOrUnion) {
#endif
}

TEST(VariableReflectionTest, GetTypeAsString) {
if (llvm::sys::RunningOnValgrind())
GTEST_SKIP() << "XFAIL due to Valgrind report";

std::string code = R"(
namespace my_namespace {
struct Container {
int value;
};
struct Wrapper {
Container item;
};
}
)";

Cpp::CreateInterpreter();
EXPECT_EQ(Cpp::Declare(code.c_str()), 0);

Cpp::TCppScope_t wrapper =
Cpp::GetScopeFromCompleteName("my_namespace::Wrapper");
EXPECT_TRUE(wrapper);

std::vector<Cpp::TCppScope_t> datamembers;
Cpp::GetDatamembers(wrapper, datamembers);
EXPECT_EQ(datamembers.size(), 1);

EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetVariableType(datamembers[0])),
"my_namespace::Container");
}

TEST(VariableReflectionTest, LookupDatamember) {
std::vector<Decl*> Decls;
std::string code = R"(
Expand Down

0 comments on commit 95e7b00

Please sign in to comment.