| 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 normally fail when run in minified dart2js, since the | 6 // types. These tests normally fail when run in minified dart2js, since the |
| 7 // names will be mangled. This version of the file is modified to expect | 7 // names will be mangled. This version of the file is modified to expect |
| 8 // minified names. | 8 // minified names. |
| 9 | 9 |
| 10 library matcher.print_minified_test; |
| 11 |
| 10 import 'dart:collection'; | 12 import 'dart:collection'; |
| 11 | 13 |
| 12 import 'package:unittest/unittest.dart' as ut; | |
| 13 | |
| 14 import 'package:matcher/matcher.dart'; | 14 import 'package:matcher/matcher.dart'; |
| 15 import 'package:matcher/src/pretty_print.dart'; | 15 import 'package:matcher/src/pretty_print.dart'; |
| 16 import 'package:unittest/unittest.dart' show test, group; |
| 16 | 17 |
| 17 class DefaultToString {} | 18 class DefaultToString {} |
| 18 | 19 |
| 19 class CustomToString { | 20 class CustomToString { |
| 20 String toString() => "string representation"; | 21 String toString() => "string representation"; |
| 21 } | 22 } |
| 22 | 23 |
| 23 class _PrivateName { | 24 class _PrivateName { |
| 24 String toString() => "string representation"; | 25 String toString() => "string representation"; |
| 25 } | 26 } |
| 26 | 27 |
| 27 class _PrivateNameIterable extends IterableMixin { | 28 class _PrivateNameIterable extends IterableMixin { |
| 28 Iterator get iterator => [1, 2, 3].iterator; | 29 Iterator get iterator => [1, 2, 3].iterator; |
| 29 } | 30 } |
| 30 | 31 |
| 31 // A regexp fragment matching a minified name. | 32 // A regexp fragment matching a minified name. |
| 32 final _minifiedName = r"[A-Za-z0-9]{1,3}"; | 33 final _minifiedName = r"[A-Za-z0-9]{1,3}"; |
| 33 | 34 |
| 34 void main() { | 35 void main() { |
| 35 ut.group('with an object', () { | 36 group('with an object', () { |
| 36 ut.test('with a default [toString]', () { | 37 test('with a default [toString]', () { |
| 37 expect(prettyPrint(new DefaultToString()), | 38 expect(prettyPrint(new DefaultToString()), |
| 38 matches(r"<Instance of '" + _minifiedName + r"'>")); | 39 matches(r"<Instance of '" + _minifiedName + r"'>")); |
| 39 }); | 40 }); |
| 40 | 41 |
| 41 ut.test('with a custom [toString]', () { | 42 test('with a custom [toString]', () { |
| 42 expect(prettyPrint(new CustomToString()), | 43 expect(prettyPrint(new CustomToString()), |
| 43 matches(_minifiedName + r':<string representation>')); | 44 matches(_minifiedName + r':<string representation>')); |
| 44 }); | 45 }); |
| 45 | 46 |
| 46 ut.test('with a custom [toString] and a private name', () { | 47 test('with a custom [toString] and a private name', () { |
| 47 expect(prettyPrint(new _PrivateName()), | 48 expect(prettyPrint(new _PrivateName()), |
| 48 matches(_minifiedName + r':<string representation>')); | 49 matches(_minifiedName + r':<string representation>')); |
| 49 }); | 50 }); |
| 50 }); | 51 }); |
| 51 | 52 |
| 52 ut.group('with an iterable', () { | 53 group('with an iterable', () { |
| 53 ut.test("that's not a list", () { | 54 test("that's not a list", () { |
| 54 expect(prettyPrint([1, 2, 3, 4].map((n) => n * 2)), | 55 expect(prettyPrint([1, 2, 3, 4].map((n) => n * 2)), |
| 55 matches(_minifiedName + r":\[2, 4, 6, 8\]")); | 56 matches(_minifiedName + r":\[2, 4, 6, 8\]")); |
| 56 }); | 57 }); |
| 57 | 58 |
| 58 ut.test("that's not a list and has a private name", () { | 59 test("that's not a list and has a private name", () { |
| 59 expect(prettyPrint(new _PrivateNameIterable()), | 60 expect(prettyPrint(new _PrivateNameIterable()), |
| 60 matches(_minifiedName + r":\[1, 2, 3\]")); | 61 matches(_minifiedName + r":\[1, 2, 3\]")); |
| 61 }); | 62 }); |
| 62 }); | 63 }); |
| 63 } | 64 } |
| OLD | NEW |