| 127 | } |
| 128 | |
| 129 | TEST(ResolveReferences, Basic) { |
| 130 | std::unique_ptr<Ast> expr_ast = ParseTestProto(kExpr); |
| 131 | expr_ast->mutable_reference_map()[2].set_name("foo.bar.var1"); |
| 132 | expr_ast->mutable_reference_map()[5].set_name("bar.foo.var2"); |
| 133 | IssueCollector issues(RuntimeIssue::Severity::kError); |
| 134 | CelFunctionRegistry func_registry; |
| 135 | cel::TypeRegistry type_registry; |
| 136 | Resolver registry("", func_registry.InternalGetRegistry(), type_registry, |
| 137 | type_registry.GetComposedTypeProvider()); |
| 138 | |
| 139 | auto result = ResolveReferences(registry, issues, *expr_ast); |
| 140 | ASSERT_THAT(result, IsOkAndHolds(true)); |
| 141 | |
| 142 | EXPECT_THAT(ExprToProtoOrDie(expr_ast->root_expr()), EqualsProto(R"pb( |
| 143 | id: 1 |
| 144 | call_expr { |
| 145 | function: "_&&_" |
| 146 | args { |
| 147 | id: 2 |
| 148 | ident_expr { name: "foo.bar.var1" } |
| 149 | } |
| 150 | args { |
| 151 | id: 5 |
| 152 | ident_expr { name: "bar.foo.var2" } |
| 153 | } |
| 154 | })pb")); |
| 155 | } |
| 156 | |
| 157 | TEST(ResolveReferences, ReturnsFalseIfNoChanges) { |
| 158 | std::unique_ptr<Ast> expr_ast = ParseTestProto(kExpr); |
nothing calls this directly
no test coverage detected