| Index: test/pretty_print_test.dart
|
| diff --git a/test/pretty_print_test.dart b/test/pretty_print_test.dart
|
| index 1e3704ff064d16cb7b4e7f0b07e0d00cc60cd752..c1e0a59bb6ce2ec065fd845e887dd655140341b0 100644
|
| --- a/test/pretty_print_test.dart
|
| +++ b/test/pretty_print_test.dart
|
| @@ -4,10 +4,26 @@
|
|
|
| library matcher.pretty_print_test;
|
|
|
| +import 'dart:collection';
|
| +
|
| import 'package:matcher/matcher.dart';
|
| import 'package:matcher/src/pretty_print.dart';
|
| import 'package:unittest/unittest.dart' show group, test, expect;
|
|
|
| +class DefaultToString {}
|
| +
|
| +class CustomToString {
|
| + String toString() => "string representation";
|
| +}
|
| +
|
| +class _PrivateName {
|
| + String toString() => "string representation";
|
| +}
|
| +
|
| +class _PrivateNameIterable extends IterableMixin {
|
| + Iterator get iterator => [1, 2, 3].iterator;
|
| +}
|
| +
|
| void main() {
|
| test('with primitive objects', () {
|
| expect(prettyPrint(12), equals('<12>'));
|
| @@ -191,4 +207,31 @@ void main() {
|
| equals("{'0': 1, '2': 3, ...}"));
|
| });
|
| });
|
| + group('with an object', () {
|
| + test('with a default [toString]', () {
|
| + expect(prettyPrint(new DefaultToString()),
|
| + equals("<Instance of 'DefaultToString'>"));
|
| + });
|
| +
|
| + test('with a custom [toString]', () {
|
| + expect(prettyPrint(new CustomToString()),
|
| + equals('CustomToString:<string representation>'));
|
| + });
|
| +
|
| + test('with a custom [toString] and a private name', () {
|
| + expect(
|
| + prettyPrint(new _PrivateName()), equals('?:<string representation>'));
|
| + });
|
| + });
|
| +
|
| + group('with an iterable', () {
|
| + test("that's not a list", () {
|
| + expect(prettyPrint([1, 2, 3, 4].map((n) => n * 2)),
|
| + equals("MappedListIterable:[2, 4, 6, 8]"));
|
| + });
|
| +
|
| + test("that's not a list and has a private name", () {
|
| + expect(prettyPrint(new _PrivateNameIterable()), equals("?:[1, 2, 3]"));
|
| + });
|
| + });
|
| }
|
|
|