@@ -28,21 +28,40 @@ TEST(FunctionReflectionTest, GetClassMethods) {
28
28
};
29
29
30
30
typedef A shadow_A;
31
+ class B {
32
+ public:
33
+ B(int n) : b{n} {}
34
+ int b;
35
+ };
36
+
37
+ class C: public B {
38
+ public:
39
+ using B::B;
40
+ };
41
+ using MyInt = int;
31
42
)" ;
32
43
33
44
GetAllTopLevelDecls (code, Decls);
34
45
Sema *S = &Interp->getCI ()->getSema ();
35
- auto methods0 = InterOp::GetClassMethods (S, Decls[0 ]);
36
46
37
47
auto get_method_name = [](InterOp::TCppFunction_t method) {
38
- return InterOp::GetQualifiedName (method);
48
+ return InterOp::GetFunctionSignature (method);
39
49
};
40
50
41
- EXPECT_EQ (get_method_name (methods0[0 ]), " A::f1" );
42
- EXPECT_EQ (get_method_name (methods0[1 ]), " A::f2" );
43
- EXPECT_EQ (get_method_name (methods0[2 ]), " A::f3" );
44
- EXPECT_EQ (get_method_name (methods0[3 ]), " A::f4" );
45
- EXPECT_EQ (get_method_name (methods0[4 ]), " A::f5" );
51
+ auto methods0 = InterOp::GetClassMethods (S, Decls[0 ]);
52
+
53
+ EXPECT_EQ (methods0.size (), 11 );
54
+ EXPECT_EQ (get_method_name (methods0[0 ]), " int A::f1(int a, int b)" );
55
+ EXPECT_EQ (get_method_name (methods0[1 ]), " const A *A::f2() const" );
56
+ EXPECT_EQ (get_method_name (methods0[2 ]), " int A::f3()" );
57
+ EXPECT_EQ (get_method_name (methods0[3 ]), " void A::f4()" );
58
+ EXPECT_EQ (get_method_name (methods0[4 ]), " int A::f5(int i)" );
59
+ EXPECT_EQ (get_method_name (methods0[5 ]), " inline constexpr A::A()" );
60
+ EXPECT_EQ (get_method_name (methods0[6 ]), " inline constexpr A::A(const A &)" );
61
+ EXPECT_EQ (get_method_name (methods0[7 ]), " inline constexpr A &A::operator=(const A &)" );
62
+ EXPECT_EQ (get_method_name (methods0[8 ]), " inline constexpr A::A(A &&)" );
63
+ EXPECT_EQ (get_method_name (methods0[9 ]), " inline constexpr A &A::operator=(A &&)" );
64
+ EXPECT_EQ (get_method_name (methods0[10 ]), " inline A::~A()" );
46
65
47
66
auto methods1 = InterOp::GetClassMethods (S, Decls[1 ]);
48
67
EXPECT_EQ (methods0.size (), methods1.size ());
@@ -51,6 +70,32 @@ TEST(FunctionReflectionTest, GetClassMethods) {
51
70
EXPECT_EQ (methods0[2 ], methods1[2 ]);
52
71
EXPECT_EQ (methods0[3 ], methods1[3 ]);
53
72
EXPECT_EQ (methods0[4 ], methods1[4 ]);
73
+
74
+ auto methods2 = InterOp::GetClassMethods (S, Decls[2 ]);
75
+
76
+ EXPECT_EQ (methods2.size (), 6 );
77
+ EXPECT_EQ (get_method_name (methods2[0 ]), " B::B(int n)" );
78
+ EXPECT_EQ (get_method_name (methods2[1 ]), " inline constexpr B::B(const B &)" );
79
+ EXPECT_EQ (get_method_name (methods2[2 ]), " inline constexpr B::B(B &&)" );
80
+ EXPECT_EQ (get_method_name (methods2[3 ]), " inline B::~B()" );
81
+ EXPECT_EQ (get_method_name (methods2[4 ]), " inline B &B::operator=(const B &)" );
82
+ EXPECT_EQ (get_method_name (methods2[5 ]), " inline B &B::operator=(B &&)" );
83
+
84
+ auto methods3 = InterOp::GetClassMethods (S, Decls[3 ]);
85
+
86
+ EXPECT_EQ (methods3.size (), 9 );
87
+ EXPECT_EQ (get_method_name (methods3[0 ]), " B::B(int n)" );
88
+ EXPECT_EQ (get_method_name (methods3[1 ]), " inline constexpr B::B(const B &)" );
89
+ EXPECT_EQ (get_method_name (methods3[3 ]), " inline C::C()" );
90
+ EXPECT_EQ (get_method_name (methods3[4 ]), " inline constexpr C::C(const C &)" );
91
+ EXPECT_EQ (get_method_name (methods3[5 ]), " inline constexpr C::C(C &&)" );
92
+ EXPECT_EQ (get_method_name (methods3[6 ]), " inline C &C::operator=(const C &)" );
93
+ EXPECT_EQ (get_method_name (methods3[7 ]), " inline C &C::operator=(C &&)" );
94
+ EXPECT_EQ (get_method_name (methods3[8 ]), " inline C::~C()" );
95
+
96
+ // Should not crash.
97
+ auto methods4 = InterOp::GetClassMethods (S, Decls[4 ]);
98
+ EXPECT_EQ (methods4.size (), 0 );
54
99
}
55
100
56
101
TEST (FunctionReflectionTest, ConstructorInGetClassMethods) {
0 commit comments