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

Side by Side Diff: test/matchers_minified_test.dart

Issue 867133002: pkg/matcher: refactor with unittest v0.12 work (Closed) Base URL: https://github.com/dart-lang/matcher.git@master
Patch Set: cl nits Created 5 years, 10 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 matcher.minified_test;
10
11 import 'package:matcher/matcher.dart';
12 import 'package:unittest/unittest.dart' show test, group;
13
14 import 'test_common.dart';
15 import 'test_utils.dart';
16
17 // A regexp fragment matching a minified name.
18 const _MINIFIED_NAME = r"[A-Za-z0-9]{1,3}";
19
20 void main() {
21 initUtils();
22
23 group('Core matchers', () {
24 test('throwsFormatException', () {
25 shouldPass(() {
26 throw new FormatException('');
27 }, throwsFormatException);
28 shouldFail(() {
29 throw new Exception();
30 }, throwsFormatException, matches(r"Expected: throws FormatException +"
31 r"Actual: <Closure(: \(\) => dynamic)?> +"
32 r"Which: threw " + _MINIFIED_NAME + r":<Exception>"));
33 });
34
35 test('throwsArgumentError', () {
36 shouldPass(() {
37 throw new ArgumentError('');
38 }, throwsArgumentError);
39 shouldFail(() {
40 throw new Exception();
41 }, throwsArgumentError, matches(r"Expected: throws ArgumentError +"
42 r"Actual: <Closure(: \(\) => dynamic)?> +"
43 r"Which: threw " + _MINIFIED_NAME + r":<Exception>"));
44 });
45
46 test('throwsRangeError', () {
47 shouldPass(() {
48 throw new RangeError(0);
49 }, throwsRangeError);
50 shouldFail(() {
51 throw new Exception();
52 }, throwsRangeError, matches(r"Expected: throws RangeError +"
53 r"Actual: <Closure(: \(\) => dynamic)?> +"
54 r"Which: threw " + _MINIFIED_NAME + r":<Exception>"));
55 });
56
57 test('throwsNoSuchMethodError', () {
58 shouldPass(() {
59 throw new NoSuchMethodError(null, const Symbol(''), null, null);
60 }, throwsNoSuchMethodError);
61 shouldFail(() {
62 throw new Exception();
63 }, throwsNoSuchMethodError, matches(
64 r"Expected: throws NoSuchMethodError +"
65 r"Actual: <Closure(: \(\) => dynamic)?> +"
66 r"Which: threw " + _MINIFIED_NAME + r":<Exception>"));
67 });
68
69 test('throwsUnimplementedError', () {
70 shouldPass(() {
71 throw new UnimplementedError('');
72 }, throwsUnimplementedError);
73 shouldFail(() {
74 throw new Exception();
75 }, throwsUnimplementedError, matches(
76 r"Expected: throws UnimplementedError +"
77 r"Actual: <Closure(: \(\) => dynamic)?> +"
78 r"Which: threw " + _MINIFIED_NAME + r":<Exception>"));
79 });
80
81 test('throwsUnsupportedError', () {
82 shouldPass(() {
83 throw new UnsupportedError('');
84 }, throwsUnsupportedError);
85 shouldFail(() {
86 throw new Exception();
87 }, throwsUnsupportedError, matches(r"Expected: throws UnsupportedError +"
88 r"Actual: <Closure(: \(\) => dynamic)?> +"
89 r"Which: threw " + _MINIFIED_NAME + r":<Exception>"));
90 });
91
92 test('throwsStateError', () {
93 shouldPass(() {
94 throw new StateError('');
95 }, throwsStateError);
96 shouldFail(() {
97 throw new Exception();
98 }, throwsStateError, matches(r"Expected: throws StateError +"
99 r"Actual: <Closure(: \(\) => dynamic)?> +"
100 r"Which: threw " + _MINIFIED_NAME + r":<Exception>"));
101 });
102 });
103
104 group('Iterable Matchers', () {
105 test('isEmpty', () {
106 var d = new SimpleIterable(0);
107 var e = new SimpleIterable(1);
108 shouldPass(d, isEmpty);
109 shouldFail(e, isEmpty,
110 matches(r"Expected: empty +Actual: " + _MINIFIED_NAME + r":\[1\]"));
111 });
112
113 test('isNotEmpty', () {
114 var d = new SimpleIterable(0);
115 var e = new SimpleIterable(1);
116 shouldPass(e, isNotEmpty);
117 shouldFail(d, isNotEmpty, matches(
118 r"Expected: non-empty +Actual: " + _MINIFIED_NAME + r":\[\]"));
119 });
120
121 test('contains', () {
122 var d = new SimpleIterable(3);
123 shouldPass(d, contains(2));
124 shouldFail(d, contains(5), matches(r"Expected: contains <5> +"
125 r"Actual: " + _MINIFIED_NAME + r":\[3, 2, 1\]"));
126 });
127 });
128
129 group('Feature Matchers', () {
130 test("Feature Matcher", () {
131 var w = new Widget();
132 w.price = 10;
133 shouldPass(w, new HasPrice(10));
134 shouldPass(w, new HasPrice(greaterThan(0)));
135 shouldFail(w, new HasPrice(greaterThan(10)), matches(
136 r"Expected: Widget with a price that is a value greater than "
137 r"<10> +"
138 r"Actual: <Instance of '" + _MINIFIED_NAME + r"'> +"
139 r"Which: has price with value <10> which is not "
140 r"a value greater than <10>"));
141 });
142 });
143 }
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