From ea6e21c506a3d25358dfb5f74c0c13b97c4f37a7 Mon Sep 17 00:00:00 2001 From: Justin King Date: Mon, 15 Apr 2024 15:37:54 -0700 Subject: [PATCH] Enable `math` conformance tests PiperOrigin-RevId: 625105405 --- conformance/BUILD | 3 +++ conformance/server.cc | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/conformance/BUILD b/conformance/BUILD index 8390e5cd7..09ff3acaf 100644 --- a/conformance/BUILD +++ b/conformance/BUILD @@ -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", @@ -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", diff --git a/conformance/server.cc b/conformance/server.cc index a9a87675a..7ca2fd64f 100644 --- a/conformance/server.cc +++ b/conformance/server.cc @@ -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" @@ -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, @@ -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))); @@ -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(); }