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

Function TEST_F

eval/compiler/instrumentation_test.cc:81–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81TEST_F(InstrumentationTest, Basic) {
82 FlatExprBuilder builder(env_, options_);
83
84 std::vector<int64_t> expr_ids;
85 Instrumentation expr_id_recorder =
86 [&expr_ids](int64_t expr_id, const cel::Value&) -> absl::Status {
87 expr_ids.push_back(expr_id);
88 return absl::OkStatus();
89 };
90
91 builder.AddProgramOptimizer(CreateInstrumentationExtension(
92 [=](const cel::Ast&) -> Instrumentation { return expr_id_recorder; }));
93
94 ASSERT_OK_AND_ASSIGN(ParsedExpr expr, Parse("1 + 2 + 3"));
95 ASSERT_OK_AND_ASSIGN(auto ast,
96 cel::extensions::CreateAstFromParsedExpr(expr));
97 ASSERT_OK_AND_ASSIGN(auto plan,
98 builder.CreateExpressionImpl(std::move(ast),
99 /*issues=*/nullptr));
100
101 auto state = plan.MakeEvaluatorState(env_->descriptor_pool.get(),
102 env_->MutableMessageFactory(), &arena_);
103 cel::Activation activation;
104
105 ASSERT_OK_AND_ASSIGN(auto value, plan.EvaluateWithCallback(
106 activation, /*embedder_context=*/nullptr,
107 EvaluationListener(), state));
108
109 // AST for the test expression:
110 // + <4>
111 // / \
112 // +<2> 3<5>
113 // / \
114 // 1<1> 2<3>
115 EXPECT_THAT(expr_ids, ElementsAre(1, 3, 2, 5, 4));
116}
117
118TEST_F(InstrumentationTest, BasicWithConstFolding) {
119 FlatExprBuilder builder(env_, options_);

Callers

nothing calls this directly

Calls 15

AddProgramOptimizerMethod · 0.80
MakeEvaluatorStateMethod · 0.80
clearMethod · 0.80
InsertOrAssignValueMethod · 0.80
EvaluateWithCallbackMethod · 0.80
ASSERT_OK_AND_ASSIGNFunction · 0.70
BoolValueClass · 0.50
ParseFunction · 0.50
CreateAstFromParsedExprFunction · 0.50

Tested by

no test coverage detected