| OLD | NEW |
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 library message_generator_test; | 6 library message_generator_test; |
| 7 | 7 |
| 8 import 'package:protoc-plugin/src/descriptor.pb.dart'; | 8 import 'package:protoc-plugin/src/descriptor.pb.dart'; |
| 9 import 'package:protoc-plugin/src/plugin.pb.dart'; | 9 import 'package:protoc-plugin/src/plugin.pb.dart'; |
| 10 import 'package:protoc-plugin/protoc.dart'; | 10 import 'package:protoc-plugin/protoc.dart'; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 bool hasType() => hasField(2); | 56 bool hasType() => hasField(2); |
| 57 void clearType() => clearField(2); | 57 void clearType() => clearField(2); |
| 58 | 58 |
| 59 String get name => getField(3); | 59 String get name => getField(3); |
| 60 void set name(String v) { setField(3, v); } | 60 void set name(String v) { setField(3, v); } |
| 61 bool hasName() => hasField(3); | 61 bool hasName() => hasField(3); |
| 62 void clearName() => clearField(3); | 62 void clearName() => clearField(3); |
| 63 } | 63 } |
| 64 | 64 |
| 65 '''; | 65 '''; |
| 66 FileDescriptorProto fd = new FileDescriptorProto(); |
| 66 EnumDescriptorProto ed = new EnumDescriptorProto() | 67 EnumDescriptorProto ed = new EnumDescriptorProto() |
| 67 ..name = 'PhoneType' | 68 ..name = 'PhoneType' |
| 68 ..value.addAll([ | 69 ..value.addAll([ |
| 69 new EnumValueDescriptorProto() | 70 new EnumValueDescriptorProto() |
| 70 ..name = 'MOBILE' | 71 ..name = 'MOBILE' |
| 71 ..number = 0, | 72 ..number = 0, |
| 72 new EnumValueDescriptorProto() | 73 new EnumValueDescriptorProto() |
| 73 ..name = 'HOME' | 74 ..name = 'HOME' |
| 74 ..number = 1, | 75 ..number = 1, |
| 75 new EnumValueDescriptorProto() | 76 new EnumValueDescriptorProto() |
| (...skipping 10 matching lines...) Expand all Loading... |
| 86 ..name = 'number' | 87 ..name = 'number' |
| 87 ..number = 1 | 88 ..number = 1 |
| 88 ..label = FieldDescriptorProto_Label.LABEL_REQUIRED | 89 ..label = FieldDescriptorProto_Label.LABEL_REQUIRED |
| 89 ..type = FieldDescriptorProto_Type.TYPE_STRING, | 90 ..type = FieldDescriptorProto_Type.TYPE_STRING, |
| 90 // optional PhoneType type = 2 [default = HOME]; | 91 // optional PhoneType type = 2 [default = HOME]; |
| 91 new FieldDescriptorProto() | 92 new FieldDescriptorProto() |
| 92 ..name = 'type' | 93 ..name = 'type' |
| 93 ..number = 2 | 94 ..number = 2 |
| 94 ..label = FieldDescriptorProto_Label.LABEL_OPTIONAL | 95 ..label = FieldDescriptorProto_Label.LABEL_OPTIONAL |
| 95 ..type = FieldDescriptorProto_Type.TYPE_ENUM | 96 ..type = FieldDescriptorProto_Type.TYPE_ENUM |
| 96 ..typeName = 'PhoneNumber.PhoneType', | 97 ..typeName = '.PhoneNumber.PhoneType', |
| 97 new FieldDescriptorProto() | 98 new FieldDescriptorProto() |
| 98 ..name = 'name' | 99 ..name = 'name' |
| 99 ..number = 3 | 100 ..number = 3 |
| 100 ..label = FieldDescriptorProto_Label.LABEL_OPTIONAL | 101 ..label = FieldDescriptorProto_Label.LABEL_OPTIONAL |
| 101 ..type = FieldDescriptorProto_Type.TYPE_STRING | 102 ..type = FieldDescriptorProto_Type.TYPE_STRING |
| 102 ..defaultValue = r'$' | 103 ..defaultValue = r'$' |
| 103 ]) | 104 ]) |
| 104 ..enumType.add(ed); | 105 ..enumType.add(ed); |
| 105 MemoryWriter buffer = new MemoryWriter(); | 106 MemoryWriter buffer = new MemoryWriter(); |
| 106 IndentingWriter writer = new IndentingWriter(' ', buffer); | 107 IndentingWriter writer = new IndentingWriter(' ', buffer); |
| 107 var options = | 108 var options = |
| 108 new GenerationOptions( | 109 new GenerationOptions( |
| 109 new CodeGeneratorRequest(), new CodeGeneratorResponse()); | 110 new CodeGeneratorRequest(), new CodeGeneratorResponse()); |
| 110 MessageGenerator mg = | 111 var context = new GenerationContext(options); |
| 111 new MessageGenerator( | 112 FileGenerator fg = new FileGenerator(fd, null, context); |
| 112 md, null, new GenerationContext(options)); | 113 MessageGenerator mg = new MessageGenerator(md, fg, context); |
| 113 mg.initializeFields(); | 114 mg.initializeFields(); |
| 114 mg.generate(writer); | 115 mg.generate(writer); |
| 115 expect(buffer.toString(), expected); | 116 expect(buffer.toString(), expected); |
| 116 }); | 117 }); |
| 117 } | 118 } |
| OLD | NEW |