Skip to content

Commit

Permalink
Enable math conformance tests
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 625105405
  • Loading branch information
jcking authored and copybara-github committed Apr 15, 2024
1 parent d3dbcda commit ea6e21c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions conformance/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ALL_TESTS = [
"@com_google_cel_spec//tests/simple:testdata/lists.textproto",
"@com_google_cel_spec//tests/simple:testdata/logic.textproto",
"@com_google_cel_spec//tests/simple:testdata/macros.textproto",
"@com_google_cel_spec//tests/simple:testdata/math_ext.textproto",
"@com_google_cel_spec//tests/simple:testdata/namespace.textproto",
"@com_google_cel_spec//tests/simple:testdata/optionals.textproto",
"@com_google_cel_spec//tests/simple:testdata/parse.textproto",
Expand Down Expand Up @@ -66,6 +67,8 @@ cc_binary(
"//eval/public:transform_utility",
"//extensions:bindings_ext",
"//extensions:encoders",
"//extensions:math_ext",
"//extensions:math_ext_macros",
"//extensions:strings",
"//extensions/protobuf:enum_adapter",
"//extensions/protobuf:memory_manager",
Expand Down
7 changes: 7 additions & 0 deletions conformance/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "eval/public/transform_utility.h"
#include "extensions/bindings_ext.h"
#include "extensions/encoders.h"
#include "extensions/math_ext.h"
#include "extensions/math_ext_macros.h"
#include "extensions/protobuf/enum_adapter.h"
#include "extensions/protobuf/memory_manager.h"
#include "extensions/protobuf/runtime_adapter.h"
Expand Down Expand Up @@ -124,6 +126,7 @@ absl::Status LegacyParse(const conformance::v1alpha1::ParseRequest& request,
cel::MacroRegistry macros;
CEL_RETURN_IF_ERROR(cel::RegisterStandardMacros(macros, options));
CEL_RETURN_IF_ERROR(cel::extensions::RegisterBindingsMacros(macros, options));
CEL_RETURN_IF_ERROR(cel::extensions::RegisterMathMacros(macros, options));
CEL_ASSIGN_OR_RETURN(auto source, cel::NewSource(request.cel_source(),
request.source_location()));
CEL_ASSIGN_OR_RETURN(auto parsed_expr,
Expand Down Expand Up @@ -177,6 +180,8 @@ class LegacyConformanceServiceImpl : public ConformanceServiceInterface {
builder->GetRegistry(), options));
CEL_RETURN_IF_ERROR(cel::extensions::RegisterStringsFunctions(
builder->GetRegistry(), options));
CEL_RETURN_IF_ERROR(cel::extensions::RegisterMathExtensionFunctions(
builder->GetRegistry(), options));

return absl::WrapUnique(
new LegacyConformanceServiceImpl(std::move(builder)));
Expand Down Expand Up @@ -319,6 +324,8 @@ class ModernConformanceServiceImpl : public ConformanceServiceInterface {
builder.function_registry(), options));
CEL_RETURN_IF_ERROR(cel::extensions::RegisterStringsFunctions(
builder.function_registry(), options));
CEL_RETURN_IF_ERROR(cel::extensions::RegisterMathExtensionFunctions(
builder.function_registry(), options));

return std::move(builder).Build();
}
Expand Down

0 comments on commit ea6e21c

Please sign in to comment.