| OLD | NEW |
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2015, 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 // Unit tests for PbMapMixin. | 6 // Unit tests for PbMapMixin. |
| 7 // There are more tests in the dart-protoc-plugin package. | 7 // There are more tests in the dart-protoc-plugin package. |
| 8 library map_mixin_test; | 8 library map_mixin_test; |
| 9 | 9 |
| 10 import 'dart:collection' show MapMixin; | 10 import 'dart:collection' show MapMixin; |
| 11 | 11 |
| 12 import 'package:protobuf/src/protobuf/mixins/map_mixin.dart'; | 12 import 'package:protobuf/src/protobuf/mixins/map_mixin.dart'; |
| 13 import 'package:test/test.dart' show test, expect, same, throws; | 13 import 'package:test/test.dart' show test, expect, same, throws; |
| 14 | 14 |
| 15 import 'mock_util.dart' show MockMessage, mockInfo; | 15 import 'mock_util.dart' show MockMessage, mockInfo; |
| 16 | 16 |
| 17 // A minimal protobuf implementation compatible with PbMapMixin. | 17 // A minimal protobuf implementation compatible with PbMapMixin. |
| 18 class Rec extends MockMessage with MapMixin, PbMapMixin { | 18 class Rec extends MockMessage with MapMixin<String, dynamic>, PbMapMixin { |
| 19 get info_ => _info; | 19 get info_ => _info; |
| 20 static final _info = mockInfo("Rec", () => new Rec()); | 20 static final _info = mockInfo("Rec", () => new Rec()); |
| 21 | 21 |
| 22 @override | 22 @override |
| 23 String toString() => "Rec(${val}, \"${str}\")"; | 23 String toString() => "Rec(${val}, \"${str}\")"; |
| 24 } | 24 } |
| 25 | 25 |
| 26 main() { | 26 main() { |
| 27 test('PbMapMixin methods return default field values', () { | 27 test('PbMapMixin methods return default field values', () { |
| 28 var r = new Rec(); | 28 var r = new Rec(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 }); | 97 }); |
| 98 | 98 |
| 99 test("reading protobuf values shouldn't change equality", () { | 99 test("reading protobuf values shouldn't change equality", () { |
| 100 var a = new Rec(); | 100 var a = new Rec(); |
| 101 var b = new Rec(); | 101 var b = new Rec(); |
| 102 expect(a == b, true); | 102 expect(a == b, true); |
| 103 new Map.from(a); | 103 new Map.from(a); |
| 104 expect(a == b, true); | 104 expect(a == b, true); |
| 105 }); | 105 }); |
| 106 } | 106 } |
| OLD | NEW |