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

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

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

Powered by Google App Engine
This is Rietveld 408576698