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

Method RunExpression

eval/eval/select_step_test.cc:119–155  ·  view source on GitHub ↗

Helper method. Creates simple pipeline containing Select step and runs it.

Source from the content-addressed store, hash-verified

117 SelectStepTest() : env_(NewTestingRuntimeEnv()) {}
118 // Helper method. Creates simple pipeline containing Select step and runs it.
119 absl::StatusOr<CelValue> RunExpression(const CelValue target,
120 absl::string_view field, bool test,
121 absl::string_view unknown_path,
122 RunExpressionOptions options) {
123 ExecutionPath path;
124
125 Expr expr;
126 auto& select = expr.mutable_select_expr();
127 select.set_field(std::string(field));
128 select.set_test_only(test);
129 Expr& expr0 = select.mutable_operand();
130
131 auto& ident = expr0.mutable_ident_expr();
132 ident.set_name("target");
133 CEL_ASSIGN_OR_RETURN(auto step0, CreateIdentStep(ident.name(), expr0.id()));
134 CEL_ASSIGN_OR_RETURN(
135 auto step1,
136 CreateSelectStep(select, expr.id(),
137 options.enable_wrapper_type_null_unboxing));
138
139 path.push_back(std::move(step0));
140 path.push_back(std::move(step1));
141
142 cel::RuntimeOptions runtime_options;
143 if (options.enable_unknowns) {
144 runtime_options.unknown_processing =
145 cel::UnknownProcessingOptions::kAttributeOnly;
146 }
147 CelExpressionFlatImpl cel_expr(
148 env_, FlatExpression(std::move(path), /*comprehension_slot_count=*/0,
149 env_->type_registry.GetComposedTypeProvider(),
150 runtime_options));
151 Activation activation;
152 activation.InsertValue("target", target);
153
154 return cel_expr.Evaluate(activation, &arena_);
155 }
156
157 absl::StatusOr<CelValue> RunExpression(const TestExtensions* message,
158 absl::string_view field, bool test,

Callers

nothing calls this directly

Calls 8

FlatExpressionClass · 0.85
RunExpressionFunction · 0.85
set_fieldMethod · 0.80
set_test_onlyMethod · 0.80
InsertValueMethod · 0.80
CreateMapFunction · 0.50
set_nameMethod · 0.45
EvaluateMethod · 0.45

Tested by

no test coverage detected