Skip to content

Commit

Permalink
dartfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Aug 19, 2016
1 parent 3ccd35e commit f75bd2a
Show file tree
Hide file tree
Showing 9 changed files with 302 additions and 323 deletions.
1 change: 1 addition & 0 deletions lib/file_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class FileGenerator extends ProtobufContainer {
}
return findMixin(name);
}

for (var mixin in dartMixins.values) {
resolveMixin(mixin.name);
}
Expand Down
30 changes: 15 additions & 15 deletions test/hash_code_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ void main() {

test('testHashCodeOptionalEnum', () {
var m1 = new TestAllTypes()
..optionalNestedEnum = TestAllTypes_NestedEnum.BAR;
..optionalNestedEnum = TestAllTypes_NestedEnum.BAR;
var m2 = new TestAllTypes()
..optionalNestedEnum = TestAllTypes_NestedEnum.BAR;
..optionalNestedEnum = TestAllTypes_NestedEnum.BAR;
expect(m1.hashCode, m2.hashCode);

m1.optionalNestedEnum = TestAllTypes_NestedEnum.BAZ;
Expand Down Expand Up @@ -139,15 +139,15 @@ void main() {

test('testHashCodeCombined', () {
var m1 = new TestAllTypes()
..optionalInt32 = 42
..optionalInt64 = new Int64(42)
..optionalString = "Dart"
..optionalNestedEnum = TestAllTypes_NestedEnum.BAR;
var m2 = new TestAllTypes()
..optionalInt32 = 42
..optionalInt64 = new Int64(42)
..optionalString = "Dart"
..optionalNestedEnum = TestAllTypes_NestedEnum.BAR;
..optionalInt32 = 42
..optionalInt64 = new Int64(42)
..optionalString = "Dart"
..optionalNestedEnum = TestAllTypes_NestedEnum.BAR;
var m2 = new TestAllTypes()
..optionalInt32 = 42
..optionalInt64 = new Int64(42)
..optionalString = "Dart"
..optionalNestedEnum = TestAllTypes_NestedEnum.BAR;
expect(m1.hashCode, m2.hashCode);

m1.repeatedInt32..add(42)..add(43);
Expand All @@ -157,11 +157,11 @@ void main() {
m1.repeatedString..add("Dart")..add("JavaScript");
m2.repeatedString..add("Dart")..add("JavaScript");
m1.repeatedNestedEnum
..add(TestAllTypes_NestedEnum.BAR)
..add(TestAllTypes_NestedEnum.BAZ);
..add(TestAllTypes_NestedEnum.BAR)
..add(TestAllTypes_NestedEnum.BAZ);
m2.repeatedNestedEnum
..add(TestAllTypes_NestedEnum.BAR)
..add(TestAllTypes_NestedEnum.BAZ);
..add(TestAllTypes_NestedEnum.BAR)
..add(TestAllTypes_NestedEnum.BAZ);
expect(m1.hashCode, m2.hashCode);

m1.unknownFields.mergeVarintField(12345, new Int64(123));
Expand Down
4 changes: 3 additions & 1 deletion test/indenting_writer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ void main() {
out.println('second;');
});

expect(out.toString(), '''
expect(
out.toString(),
'''
class test {
first;
Expand Down
30 changes: 15 additions & 15 deletions test/json_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,42 +44,42 @@ void main() {

// Test empty list.
expect(getAllSet()..repeatedBool.clear(),
expectedJson('"43":[true,false],', ''));
expectedJson('"43":[true,false],', ''));

// Test negative number.
expect(getAllSet()..optionalInt32 = -1234567,
expectedJson(':101,', ':-1234567,'));
expectedJson(':101,', ':-1234567,'));

// 64-bit numbers outside 53-bit range are quoted.
expect(getAllSet()..optionalInt64 = make64(0, 0x200000),
expectedJson(':102,', ':9007199254740992,'));
expectedJson(':102,', ':9007199254740992,'));
expect(getAllSet()..optionalInt64 = make64(1, 0x200000),
expectedJson(':102,', ':"9007199254740993",'));
expectedJson(':102,', ':"9007199254740993",'));
expect(getAllSet()..optionalInt64 = -make64(0, 0x200000),
expectedJson(':102,', ':-9007199254740992,'));
expectedJson(':102,', ':-9007199254740992,'));
expect(getAllSet()..optionalInt64 = -make64(1, 0x200000),
expectedJson(':102,', ':"-9007199254740993",'));
expectedJson(':102,', ':"-9007199254740993",'));

// Quotes, backslashes, and control characters in strings are quoted.
expect(getAllSet()..optionalString = 'a\u0000b\u0001cd\\e\"fg',
expectedJson(':"115",', ':"a\\u0000b\\u0001cd\\\\e\\"fg",'));
expectedJson(':"115",', ':"a\\u0000b\\u0001cd\\\\e\\"fg",'));
});

test('testBase64Encode', () {
expect(getAllSet()..optionalBytes = 'Hello, world'.codeUnits,
expectedJson(':"MTE2",', ':"SGVsbG8sIHdvcmxk",'));
expectedJson(':"MTE2",', ':"SGVsbG8sIHdvcmxk",'));

expect(getAllSet()..optionalBytes = 'Hello, world!'.codeUnits,
expectedJson(':"MTE2",', ':"SGVsbG8sIHdvcmxkIQ==",'));
expectedJson(':"MTE2",', ':"SGVsbG8sIHdvcmxkIQ==",'));

expect(getAllSet()..optionalBytes = 'Hello, world!!'.codeUnits,
expectedJson(':"MTE2",', ':"SGVsbG8sIHdvcmxkISE=",'));
expectedJson(':"MTE2",', ':"SGVsbG8sIHdvcmxkISE=",'));

// An empty list should not appear in the output.
expect(getAllSet()..optionalBytes = [], expectedJson('"15":"MTE2",', ''));

expect(getAllSet()..optionalBytes = 'a'.codeUnits,
expectedJson(':"MTE2",', ':"YQ==",'));
expectedJson(':"MTE2",', ':"YQ==",'));
});

test('testBase64Decode', () {
Expand All @@ -91,11 +91,11 @@ void main() {

expect(optionalBytes(':"MTE2",', ':"SGVsbG8sIHdvcmxk",'), 'Hello, world');

expect(optionalBytes(':"MTE2",', ':"SGVsbG8sIHdvcmxkIQ==",'),
'Hello, world!');
expect(
optionalBytes(':"MTE2",', ':"SGVsbG8sIHdvcmxkIQ==",'), 'Hello, world!');

expect(optionalBytes(':"MTE2",', ':"SGVsbG8sIHdvcmxkISE=",'),
'Hello, world!!');
'Hello, world!!');

// Remove optionalBytes tag, reads back as empty list, hence empty string.
expect(optionalBytes('"15":"MTE2",', ''), isEmpty);
Expand All @@ -117,6 +117,6 @@ void main() {
test('testExtensionsParse', () {
ExtensionRegistry registry = getExtensionRegistry();
expect(new TestAllExtensions.fromJson(TEST_ALL_TYPES_JSON, registry),
getAllExtensionsSet());
getAllExtensionsSet());
});
}
2 changes: 1 addition & 1 deletion test/protoc_options_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void main() {
});

test('testInvalidGeneratorOptions', () {
checkInvalid(String parameter) {
checkInvalid(String parameter) {
var request = new CodeGeneratorRequest();
if (parameter != null) request.parameter = parameter;
var response = new CodeGeneratorResponse();
Expand Down
1 change: 1 addition & 0 deletions test/service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void main() {
var descriptor = new DescriptorProto()..mergeFromJsonMap(json);
return descriptor.name;
}

expect(readMessageName('.SearchRequest'), "SearchRequest");
expect(readMessageName('.service2.SearchRequest'), "SearchRequest");
expect(readMessageName('.service3.SearchResult'), "SearchResult");
Expand Down
Loading

0 comments on commit f75bd2a

Please sign in to comment.