|
28 | 28 | #include "checker/type_checker.h" |
29 | 29 | #include "checker/validation_result.h" |
30 | 30 | #include "common/ast.h" |
31 | | -#include "common/ast/expr.h" |
32 | 31 | #include "common/decl.h" |
33 | 32 | #include "common/type.h" |
34 | 33 | #include "common/type_introspector.h" |
@@ -71,52 +70,42 @@ TEST_P(ContextDeclsFieldsDefinedTest, ContextDeclsFieldsDefined) { |
71 | 70 | INSTANTIATE_TEST_SUITE_P( |
72 | 71 | TestAllTypes, ContextDeclsFieldsDefinedTest, |
73 | 72 | testing::Values( |
74 | | - ContextDeclsTestCase{"single_int64", |
75 | | - TypeSpec(ast_internal::PrimitiveType::kInt64)}, |
76 | | - ContextDeclsTestCase{"single_uint32", |
77 | | - TypeSpec(ast_internal::PrimitiveType::kUint64)}, |
78 | | - ContextDeclsTestCase{"single_double", |
79 | | - TypeSpec(ast_internal::PrimitiveType::kDouble)}, |
80 | | - ContextDeclsTestCase{"single_string", |
81 | | - TypeSpec(ast_internal::PrimitiveType::kString)}, |
82 | | - ContextDeclsTestCase{"single_any", |
83 | | - TypeSpec(ast_internal::WellKnownType::kAny)}, |
| 73 | + ContextDeclsTestCase{"single_int64", TypeSpec(PrimitiveType::kInt64)}, |
| 74 | + ContextDeclsTestCase{"single_uint32", TypeSpec(PrimitiveType::kUint64)}, |
| 75 | + ContextDeclsTestCase{"single_double", TypeSpec(PrimitiveType::kDouble)}, |
| 76 | + ContextDeclsTestCase{"single_string", TypeSpec(PrimitiveType::kString)}, |
| 77 | + ContextDeclsTestCase{"single_any", TypeSpec(WellKnownTypeSpec::kAny)}, |
84 | 78 | ContextDeclsTestCase{"single_duration", |
85 | | - TypeSpec(ast_internal::WellKnownType::kDuration)}, |
86 | | - ContextDeclsTestCase{"single_bool_wrapper", |
87 | | - TypeSpec(ast_internal::PrimitiveTypeWrapper( |
88 | | - ast_internal::PrimitiveType::kBool))}, |
| 79 | + TypeSpec(WellKnownTypeSpec::kDuration)}, |
| 80 | + ContextDeclsTestCase{ |
| 81 | + "single_bool_wrapper", |
| 82 | + TypeSpec(PrimitiveTypeWrapper(PrimitiveType::kBool))}, |
89 | 83 | ContextDeclsTestCase{ |
90 | 84 | "list_value", |
91 | | - TypeSpec(ast_internal::ListType( |
92 | | - std::make_unique<TypeSpec>(ast_internal::DynamicType())))}, |
| 85 | + TypeSpec(ListTypeSpec(std::make_unique<TypeSpec>(DynTypeSpec())))}, |
93 | 86 | ContextDeclsTestCase{ |
94 | 87 | "standalone_message", |
95 | | - TypeSpec(ast_internal::MessageType( |
| 88 | + TypeSpec(MessageTypeSpec( |
96 | 89 | "cel.expr.conformance.proto3.TestAllTypes.NestedMessage"))}, |
97 | 90 | ContextDeclsTestCase{"standalone_enum", |
98 | | - TypeSpec(ast_internal::PrimitiveType::kInt64)}, |
99 | | - ContextDeclsTestCase{ |
100 | | - "repeated_bytes", |
101 | | - TypeSpec(ast_internal::ListType(std::make_unique<TypeSpec>( |
102 | | - ast_internal::PrimitiveType::kBytes)))}, |
| 91 | + TypeSpec(PrimitiveType::kInt64)}, |
| 92 | + ContextDeclsTestCase{"repeated_bytes", |
| 93 | + TypeSpec(ListTypeSpec(std::make_unique<TypeSpec>( |
| 94 | + PrimitiveType::kBytes)))}, |
103 | 95 | ContextDeclsTestCase{ |
104 | 96 | "repeated_nested_message", |
105 | | - TypeSpec(ast_internal::ListType(std::make_unique< |
106 | | - TypeSpec>(ast_internal::MessageType( |
| 97 | + TypeSpec(ListTypeSpec(std::make_unique<TypeSpec>(MessageTypeSpec( |
107 | 98 | "cel.expr.conformance.proto3.TestAllTypes.NestedMessage"))))}, |
108 | 99 | ContextDeclsTestCase{ |
109 | 100 | "map_int32_timestamp", |
110 | | - TypeSpec(ast_internal::MapType( |
111 | | - std::make_unique<TypeSpec>(ast_internal::PrimitiveType::kInt64), |
112 | | - std::make_unique<TypeSpec>( |
113 | | - ast_internal::WellKnownType::kTimestamp)))}, |
| 101 | + TypeSpec(MapTypeSpec( |
| 102 | + std::make_unique<TypeSpec>(PrimitiveType::kInt64), |
| 103 | + std::make_unique<TypeSpec>(WellKnownTypeSpec::kTimestamp)))}, |
114 | 104 | ContextDeclsTestCase{ |
115 | 105 | "single_struct", |
116 | | - TypeSpec(ast_internal::MapType( |
117 | | - std::make_unique<TypeSpec>( |
118 | | - ast_internal::PrimitiveType::kString), |
119 | | - std::make_unique<TypeSpec>(ast_internal::DynamicType())))})); |
| 106 | + TypeSpec( |
| 107 | + MapTypeSpec(std::make_unique<TypeSpec>(PrimitiveType::kString), |
| 108 | + std::make_unique<TypeSpec>(DynTypeSpec())))})); |
120 | 109 |
|
121 | 110 | TEST(ContextDeclsTest, ErrorOnDuplicateContextDeclaration) { |
122 | 111 | TypeCheckerBuilderImpl builder(internal::GetSharedTestingDescriptorPool(), |
@@ -323,8 +312,7 @@ TEST(TypeCheckerBuilderImplTest, ReplaceVariable) { |
323 | 312 |
|
324 | 313 | const auto& checked_ast = *result.GetAst(); |
325 | 314 |
|
326 | | - EXPECT_EQ(checked_ast.GetReturnType(), |
327 | | - TypeSpec(ast_internal::PrimitiveType::kString)); |
| 315 | + EXPECT_EQ(checked_ast.GetReturnType(), TypeSpec(PrimitiveType::kString)); |
328 | 316 | } |
329 | 317 |
|
330 | 318 | } // namespace |
|
0 commit comments