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

Function RunExpression

eval/eval/create_list_step_test.cc:72–106  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

70
71// Helper method. Creates simple pipeline containing Select step and runs it.
72absl::StatusOr<CelValue> RunExpression(
73 const absl_nonnull std::shared_ptr<const RuntimeEnv>& env,
74 const std::vector<int64_t>& values, google::protobuf::Arena* arena,
75 bool enable_unknowns) {
76 ExecutionPath path;
77 Expr dummy_expr;
78
79 auto& create_list = dummy_expr.mutable_list_expr();
80 for (auto value : values) {
81 auto& expr0 = create_list.mutable_elements().emplace_back().mutable_expr();
82 expr0.mutable_const_expr().set_int64_value(value);
83 CEL_ASSIGN_OR_RETURN(
84 auto const_step,
85 CreateConstValueStep(cel::interop_internal::CreateIntValue(value),
86 /*expr_id=*/-1));
87 path.push_back(std::move(const_step));
88 }
89
90 CEL_ASSIGN_OR_RETURN(auto step,
91 CreateCreateListStep(create_list, dummy_expr.id()));
92 path.push_back(std::move(step));
93 cel::RuntimeOptions options;
94 if (enable_unknowns) {
95 options.unknown_processing = cel::UnknownProcessingOptions::kAttributeOnly;
96 }
97 CelExpressionFlatImpl cel_expr(
98 env,
99
100 FlatExpression(std::move(path),
101 /*comprehension_slot_count=*/0,
102 env->type_registry.GetComposedTypeProvider(), options));
103 Activation activation;
104
105 return cel_expr.Evaluate(activation, arena);
106}
107
108// Helper method. Creates simple pipeline containing Select step and runs it.
109absl::StatusOr<CelValue> RunExpressionWithCelValues(

Callers 4

CEL_ASSIGN_OR_RETURNFunction · 0.85
TESTFunction · 0.85
RunExpressionMethod · 0.85
TEST_PFunction · 0.85

Calls 2

FlatExpressionClass · 0.85
EvaluateMethod · 0.45

Tested by

no test coverage detected