Helper method. Creates simple pipeline containing Select step and runs it.
| 70 | |
| 71 | // Helper method. Creates simple pipeline containing Select step and runs it. |
| 72 | absl::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. |
| 109 | absl::StatusOr<CelValue> RunExpressionWithCelValues( |
no test coverage detected