|
41 | 41 | import com.google.common.util.concurrent.MoreExecutors; |
42 | 42 | import com.google.protobuf.Any; |
43 | 43 | import com.google.protobuf.ByteString; |
| 44 | +import com.google.protobuf.DescriptorProtos.FileDescriptorProto; |
44 | 45 | import com.google.protobuf.DescriptorProtos.FileDescriptorSet; |
| 46 | +import com.google.protobuf.Descriptors.FileDescriptor; |
45 | 47 | import com.google.protobuf.Duration; |
46 | 48 | import com.google.protobuf.FieldMask; |
47 | 49 | import com.google.protobuf.Message; |
48 | 50 | import com.google.protobuf.NullValue; |
49 | 51 | import com.google.protobuf.Struct; |
| 52 | +import com.google.protobuf.TextFormat; |
50 | 53 | import com.google.protobuf.Timestamp; |
51 | 54 | import com.google.protobuf.util.Timestamps; |
52 | 55 | import com.google.rpc.context.AttributeContext; |
@@ -1021,6 +1024,34 @@ public void compile_enumTypeTransitiveResolutionFailure() { |
1021 | 1024 | assertThat(e).hasMessageThat().contains("undeclared reference to 'NullValue'"); |
1022 | 1025 | } |
1023 | 1026 |
|
| 1027 | + @Test |
| 1028 | + public void compile_multipleInstancesOfEnumDescriptor_dedupedByFullName() throws Exception { |
| 1029 | + String enumTextProto = |
| 1030 | + "name: \"standalone_global_enum.proto\"\n" |
| 1031 | + + "package: \"dev.cel.testing.testdata.proto3\"\n" |
| 1032 | + + "enum_type {\n" |
| 1033 | + + " name: \"StandaloneGlobalEnum\"\n" |
| 1034 | + + " value {\n" |
| 1035 | + + " name: \"SGOO\"\n" |
| 1036 | + + " number: 0\n" |
| 1037 | + + " }\n" |
| 1038 | + + "}\n" |
| 1039 | + + "syntax: \"proto3\"\n"; |
| 1040 | + FileDescriptorProto enumFileDescriptorProto = |
| 1041 | + TextFormat.parse(enumTextProto, FileDescriptorProto.class); |
| 1042 | + FileDescriptor enumFileDescriptor = |
| 1043 | + FileDescriptor.buildFrom(enumFileDescriptorProto, new FileDescriptor[] {}); |
| 1044 | + Cel cel = |
| 1045 | + standardCelBuilderWithMacros() |
| 1046 | + .setContainer("dev.cel.testing.testdata") |
| 1047 | + .addFileTypes(enumFileDescriptor) |
| 1048 | + .addFileTypes(StandaloneGlobalEnum.getDescriptor().getFile()) |
| 1049 | + .build(); |
| 1050 | + |
| 1051 | + assertThat(cel.compile("dev.cel.testing.testdata.proto3.StandaloneGlobalEnum.SGOO").getAst()) |
| 1052 | + .isNotNull(); |
| 1053 | + } |
| 1054 | + |
1024 | 1055 | @Test |
1025 | 1056 | public void program_customVarResolver() throws Exception { |
1026 | 1057 | Cel cel = |
|
0 commit comments