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

Side by Side Diff: pkg/unittest/test/matchers_unminified_test.dart

Issue 210413002: pkg/unittest: using matcher and mock from packages (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: releasing v0.10.1 Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « pkg/unittest/test/matchers_test.dart ('k') | pkg/unittest/test/mirror_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 import 'package:unittest/unittest.dart';
11
12 import 'test_common.dart';
13 import 'test_utils.dart';
14
15 void main() {
16 initUtils();
17
18 group('Core matchers', () {
19 test('throwsFormatException', () {
20 shouldPass(() { throw new FormatException(''); },
21 throwsFormatException);
22 shouldFail(() { throw new Exception(); },
23 throwsFormatException,
24 matches(
25 r"Expected: throws FormatException +"
26 r"Actual: <Closure(: \(\) => dynamic)?> +"
27 r"Which: threw \?:<Exception>"));
28
29 });
30
31 test('throwsArgumentError', () {
32 shouldPass(() { throw new ArgumentError(''); },
33 throwsArgumentError);
34 shouldFail(() { throw new Exception(); },
35 throwsArgumentError,
36 matches(
37 r"Expected: throws ArgumentError +"
38 r"Actual: <Closure(: \(\) => dynamic)?> +"
39 r"Which: threw \?:<Exception>"));
40 });
41
42 test('throwsRangeError', () {
43 shouldPass(() { throw new RangeError(0); },
44 throwsRangeError);
45 shouldFail(() { throw new Exception(); },
46 throwsRangeError,
47 matches(
48 r"Expected: throws RangeError +"
49 r"Actual: <Closure(: \(\) => dynamic)?> +"
50 r"Which: threw \?:<Exception>"));
51 });
52
53 test('throwsNoSuchMethodError', () {
54 shouldPass(() {
55 throw new NoSuchMethodError(null, const Symbol(''), null, null);
56 }, throwsNoSuchMethodError);
57 shouldFail(() { throw new Exception(); },
58 throwsNoSuchMethodError,
59 matches(
60 r"Expected: throws NoSuchMethodError +"
61 r"Actual: <Closure(: \(\) => dynamic)?> +"
62 r"Which: threw \?:<Exception>"));
63 });
64
65 test('throwsUnimplementedError', () {
66 shouldPass(() { throw new UnimplementedError(''); },
67 throwsUnimplementedError);
68 shouldFail(() { throw new Exception(); },
69 throwsUnimplementedError,
70 matches(
71 r"Expected: throws UnimplementedError +"
72 r"Actual: <Closure(: \(\) => dynamic)?> +"
73 r"Which: threw \?:<Exception>"));
74 });
75
76 test('throwsUnsupportedError', () {
77 shouldPass(() { throw new UnsupportedError(''); },
78 throwsUnsupportedError);
79 shouldFail(() { throw new Exception(); },
80 throwsUnsupportedError,
81 matches(
82 r"Expected: throws UnsupportedError +"
83 r"Actual: <Closure(: \(\) => dynamic)?> +"
84 r"Which: threw \?:<Exception>"));
85 });
86
87 test('throwsStateError', () {
88 shouldPass(() { throw new StateError(''); },
89 throwsStateError);
90 shouldFail(() { throw new Exception(); },
91 throwsStateError,
92 matches(
93 r"Expected: throws StateError +"
94 r"Actual: <Closure(: \(\) => dynamic)?> +"
95 r"Which: threw \?:<Exception>"));
96 });
97 });
98
99 group('Iterable Matchers', () {
100 test('isEmpty', () {
101 var d = new SimpleIterable(0);
102 var e = new SimpleIterable(1);
103 shouldPass(d, isEmpty);
104 shouldFail(e, isEmpty, "Expected: empty "
105 "Actual: SimpleIterable:[1]");
106 });
107
108 test('contains', () {
109 var d = new SimpleIterable(3);
110 shouldPass(d, contains(2));
111 shouldFail(d, contains(5),
112 "Expected: contains <5> "
113 "Actual: SimpleIterable:[3, 2, 1]");
114 });
115 });
116
117 group('Feature Matchers', () {
118 test("Feature Matcher", () {
119 var w = new Widget();
120 w.price = 10;
121 shouldPass(w, new HasPrice(10));
122 shouldPass(w, new HasPrice(greaterThan(0)));
123 shouldFail(w, new HasPrice(greaterThan(10)),
124 "Expected: Widget with a price that is a value greater than <10> "
125 "Actual: <Instance of 'Widget'> "
126 "Which: has price with value <10> which is not "
127 "a value greater than <10>");
128 });
129 });
130 }
OLDNEW
« no previous file with comments | « pkg/unittest/test/matchers_test.dart ('k') | pkg/unittest/test/mirror_matchers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698