| Index: test/message_test.dart
|
| diff --git a/test/message_test.dart b/test/message_test.dart
|
| index 62af81c3e0c1a018d3530e0113431fb94ef12ec3..4a541d77905daf4d8a0e67cd91bba57ceefbb121 100644
|
| --- a/test/message_test.dart
|
| +++ b/test/message_test.dart
|
| @@ -7,19 +7,19 @@ library message_test;
|
|
|
| import 'package:test/test.dart' show test, expect, predicate, throwsA;
|
|
|
| -import 'mock_util.dart' show MockMessage;
|
| +import 'mock_util.dart' show MockMessage, mockInfo;
|
|
|
| class Rec extends MockMessage {
|
| - get className => "Rec";
|
| - Rec create() => new Rec();
|
| + get info_ => _info;
|
| + static final _info = mockInfo("Rec", () => new Rec());
|
| }
|
|
|
| -throwsError(Type expectedType, String expectedMessage) => throwsA(
|
| - predicate((x) {
|
| - expect(x.runtimeType, expectedType);
|
| - expect(x.message, expectedMessage);
|
| - return true;
|
| -}));
|
| +throwsError(Type expectedType, String expectedMessage) =>
|
| + throwsA(predicate((x) {
|
| + expect(x.runtimeType, expectedType);
|
| + expect(x.message, expectedMessage);
|
| + return true;
|
| + }));
|
|
|
| main() {
|
| test('getField with invalid tag throws exception', () {
|
| @@ -35,4 +35,26 @@ main() {
|
| r.getDefaultForField(123);
|
| }, throwsError(ArgumentError, "tag 123 not defined in Rec"));
|
| });
|
| +
|
| + test('operator== and hashCode work for a simple record', () {
|
| + var a = new Rec();
|
| + expect(a == a, true);
|
| +
|
| + var b = new Rec();
|
| + expect(a.info_ == b.info_, true, reason: "BuilderInfo should be the same");
|
| + expect(a == b, true);
|
| + expect(a.hashCode, b.hashCode);
|
| +
|
| + a.val = 123;
|
| + expect(a == b, false);
|
| + b.val = 123;
|
| + expect(a == b, true);
|
| + expect(a.hashCode, b.hashCode);
|
| +
|
| + a.child = new Rec();
|
| + expect(a == b, false);
|
| + b.child = new Rec();
|
| + expect(a == b, true);
|
| + expect(a.hashCode, b.hashCode);
|
| + });
|
| }
|
|
|