@@ -142,34 +142,30 @@ TEST(FunctionReflectionTest, GetFunctionsUsingName) {
142
142
int f4(int a) { return a + 1; }
143
143
int f4() { return 0; }
144
144
}
145
+
146
+ typedef A shadow_A;
145
147
)" ;
146
148
147
149
GetAllTopLevelDecls (code, Decls);
148
150
151
+ Sema *S = &Interp->getCI ()->getSema ();
152
+
149
153
// This lambda can take in the scope and the name of the function
150
- // and check if GetFunctionsUsingName is returning a vector of functions
151
- // with size equal to number_of_overloads
152
- auto test_get_funcs_using_name = [&](Cpp::TCppScope_t scope,
153
- const std::string name,
154
- std::size_t number_of_overloads) {
155
- Sema *S = &Interp->getCI ()->getSema ();
154
+ // and returns the size of the vector returned by GetFunctionsUsingName
155
+ auto get_number_of_funcs_using_name = [&](Cpp::TCppScope_t scope,
156
+ const std::string &name) {
156
157
auto Funcs = Cpp::GetFunctionsUsingName (S, scope, name);
157
158
158
- // Check if the number of functions returned is equal to the
159
- // number_of_overloads given by the user
160
- EXPECT_TRUE (Funcs.size () == number_of_overloads);
161
- for (auto *F : Funcs) {
162
- // Check if the fully scoped name of the function matches its
163
- // expected fully scoped name
164
- EXPECT_EQ (Cpp::GetQualifiedName (F),
165
- Cpp::GetQualifiedName (scope) + " ::" + name);
166
- }
159
+ return Funcs.size ();
167
160
};
168
161
169
- test_get_funcs_using_name (Decls[0 ], " f1" , 3 );
170
- test_get_funcs_using_name (Decls[0 ], " f2" , 1 );
171
- test_get_funcs_using_name (Decls[0 ], " f3" , 1 );
172
- test_get_funcs_using_name (Decls[1 ], " f4" , 2 );
162
+ EXPECT_EQ (get_number_of_funcs_using_name (Decls[0 ], " f1" ), 3 );
163
+ EXPECT_EQ (get_number_of_funcs_using_name (Decls[0 ], " f2" ), 1 );
164
+ EXPECT_EQ (get_number_of_funcs_using_name (Decls[0 ], " f3" ), 1 );
165
+ EXPECT_EQ (get_number_of_funcs_using_name (Decls[1 ], " f4" ), 2 );
166
+ EXPECT_EQ (get_number_of_funcs_using_name (Decls[2 ], " f1" ), 3 );
167
+ EXPECT_EQ (get_number_of_funcs_using_name (Decls[2 ], " f2" ), 1 );
168
+ EXPECT_EQ (get_number_of_funcs_using_name (Decls[2 ], " f3" ), 1 );
173
169
}
174
170
175
171
TEST (FunctionReflectionTest, GetFunctionReturnType) {
0 commit comments