@@ -139,5 +139,93 @@ TEST(TypeCheckerBuilderTest, AddLibraryForwardsErrors) {
139139 StatusIs (absl::StatusCode::kInternal , HasSubstr (" test error" )));
140140}
141141
142+ TEST (TypeCheckerBuilderTest, AddFunctionOverlapsWithStdMacroError) {
143+ TypeCheckerBuilder builder;
144+
145+ ASSERT_OK_AND_ASSIGN (
146+ auto fn_decl, MakeFunctionDecl (" map" , MakeMemberOverloadDecl (
147+ " ovl_3" , ListType (), ListType (),
148+ DynType (), DynType ())));
149+
150+ EXPECT_THAT (builder.AddFunction (fn_decl),
151+ StatusIs (absl::StatusCode::kInvalidArgument ,
152+ " overload for name 'map' with 3 argument(s) overlaps "
153+ " with predefined macro" ));
154+
155+ fn_decl.set_name (" filter" );
156+
157+ EXPECT_THAT (builder.AddFunction (fn_decl),
158+ StatusIs (absl::StatusCode::kInvalidArgument ,
159+ " overload for name 'filter' with 3 argument(s) overlaps "
160+ " with predefined macro" ));
161+
162+ fn_decl.set_name (" exists" );
163+
164+ EXPECT_THAT (builder.AddFunction (fn_decl),
165+ StatusIs (absl::StatusCode::kInvalidArgument ,
166+ " overload for name 'exists' with 3 argument(s) overlaps "
167+ " with predefined macro" ));
168+
169+ fn_decl.set_name (" exists_one" );
170+
171+ EXPECT_THAT (builder.AddFunction (fn_decl),
172+ StatusIs (absl::StatusCode::kInvalidArgument ,
173+ " overload for name 'exists_one' with 3 argument(s) "
174+ " overlaps with predefined macro" ));
175+
176+ fn_decl.set_name (" all" );
177+
178+ EXPECT_THAT (builder.AddFunction (fn_decl),
179+ StatusIs (absl::StatusCode::kInvalidArgument ,
180+ " overload for name 'all' with 3 argument(s) overlaps "
181+ " with predefined macro" ));
182+
183+ fn_decl.set_name (" optMap" );
184+
185+ EXPECT_THAT (builder.AddFunction (fn_decl),
186+ StatusIs (absl::StatusCode::kInvalidArgument ,
187+ " overload for name 'optMap' with 3 argument(s) overlaps "
188+ " with predefined macro" ));
189+
190+ fn_decl.set_name (" optFlatMap" );
191+
192+ EXPECT_THAT (
193+ builder.AddFunction (fn_decl),
194+ StatusIs (absl::StatusCode::kInvalidArgument ,
195+ " overload for name 'optFlatMap' with 3 argument(s) overlaps "
196+ " with predefined macro" ));
197+
198+ ASSERT_OK_AND_ASSIGN (
199+ fn_decl, MakeFunctionDecl (
200+ " has" , MakeOverloadDecl (" ovl_1" , BoolType (), DynType ())));
201+
202+ EXPECT_THAT (builder.AddFunction (fn_decl),
203+ StatusIs (absl::StatusCode::kInvalidArgument ,
204+ " overload for name 'has' with 1 argument(s) overlaps "
205+ " with predefined macro" ));
206+
207+ ASSERT_OK_AND_ASSIGN (
208+ fn_decl, MakeFunctionDecl (" map" , MakeMemberOverloadDecl (
209+ " ovl_4" , ListType (), ListType (),
210+
211+ DynType (), DynType (), DynType ())));
212+
213+ EXPECT_THAT (builder.AddFunction (fn_decl),
214+ StatusIs (absl::StatusCode::kInvalidArgument ,
215+ " overload for name 'map' with 4 argument(s) overlaps "
216+ " with predefined macro" ));
217+ }
218+
219+ TEST (TypeCheckerBuilderTest, AddFunctionNoOverlapWithStdMacroError) {
220+ TypeCheckerBuilder builder;
221+
222+ ASSERT_OK_AND_ASSIGN (
223+ auto fn_decl,
224+ MakeFunctionDecl (" has" , MakeMemberOverloadDecl (" ovl" , BoolType (),
225+ DynType (), StringType ())));
226+
227+ EXPECT_THAT (builder.AddFunction (fn_decl), IsOk ());
228+ }
229+
142230} // namespace
143231} // namespace cel
0 commit comments