Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: test/matchers_minified_test.dart

Issue 1135653004: pkg/(unit)test: include a copy of old matcher (Closed) Base URL: https://github.com/dart-lang/test.git@stable
Patch Set: another nit Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/iterable_matchers_test.dart ('k') | test/matchers_unminified_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // This file is for matcher tests that rely on the names of various Dart types.
6 // These tests normally fail when run in minified dart2js, since the names will
7 // be mangled. This version of the file is modified to expect minified names.
8
9 library unittest.matcher.minified_test;
10
11 import 'package:unittest/unittest.dart';
12
13 import 'test_common.dart';
14 import 'test_utils.dart';
15
16 // A regexp fragment matching a minified name.
17 const _MINIFIED_NAME = r"[A-Za-z0-9]{1,3}";
18
19 void main() {
20 initUtils();
21
22 group('Core matchers', () {
23 test('throwsFormatException', () {
24 shouldPass(() {
25 throw new FormatException('');
26 }, throwsFormatException);
27 shouldFail(() {
28 throw new Exception();
29 }, throwsFormatException, matches(r"Expected: throws FormatException +"
30 r"Actual: <Closure(: \(\) => dynamic)?> +"
31 r"Which: threw " + _MINIFIED_NAME + r":<Exception>"));
32 });
33
34 test('throwsArgumentError', () {
35 shouldPass(() {
36 throw new ArgumentError('');
37 }, throwsArgumentError);
38 shouldFail(() {
39 throw new Exception();
40 }, throwsArgumentError, matches(r"Expected: throws ArgumentError +"
41 r"Actual: <Closure(: \(\) => dynamic)?> +"
42 r"Which: threw " + _MINIFIED_NAME + r":<Exception>"));
43 });
44
45 test('throwsRangeError', () {
46 shouldPass(() {
47 throw new RangeError(0);
48 }, throwsRangeError);
49 shouldFail(() {
50 throw new Exception();
51 }, throwsRangeError, matches(r"Expected: throws RangeError +"
52 r"Actual: <Closure(: \(\) => dynamic)?> +"
53 r"Which: threw " + _MINIFIED_NAME + r":<Exception>"));
54 });
55
56 test('throwsNoSuchMethodError', () {
57 shouldPass(() {
58 throw new NoSuchMethodError(null, const Symbol(''), null, null);
59 }, throwsNoSuchMethodError);
60 shouldFail(() {
61 throw new Exception();
62 }, throwsNoSuchMethodError, matches(
63 r"Expected: throws NoSuchMethodError +"
64 r"Actual: <Closure(: \(\) => dynamic)?> +"
65 r"Which: threw " + _MINIFIED_NAME + r":<Exception>"));
66 });
67
68 test('throwsUnimplementedError', () {
69 shouldPass(() {
70 throw new UnimplementedError('');
71 }, throwsUnimplementedError);
72 shouldFail(() {
73 throw new Exception();
74 }, throwsUnimplementedError, matches(
75 r"Expected: throws UnimplementedError +"
76 r"Actual: <Closure(: \(\) => dynamic)?> +"
77 r"Which: threw " + _MINIFIED_NAME + r":<Exception>"));
78 });
79
80 test('throwsUnsupportedError', () {
81 shouldPass(() {
82 throw new UnsupportedError('');
83 }, throwsUnsupportedError);
84 shouldFail(() {
85 throw new Exception();
86 }, throwsUnsupportedError, matches(r"Expected: throws UnsupportedError +"
87 r"Actual: <Closure(: \(\) => dynamic)?> +"
88 r"Which: threw " + _MINIFIED_NAME + r":<Exception>"));
89 });
90
91 test('throwsStateError', () {
92 shouldPass(() {
93 throw new StateError('');
94 }, throwsStateError);
95 shouldFail(() {
96 throw new Exception();
97 }, throwsStateError, matches(r"Expected: throws StateError +"
98 r"Actual: <Closure(: \(\) => dynamic)?> +"
99 r"Which: threw " + _MINIFIED_NAME + r":<Exception>"));
100 });
101 });
102
103 group('Iterable Matchers', () {
104 test('isEmpty', () {
105 var d = new SimpleIterable(0);
106 var e = new SimpleIterable(1);
107 shouldPass(d, isEmpty);
108 shouldFail(e, isEmpty,
109 matches(r"Expected: empty +Actual: " + _MINIFIED_NAME + r":\[1\]"));
110 });
111
112 test('isNotEmpty', () {
113 var d = new SimpleIterable(0);
114 var e = new SimpleIterable(1);
115 shouldPass(e, isNotEmpty);
116 shouldFail(d, isNotEmpty, matches(
117 r"Expected: non-empty +Actual: " + _MINIFIED_NAME + r":\[\]"));
118 });
119
120 test('contains', () {
121 var d = new SimpleIterable(3);
122 shouldPass(d, contains(2));
123 shouldFail(d, contains(5), matches(r"Expected: contains <5> +"
124 r"Actual: " + _MINIFIED_NAME + r":\[3, 2, 1\]"));
125 });
126 });
127
128 group('Feature Matchers', () {
129 test("Feature Matcher", () {
130 var w = new Widget();
131 w.price = 10;
132 shouldPass(w, new HasPrice(10));
133 shouldPass(w, new HasPrice(greaterThan(0)));
134 shouldFail(w, new HasPrice(greaterThan(10)), matches(
135 r"Expected: Widget with a price that is a value greater than "
136 r"<10> +"
137 r"Actual: <Instance of '" + _MINIFIED_NAME + r"'> +"
138 r"Which: has price with value <10> which is not "
139 r"a value greater than <10>"));
140 });
141 });
142 }
OLDNEW
« no previous file with comments | « test/iterable_matchers_test.dart ('k') | test/matchers_unminified_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698