Skip to content

Commit

Permalink
Merge pull request google#60 from dart-lang/tweaks
Browse files Browse the repository at this point in the history
Tweaks
  • Loading branch information
jakobr-google authored Jan 25, 2017
2 parents 5f24f72 + f75bd2a commit d5b3171
Show file tree
Hide file tree
Showing 11 changed files with 304 additions and 325 deletions.
2 changes: 1 addition & 1 deletion benchmark/lib/suites/json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import '../benchmarks/string_json.dart';
import '../benchmarks/repeated_string_json.dart';
import '../generated/benchmark.pb.dart' show Suite;

final jsonSuite = () {
final Suite jsonSuite = () {
var suite = new Suite();
suite.requests.addAll([
_int32(1, 100),
Expand Down
2 changes: 1 addition & 1 deletion benchmark/lib/suites/props.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../benchmarks/set_strings.dart';
import '../benchmarks/has_strings.dart';
import '../generated/benchmark.pb.dart' show Suite;

final propsSuite = () {
final Suite propsSuite = () {
var suite = new Suite();
suite.requests.addAll([
_getStrings(10, null),
Expand Down
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 d5b3171

Please sign in to comment.