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

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

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