MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / TestLibrary

Method TestLibrary

env/env_test.cc:71–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69class TestLibrary : public CompilerLibrary {
70 public:
71 explicit TestLibrary(int version)
72 : CompilerLibrary(
73 "testlib",
74 [version](ParserBuilder& builder) {
75 absl::Status status;
76 CEL_ASSIGN_OR_RETURN(
77 auto macro1,
78 cel::Macro::Global("testMacro1", 0, TestMacroExpander));
79 status.Update(builder.AddMacro(macro1));
80 if (version == 2) {
81 CEL_ASSIGN_OR_RETURN(
82 auto macro2,
83 cel::Macro::Global("testMacro2", 0, TestMacroExpander));
84 status.Update(builder.AddMacro(macro2));
85 }
86 return status;
87 },
88 [version](TypeCheckerBuilder& builder) {
89 absl::Status status;
90 CEL_ASSIGN_OR_RETURN(
91 auto func1, cel::MakeFunctionDecl(
92 "testFunc1", MakeOverloadDecl(StringType())));
93 status.Update(builder.AddFunction(func1));
94 if (version == 2) {
95 CEL_ASSIGN_OR_RETURN(
96 auto func2,
97 cel::MakeFunctionDecl("testFunc2",
98 MakeOverloadDecl(StringType())));
99 status.Update(builder.AddFunction(func2));
100 }
101 return status;
102 }) {};
103};
104
105absl::StatusOr<cel::Value> CompileAndEvalExpr(

Callers

nothing calls this directly

Calls 2

AddMacroMethod · 0.80
AddFunctionMethod · 0.45

Tested by

no test coverage detected