| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:collection'; | 5 import 'dart:collection'; |
| 6 | 6 |
| 7 import 'package:unittest/src/pretty_print.dart'; | 7 import 'package:unittest/src/pretty_print.dart'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 class DefaultToString {} | 10 class DefaultToString {} |
| 11 | 11 |
| 12 class CustomToString { | 12 class CustomToString { |
| 13 String toString() => "string representation"; | 13 String toString() => "string representation"; |
| 14 } | 14 } |
| 15 | 15 |
| 16 class _PrivateName { | 16 class _PrivateName { |
| 17 String toString() => "string representation"; | 17 String toString() => "string representation"; |
| 18 } | 18 } |
| 19 | 19 |
| 20 class _PrivateNameIterable extends IterableMixin { | 20 class _PrivateNameIterable extends IterableMixin { |
| 21 Iterator get iterator => [1, 2, 3].iterator; | 21 Iterator get iterator => [1, 2, 3].iterator; |
| 22 } | 22 } |
| 23 | 23 |
| 24 void main() { | 24 void main() { |
| 25 test('with primitive objects', () { | 25 test('with primitive objects', () { |
| 26 expect(prettyPrint(12), equals('<12>')); | 26 expect(prettyPrint(12), equals('<12>')); |
| 27 expect(prettyPrint(12.13), equals('<12.13>')); | 27 expect(prettyPrint(12.13), equals('<12.13>')); |
| 28 expect(prettyPrint(true), equals('<true>')); | 28 expect(prettyPrint(true), equals('<true>')); |
| 29 expect(prettyPrint(null), equals('<null>')); | 29 expect(prettyPrint(null), equals('<null>')); |
| 30 expect(prettyPrint(() => 12), equals('<Closure: (dynamic) => dynamic>')); | 30 expect(prettyPrint(() => 12), |
| 31 matches(r'<Closure(: \(dynamic\) => dynamic)?>')); |
| 31 }); | 32 }); |
| 32 | 33 |
| 33 test('with an object with a default [toString]', () { | 34 test('with an object with a default [toString]', () { |
| 34 expect(prettyPrint(new DefaultToString()), | 35 expect(prettyPrint(new DefaultToString()), |
| 35 equals("<Instance of 'DefaultToString'>")); | 36 equals("<Instance of 'DefaultToString'>")); |
| 36 }); | 37 }); |
| 37 | 38 |
| 38 test('with an object with a custom [toString]', () { | 39 test('with an object with a custom [toString]', () { |
| 39 expect(prettyPrint(new CustomToString()), | 40 expect(prettyPrint(new CustomToString()), |
| 40 equals('CustomToString:<string representation>')); | 41 equals('CustomToString:<string representation>')); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 expect(prettyPrint({'0': 1, '2': 3, '4': 5, '6': 7}, maxItems: 4), | 213 expect(prettyPrint({'0': 1, '2': 3, '4': 5, '6': 7}, maxItems: 4), |
| 213 equals("{'0': 1, '2': 3, '4': 5, '6': 7}")); | 214 equals("{'0': 1, '2': 3, '4': 5, '6': 7}")); |
| 214 }); | 215 }); |
| 215 | 216 |
| 216 test("that's over maxItems", () { | 217 test("that's over maxItems", () { |
| 217 expect(prettyPrint({'0': 1, '2': 3, '4': 5, '6': 7}, maxItems: 3), | 218 expect(prettyPrint({'0': 1, '2': 3, '4': 5, '6': 7}, maxItems: 3), |
| 218 equals("{'0': 1, '2': 3, ...}")); | 219 equals("{'0': 1, '2': 3, ...}")); |
| 219 }); | 220 }); |
| 220 }); | 221 }); |
| 221 } | 222 } |
| OLD | NEW |