From 95e7b0016dc721be782e69b8bebdc5d0c6b907f4 Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Tue, 3 Dec 2024 12:40:37 +0530 Subject: [PATCH] Minimal example of a bug from cppyy That needs to be fixed at CppInterOp reference: look at comments at compiler-research/cppyy-backend#116 --- .../CppInterOp/VariableReflectionTest.cpp | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/unittests/CppInterOp/VariableReflectionTest.cpp b/unittests/CppInterOp/VariableReflectionTest.cpp index d075c1bc..8c4b7781 100644 --- a/unittests/CppInterOp/VariableReflectionTest.cpp +++ b/unittests/CppInterOp/VariableReflectionTest.cpp @@ -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 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 Decls; std::string code = R"(