Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // This file is for pretty-print tests that rely on the names of various Dart | 5 // This file is for pretty-print tests that rely on the names of various Dart |
| 6 // types. These tests will fail when run in minified dart2js, since the names | 6 // types. These tests will fail when run in minified dart2js, since the names |
| 7 // will be mangled. A version of this file that works in minified dart2js is in | 7 // will be mangled. A version of this file that works in minified dart2js is in |
| 8 // pretty_print_minified_test.dart. | 8 // pretty_print_minified_test.dart. |
| 9 | 9 |
| 10 library matcher.pritn_unminified; | |
|
blois
2014/03/24 22:55:21
typo- print.
and append _test?
kevmoo
2014/03/25 00:12:46
Done.
| |
| 11 | |
| 10 import 'dart:collection'; | 12 import 'dart:collection'; |
| 11 import 'package:unittest/unittest.dart' as ut; | |
| 12 | 13 |
| 13 import 'package:matcher/matcher.dart'; | 14 import 'package:matcher/matcher.dart'; |
| 14 import 'package:matcher/src/pretty_print.dart'; | 15 import 'package:matcher/src/pretty_print.dart'; |
| 16 import 'package:unittest/unittest.dart' show test, group; | |
| 15 | 17 |
| 16 class DefaultToString {} | 18 class DefaultToString {} |
| 17 | 19 |
| 18 class CustomToString { | 20 class CustomToString { |
| 19 String toString() => "string representation"; | 21 String toString() => "string representation"; |
| 20 } | 22 } |
| 21 | 23 |
| 22 class _PrivateName { | 24 class _PrivateName { |
| 23 String toString() => "string representation"; | 25 String toString() => "string representation"; |
| 24 } | 26 } |
| 25 | 27 |
| 26 class _PrivateNameIterable extends IterableMixin { | 28 class _PrivateNameIterable extends IterableMixin { |
| 27 Iterator get iterator => [1, 2, 3].iterator; | 29 Iterator get iterator => [1, 2, 3].iterator; |
| 28 } | 30 } |
| 29 | 31 |
| 30 void main() { | 32 void main() { |
| 31 ut.group('with an object', () { | 33 group('with an object', () { |
| 32 ut.test('with a default [toString]', () { | 34 test('with a default [toString]', () { |
| 33 expect(prettyPrint(new DefaultToString()), | 35 expect(prettyPrint(new DefaultToString()), |
| 34 equals("<Instance of 'DefaultToString'>")); | 36 equals("<Instance of 'DefaultToString'>")); |
| 35 }); | 37 }); |
| 36 | 38 |
| 37 ut.test('with a custom [toString]', () { | 39 test('with a custom [toString]', () { |
| 38 expect(prettyPrint(new CustomToString()), | 40 expect(prettyPrint(new CustomToString()), |
| 39 equals('CustomToString:<string representation>')); | 41 equals('CustomToString:<string representation>')); |
| 40 }); | 42 }); |
| 41 | 43 |
| 42 ut.test('with a custom [toString] and a private name', () { | 44 test('with a custom [toString] and a private name', () { |
| 43 expect(prettyPrint(new _PrivateName()), | 45 expect(prettyPrint(new _PrivateName()), |
| 44 equals('?:<string representation>')); | 46 equals('?:<string representation>')); |
| 45 }); | 47 }); |
| 46 }); | 48 }); |
| 47 | 49 |
| 48 ut.group('with an iterable', () { | 50 group('with an iterable', () { |
| 49 ut.test("that's not a list", () { | 51 test("that's not a list", () { |
| 50 expect(prettyPrint([1, 2, 3, 4].map((n) => n * 2)), | 52 expect(prettyPrint([1, 2, 3, 4].map((n) => n * 2)), |
| 51 equals("MappedListIterable:[2, 4, 6, 8]")); | 53 equals("MappedListIterable:[2, 4, 6, 8]")); |
| 52 }); | 54 }); |
| 53 | 55 |
| 54 ut.test("that's not a list and has a private name", () { | 56 test("that's not a list and has a private name", () { |
| 55 expect(prettyPrint(new _PrivateNameIterable()), | 57 expect(prettyPrint(new _PrivateNameIterable()), |
| 56 equals("?:[1, 2, 3]")); | 58 equals("?:[1, 2, 3]")); |
| 57 }); | 59 }); |
| 58 }); | 60 }); |
| 59 } | 61 } |
| OLD | NEW |