2323#include " checker/optional.h"
2424#include " checker/standard_library.h"
2525#include " checker/type_check_issue.h"
26+ #include " checker/type_checker.h"
2627#include " checker/validation_result.h"
2728#include " common/decl.h"
29+ #include " common/source.h"
2830#include " common/type.h"
2931#include " compiler/compiler.h"
3032#include " internal/testing.h"
@@ -51,7 +53,6 @@ TEST(CompilerFactoryTest, Works) {
5153 NewCompilerBuilder (cel::internal::GetSharedTestingDescriptorPool ()));
5254
5355 ASSERT_THAT (builder->AddLibrary (StandardCheckerLibrary ()), IsOk ());
54- builder->GetParserBuilder ().GetOptions ().enable_hidden_accumulator_var = true ;
5556 ASSERT_OK_AND_ASSIGN (auto compiler, std::move (*builder).Build ());
5657
5758 ASSERT_OK_AND_ASSIGN (
@@ -164,7 +165,52 @@ TEST(CompilerFactoryTest, ParserOptions) {
164165 ASSERT_THAT (compiler->Compile (" a.?b.orValue('foo')" ), IsOk ());
165166}
166167
167- TEST (CompilerFactoryTest, DisableStandarMacros) {
168+ TEST (CompilerFactoryTest, GetParser) {
169+ ASSERT_OK_AND_ASSIGN (
170+ auto builder,
171+ NewCompilerBuilder (cel::internal::GetSharedTestingDescriptorPool ()));
172+
173+ ASSERT_OK_AND_ASSIGN (auto compiler, std::move (*builder).Build ());
174+
175+ const cel::Parser& parser = compiler->GetParser ();
176+
177+ ASSERT_OK_AND_ASSIGN (auto source, cel::NewSource (" Or(a, b)" ));
178+ ASSERT_OK_AND_ASSIGN (auto ast, parser.Parse (*source));
179+ }
180+
181+ TEST (CompilerFactoryTest, GetTypeChecker) {
182+ ASSERT_OK_AND_ASSIGN (
183+ auto builder,
184+ NewCompilerBuilder (cel::internal::GetSharedTestingDescriptorPool ()));
185+
186+ absl::Status s;
187+ s.Update (builder->GetCheckerBuilder ().AddVariable (
188+ MakeVariableDecl (" a" , BoolType ())));
189+
190+ s.Update (builder->GetCheckerBuilder ().AddVariable (
191+ MakeVariableDecl (" b" , BoolType ())));
192+
193+ ASSERT_OK_AND_ASSIGN (
194+ auto or_decl,
195+ MakeFunctionDecl (" Or" , MakeOverloadDecl (" Or_bool_bool" , BoolType (),
196+ BoolType (), BoolType ())));
197+ s.Update (builder->GetCheckerBuilder ().AddFunction (std::move (or_decl)));
198+
199+ ASSERT_THAT (s, IsOk ());
200+ ASSERT_OK_AND_ASSIGN (auto compiler, std::move (*builder).Build ());
201+
202+ const cel::Parser& parser = compiler->GetParser ();
203+
204+ ASSERT_OK_AND_ASSIGN (auto source, cel::NewSource (" Or(a, b)" ));
205+ ASSERT_OK_AND_ASSIGN (auto ast, parser.Parse (*source));
206+
207+ const cel::TypeChecker& checker = compiler->GetTypeChecker ();
208+ ASSERT_OK_AND_ASSIGN (cel::ValidationResult result,
209+ checker.Check (std::move (ast)));
210+ EXPECT_TRUE (result.IsValid ());
211+ }
212+
213+ TEST (CompilerFactoryTest, DisableStandardMacros) {
168214 CompilerOptions options;
169215 options.parser_options .disable_standard_macros = true ;
170216
0 commit comments