Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: test/message_generator_test.dart

Issue 1829573002: Fix all strong mode warnings in protoc-plugin (Closed) Base URL: git@github.com:dart-lang/dart-protoc-plugin.git@master
Patch Set: regenerate pb.dart files Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/generated_message_test.dart ('k') | test/message_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/indenting_writer.dart'; 8 import 'package:protoc_plugin/indenting_writer.dart';
9 import 'package:protoc_plugin/protoc.dart'; 9 import 'package:protoc_plugin/protoc.dart';
10 import 'package:protoc_plugin/src/descriptor.pb.dart'; 10 import 'package:protoc_plugin/src/descriptor.pb.dart';
(...skipping 10 matching lines...) Expand all
21 static const PhoneNumber_PhoneType WORK = const PhoneNumber_PhoneType._(2, 'WO RK'); 21 static const PhoneNumber_PhoneType WORK = const PhoneNumber_PhoneType._(2, 'WO RK');
22 22
23 static const PhoneNumber_PhoneType BUSINESS = WORK; 23 static const PhoneNumber_PhoneType BUSINESS = WORK;
24 24
25 static const List<PhoneNumber_PhoneType> values = const <PhoneNumber_PhoneType > [ 25 static const List<PhoneNumber_PhoneType> values = const <PhoneNumber_PhoneType > [
26 MOBILE, 26 MOBILE,
27 HOME, 27 HOME,
28 WORK, 28 WORK,
29 ]; 29 ];
30 30
31 static final Map<int, PhoneNumber_PhoneType> _byValue = ProtobufEnum.initByVal ue(values); 31 static final Map<int, dynamic> _byValue = ProtobufEnum.initByValue(values);
32 static PhoneNumber_PhoneType valueOf(int value) => _byValue[value]; 32 static PhoneNumber_PhoneType valueOf(int value) => _byValue[value] as PhoneNum ber_PhoneType;
33 static void $checkItem(PhoneNumber_PhoneType v) { 33 static void $checkItem(PhoneNumber_PhoneType v) {
34 if (v is !PhoneNumber_PhoneType) checkItemFailed(v, 'PhoneNumber_PhoneType') ; 34 if (v is !PhoneNumber_PhoneType) checkItemFailed(v, 'PhoneNumber_PhoneType') ;
35 } 35 }
36 36
37 const PhoneNumber_PhoneType._(int v, String n) : super(v, n); 37 const PhoneNumber_PhoneType._(int v, String n) : super(v, n);
38 } 38 }
39 39
40 class PhoneNumber extends GeneratedMessage { 40 class PhoneNumber extends GeneratedMessage {
41 static final BuilderInfo _i = new BuilderInfo('PhoneNumber') 41 static final BuilderInfo _i = new BuilderInfo('PhoneNumber')
42 ..a(1, 'number', PbFieldType.QS) 42 ..a/*<String>*/(1, 'number', PbFieldType.QS)
43 ..e(2, 'type', PbFieldType.OE, PhoneNumber_PhoneType.MOBILE, PhoneNumber_Pho neType.valueOf) 43 ..e/*<PhoneNumber_PhoneType>*/(2, 'type', PbFieldType.OE, PhoneNumber_PhoneT ype.MOBILE, PhoneNumber_PhoneType.valueOf)
44 ..a(3, 'name', PbFieldType.OS, '\$') 44 ..a/*<String>*/(3, 'name', PbFieldType.OS, '\$')
45 ; 45 ;
46 46
47 PhoneNumber() : super(); 47 PhoneNumber() : super();
48 PhoneNumber.fromBuffer(List<int> i, [ExtensionRegistry r = ExtensionRegistry.E MPTY]) : super.fromBuffer(i, r); 48 PhoneNumber.fromBuffer(List<int> i, [ExtensionRegistry r = ExtensionRegistry.E MPTY]) : super.fromBuffer(i, r);
49 PhoneNumber.fromJson(String i, [ExtensionRegistry r = ExtensionRegistry.EMPTY] ) : super.fromJson(i, r); 49 PhoneNumber.fromJson(String i, [ExtensionRegistry r = ExtensionRegistry.EMPTY] ) : super.fromJson(i, r);
50 PhoneNumber clone() => new PhoneNumber()..mergeFromMessage(this); 50 PhoneNumber clone() => new PhoneNumber()..mergeFromMessage(this);
51 BuilderInfo get info_ => _i; 51 BuilderInfo get info_ => _i;
52 static PhoneNumber create() => new PhoneNumber(); 52 static PhoneNumber create() => new PhoneNumber();
53 static PbList<PhoneNumber> createRepeated() => new PbList<PhoneNumber>(); 53 static PbList<PhoneNumber> createRepeated() => new PbList<PhoneNumber>();
54 static PhoneNumber getDefault() { 54 static PhoneNumber getDefault() {
(...skipping 19 matching lines...) Expand all
74 void set name(String v) { $_setString(2, 3, v); } 74 void set name(String v) { $_setString(2, 3, v); }
75 bool hasName() => $_has(2, 3); 75 bool hasName() => $_has(2, 3);
76 void clearName() => clearField(3); 76 void clearName() => clearField(3);
77 } 77 }
78 78
79 class _ReadonlyPhoneNumber extends PhoneNumber with ReadonlyMessageMixin {} 79 class _ReadonlyPhoneNumber extends PhoneNumber with ReadonlyMessageMixin {}
80 80
81 '''; 81 ''';
82 FileDescriptorProto fd = new FileDescriptorProto(); 82 FileDescriptorProto fd = new FileDescriptorProto();
83 EnumDescriptorProto ed = new EnumDescriptorProto() 83 EnumDescriptorProto ed = new EnumDescriptorProto()
84 ..name = 'PhoneType' 84 ..name = 'PhoneType'
85 ..value.addAll([ 85 ..value.addAll([
86 new EnumValueDescriptorProto() 86 new EnumValueDescriptorProto()
87 ..name = 'MOBILE' 87 ..name = 'MOBILE'
88 ..number = 0, 88 ..number = 0,
89 new EnumValueDescriptorProto() 89 new EnumValueDescriptorProto()
90 ..name = 'HOME' 90 ..name = 'HOME'
91 ..number = 1, 91 ..number = 1,
92 new EnumValueDescriptorProto() 92 new EnumValueDescriptorProto()
93 ..name = 'WORK' 93 ..name = 'WORK'
94 ..number = 2, 94 ..number = 2,
95 new EnumValueDescriptorProto() 95 new EnumValueDescriptorProto()
96 ..name = 'BUSINESS' 96 ..name = 'BUSINESS'
97 ..number = 2]); 97 ..number = 2
98 ]);
98 DescriptorProto md = new DescriptorProto() 99 DescriptorProto md = new DescriptorProto()
99 ..name = 'PhoneNumber' 100 ..name = 'PhoneNumber'
100 ..field.addAll([ 101 ..field.addAll([
101 // optional PhoneType type = 2 [default = HOME]; 102 // optional PhoneType type = 2 [default = HOME];
102 new FieldDescriptorProto() 103 new FieldDescriptorProto()
103 ..name = 'type' 104 ..name = 'type'
104 ..number = 2 105 ..number = 2
105 ..label = FieldDescriptorProto_Label.LABEL_OPTIONAL 106 ..label = FieldDescriptorProto_Label.LABEL_OPTIONAL
106 ..type = FieldDescriptorProto_Type.TYPE_ENUM 107 ..type = FieldDescriptorProto_Type.TYPE_ENUM
107 ..typeName = '.PhoneNumber.PhoneType', 108 ..typeName = '.PhoneNumber.PhoneType',
108 // required string number = 1; 109 // required string number = 1;
109 new FieldDescriptorProto() 110 new FieldDescriptorProto()
110 ..name = 'number' 111 ..name = 'number'
111 ..number = 1 112 ..number = 1
112 ..label = FieldDescriptorProto_Label.LABEL_REQUIRED 113 ..label = FieldDescriptorProto_Label.LABEL_REQUIRED
113 ..type = FieldDescriptorProto_Type.TYPE_STRING, 114 ..type = FieldDescriptorProto_Type.TYPE_STRING,
114 new FieldDescriptorProto() 115 new FieldDescriptorProto()
115 ..name = 'name' 116 ..name = 'name'
116 ..number = 3 117 ..number = 3
117 ..label = FieldDescriptorProto_Label.LABEL_OPTIONAL 118 ..label = FieldDescriptorProto_Label.LABEL_OPTIONAL
118 ..type = FieldDescriptorProto_Type.TYPE_STRING 119 ..type = FieldDescriptorProto_Type.TYPE_STRING
119 ..defaultValue = r'$' 120 ..defaultValue = r'$'
120 ]) 121 ])
121 ..enumType.add(ed); 122 ..enumType.add(ed);
122 var options = parseGenerationOptions( 123 var options = parseGenerationOptions(
123 new CodeGeneratorRequest(), new CodeGeneratorResponse()); 124 new CodeGeneratorRequest(), new CodeGeneratorResponse());
124 125
125 FileGenerator fg = new FileGenerator(fd); 126 FileGenerator fg = new FileGenerator(fd);
126 MessageGenerator mg = new MessageGenerator(md, fg, null); 127 MessageGenerator mg = new MessageGenerator(md, fg, null);
127 128
128 var ctx = new GenerationContext(options); 129 var ctx = new GenerationContext(options);
129 mg.register(ctx); 130 mg.register(ctx);
130 mg.resolve(ctx); 131 mg.resolve(ctx);
131 132
132 var writer = new IndentingWriter(); 133 var writer = new IndentingWriter();
133 mg.generate(writer); 134 mg.generate(writer);
134 expect(writer.toString(), expected); 135 expect(writer.toString(), expected);
135 }); 136 });
136 } 137 }
OLDNEW
« no previous file with comments | « test/generated_message_test.dart ('k') | test/message_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698