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

Side by Side Diff: test/matchers_unminified_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/matchers_minified_test.dart ('k') | test/numeric_matchers_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 will fail when run in minified dart2js, since the names will be
7 // mangled. A version of this file that works in minified dart2js is in
8 // matchers_minified_test.dart.
9
10 library unittest.matcher.unminified_test;
11
12 import 'package:unittest/unittest.dart';
13
14 import 'test_common.dart';
15 import 'test_utils.dart';
16
17 void main() {
18 initUtils();
19
20 group('Core matchers', () {
21 test('throwsFormatException', () {
22 shouldPass(() {
23 throw new FormatException('');
24 }, throwsFormatException);
25 shouldFail(() {
26 throw new Exception();
27 }, throwsFormatException, matches(r"Expected: throws FormatException +"
28 r"Actual: <Closure(: \(\) => dynamic)?> +"
29 r"Which: threw \?:<Exception>"));
30 });
31
32 test('throwsArgumentError', () {
33 shouldPass(() {
34 throw new ArgumentError('');
35 }, throwsArgumentError);
36 shouldFail(() {
37 throw new Exception();
38 }, throwsArgumentError, matches(r"Expected: throws ArgumentError +"
39 r"Actual: <Closure(: \(\) => dynamic)?> +"
40 r"Which: threw \?:<Exception>"));
41 });
42
43 test('throwsRangeError', () {
44 shouldPass(() {
45 throw new RangeError(0);
46 }, throwsRangeError);
47 shouldFail(() {
48 throw new Exception();
49 }, throwsRangeError, matches(r"Expected: throws RangeError +"
50 r"Actual: <Closure(: \(\) => dynamic)?> +"
51 r"Which: threw \?:<Exception>"));
52 });
53
54 test('throwsNoSuchMethodError', () {
55 shouldPass(() {
56 throw new NoSuchMethodError(null, const Symbol(''), null, null);
57 }, throwsNoSuchMethodError);
58 shouldFail(() {
59 throw new Exception();
60 }, throwsNoSuchMethodError, matches(
61 r"Expected: throws NoSuchMethodError +"
62 r"Actual: <Closure(: \(\) => dynamic)?> +"
63 r"Which: threw \?:<Exception>"));
64 });
65
66 test('throwsUnimplementedError', () {
67 shouldPass(() {
68 throw new UnimplementedError('');
69 }, throwsUnimplementedError);
70 shouldFail(() {
71 throw new Exception();
72 }, throwsUnimplementedError, matches(
73 r"Expected: throws UnimplementedError +"
74 r"Actual: <Closure(: \(\) => dynamic)?> +"
75 r"Which: threw \?:<Exception>"));
76 });
77
78 test('throwsUnsupportedError', () {
79 shouldPass(() {
80 throw new UnsupportedError('');
81 }, throwsUnsupportedError);
82 shouldFail(() {
83 throw new Exception();
84 }, throwsUnsupportedError, matches(r"Expected: throws UnsupportedError +"
85 r"Actual: <Closure(: \(\) => dynamic)?> +"
86 r"Which: threw \?:<Exception>"));
87 });
88
89 test('throwsStateError', () {
90 shouldPass(() {
91 throw new StateError('');
92 }, throwsStateError);
93 shouldFail(() {
94 throw new Exception();
95 }, throwsStateError, matches(r"Expected: throws StateError +"
96 r"Actual: <Closure(: \(\) => dynamic)?> +"
97 r"Which: threw \?:<Exception>"));
98 });
99 });
100
101 group('Iterable Matchers', () {
102 test('isEmpty', () {
103 var d = new SimpleIterable(0);
104 var e = new SimpleIterable(1);
105 shouldPass(d, isEmpty);
106 shouldFail(e, isEmpty, "Expected: empty "
107 "Actual: SimpleIterable:[1]");
108 });
109
110 test('isNotEmpty', () {
111 var d = new SimpleIterable(0);
112 var e = new SimpleIterable(1);
113 shouldPass(e, isNotEmpty);
114 shouldFail(d, isNotEmpty, "Expected: non-empty "
115 "Actual: SimpleIterable:[]");
116 });
117
118 test('contains', () {
119 var d = new SimpleIterable(3);
120 shouldPass(d, contains(2));
121 shouldFail(d, contains(5), "Expected: contains <5> "
122 "Actual: SimpleIterable:[3, 2, 1]");
123 });
124 });
125
126 group('Feature Matchers', () {
127 test("Feature Matcher", () {
128 var w = new Widget();
129 w.price = 10;
130 shouldPass(w, new HasPrice(10));
131 shouldPass(w, new HasPrice(greaterThan(0)));
132 shouldFail(w, new HasPrice(greaterThan(10)),
133 "Expected: Widget with a price that is a value greater than <10> "
134 "Actual: <Instance of 'Widget'> "
135 "Which: has price with value <10> which is not "
136 "a value greater than <10>");
137 });
138 });
139 }
OLDNEW
« no previous file with comments | « test/matchers_minified_test.dart ('k') | test/numeric_matchers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698