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

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

Issue 15350003: Fix unittest for dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « pkg/unittest/lib/src/pretty_print.dart ('k') | pkg/unittest/test/pretty_print_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 library unittestTests; 5 library unittestTests;
6 import 'package:unittest/unittest.dart'; 6 import 'package:unittest/unittest.dart';
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 part 'test_utils.dart'; 9 part 'test_utils.dart';
10 10
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 test('anything', () { 120 test('anything', () {
121 var a = new Map(); 121 var a = new Map();
122 shouldPass(0, anything); 122 shouldPass(0, anything);
123 shouldPass(null, anything); 123 shouldPass(null, anything);
124 shouldPass(a, anything); 124 shouldPass(a, anything);
125 shouldFail(a, isNot(anything), "Expected: not anything But: was {}."); 125 shouldFail(a, isNot(anything), "Expected: not anything But: was {}.");
126 }); 126 });
127 127
128 test('throws', () { 128 test('throws', () {
129 shouldFail(doesNotThrow, throws, 129 shouldFail(doesNotThrow, throws,
130 "Expected: throws an exception But: no exception. " 130 matches(
131 "Actual: <Closure: (dynamic) => dynamic " 131 r"Expected: throws an exception +But: no exception\."
132 "from Function 'doesNotThrow': static.>"); 132 r"Actual: <Closure(: \(dynamic\) => dynamic "
133 r"from Function 'doesNotThrow': static\.)?>"));
133 shouldPass(doesThrow, throws); 134 shouldPass(doesThrow, throws);
134 shouldFail(true, throws, 135 shouldFail(true, throws,
135 "Expected: throws an exception But: not a Function or Future. " 136 "Expected: throws an exception But: not a Function or Future. "
136 "Actual: <true>"); 137 "Actual: <true>");
137 }); 138 });
138 139
139 test('throwsA', () { 140 test('throwsA', () {
140 shouldPass(doesThrow, throwsA(equals('X'))); 141 shouldPass(doesThrow, throwsA(equals('X')));
141 shouldFail(doesThrow, throwsA(equals('Y')), 142 shouldFail(doesThrow, throwsA(equals('Y')),
142 "Expected: throws an exception which matches 'Y' " 143 matches(
143 "But: exception 'X' does not match 'Y'. " 144 r"Expected: throws an exception which matches 'Y' +"
144 "Actual: <Closure: (dynamic) => dynamic " 145 r"But: exception 'X' does not match 'Y'\."
145 "from Function 'doesThrow': static.>"); 146 r"Actual: <Closure(: \(dynamic\) => dynamic "
147 r"from Function 'doesThrow': static\.)?>"));
146 }); 148 });
147 149
148 test('throwsFormatException', () { 150 test('throwsFormatException', () {
149 shouldPass(() { throw new FormatException(''); }, 151 shouldPass(() { throw new FormatException(''); },
150 throwsFormatException); 152 throwsFormatException);
151 shouldFail(() { throw new Exception(); }, 153 shouldFail(() { throw new Exception(); },
152 throwsFormatException, 154 throwsFormatException,
153 "Expected: throws an exception which matches FormatException " 155 matches(
154 "But: exception ?:<Exception> does not match FormatException. " 156 r"Expected: throws an exception which matches FormatException +"
155 "Actual: <Closure: (dynamic) => dynamic>"); 157 r"But: exception \?:<Exception> does not match FormatException\."
158 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
156 }); 159 });
157 160
158 test('throwsArgumentError', () { 161 test('throwsArgumentError', () {
159 shouldPass(() { throw new ArgumentError(''); }, 162 shouldPass(() { throw new ArgumentError(''); },
160 throwsArgumentError); 163 throwsArgumentError);
161 shouldFail(() { throw new Exception(); }, 164 shouldFail(() { throw new Exception(); },
162 throwsArgumentError, 165 throwsArgumentError,
163 "Expected: throws an exception which matches ArgumentError " 166 matches(
164 "But: exception ?:<Exception> does not match " 167 r"Expected: throws an exception which matches ArgumentError +"
165 "ArgumentError. " 168 r"But: exception \?:<Exception> does not match "
166 "Actual: <Closure: (dynamic) => dynamic>"); 169 r"ArgumentError\."
170 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
167 }); 171 });
168 172
169 test('throwsRangeError', () { 173 test('throwsRangeError', () {
170 shouldPass(() { throw new RangeError(0); }, 174 shouldPass(() { throw new RangeError(0); },
171 throwsRangeError); 175 throwsRangeError);
172 shouldFail(() { throw new Exception(); }, 176 shouldFail(() { throw new Exception(); },
173 throwsRangeError, 177 throwsRangeError,
174 "Expected: throws an exception which matches RangeError " 178 matches(
175 "But: exception ?:<Exception> does not match RangeError. " 179 r"Expected: throws an exception which matches RangeError +"
176 "Actual: <Closure: (dynamic) => dynamic>"); 180 r"But: exception \?:<Exception> does not match RangeError\."
181 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
177 }); 182 });
178 183
179 test('throwsNoSuchMethodError', () { 184 test('throwsNoSuchMethodError', () {
180 shouldPass(() { throw new NoSuchMethodError(null, '', null, null); }, 185 shouldPass(() { throw new NoSuchMethodError(null, '', null, null); },
181 throwsNoSuchMethodError); 186 throwsNoSuchMethodError);
182 shouldFail(() { throw new Exception(); }, 187 shouldFail(() { throw new Exception(); },
183 throwsNoSuchMethodError, 188 throwsNoSuchMethodError,
184 "Expected: throws an exception which matches NoSuchMethodError " 189 matches(
185 "But: exception ?:<Exception> does not match " 190 r"Expected: throws an exception which matches NoSuchMethodError +"
186 "NoSuchMethodError. " 191 r"But: exception \?:<Exception> does not match "
187 "Actual: <Closure: (dynamic) => dynamic>"); 192 r"NoSuchMethodError\."
193 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
188 }); 194 });
189 195
190 test('throwsUnimplementedError', () { 196 test('throwsUnimplementedError', () {
191 shouldPass(() { throw new UnimplementedError(''); }, 197 shouldPass(() { throw new UnimplementedError(''); },
192 throwsUnimplementedError); 198 throwsUnimplementedError);
193 shouldFail(() { throw new Exception(); }, 199 shouldFail(() { throw new Exception(); },
194 throwsUnimplementedError, 200 throwsUnimplementedError,
195 "Expected: throws an exception which matches UnimplementedError " 201 matches(
196 "But: exception ?:<Exception> does not match " 202 r"Expected: throws an exception which matches "
197 "UnimplementedError. " 203 r"UnimplementedError +"
198 "Actual: <Closure: (dynamic) => dynamic>"); 204 r"But: exception \?:<Exception> does not match "
205 r"UnimplementedError\."
206 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
199 }); 207 });
200 208
201 test('throwsUnsupportedError', () { 209 test('throwsUnsupportedError', () {
202 shouldPass(() { throw new UnsupportedError(''); }, 210 shouldPass(() { throw new UnsupportedError(''); },
203 throwsUnsupportedError); 211 throwsUnsupportedError);
204 shouldFail(() { throw new Exception(); }, 212 shouldFail(() { throw new Exception(); },
205 throwsUnsupportedError, 213 throwsUnsupportedError,
206 "Expected: throws an exception which matches UnsupportedError " 214 matches(
207 "But: exception ?:<Exception> does not match " 215 r"Expected: throws an exception which matches UnsupportedError +"
208 "UnsupportedError. " 216 r"But: exception \?:<Exception> does not match "
209 "Actual: <Closure: (dynamic) => dynamic>"); 217 r"UnsupportedError\."
218 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
210 }); 219 });
211 220
212 test('throwsStateError', () { 221 test('throwsStateError', () {
213 shouldPass(() { throw new StateError(''); }, 222 shouldPass(() { throw new StateError(''); },
214 throwsStateError); 223 throwsStateError);
215 shouldFail(() { throw new Exception(); }, 224 shouldFail(() { throw new Exception(); },
216 throwsStateError, 225 throwsStateError,
217 "Expected: throws an exception which matches StateError " 226 matches(
218 "But: exception ?:<Exception> does not match " 227 r"Expected: throws an exception which matches StateError +"
219 "StateError. " 228 r"But: exception \?:<Exception> does not match "
220 "Actual: <Closure: (dynamic) => dynamic>"); 229 r"StateError\."
230 r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
221 }); 231 });
222 232
223 test('returnsNormally', () { 233 test('returnsNormally', () {
224 shouldPass(doesNotThrow, returnsNormally); 234 shouldPass(doesNotThrow, returnsNormally);
225 shouldFail(doesThrow, returnsNormally, 235 shouldFail(doesThrow, returnsNormally,
226 "Expected: return normally But: threw 'X'. " 236 matches(
227 "Actual: <Closure: (dynamic) => dynamic " 237 r"Expected: return normally +But: threw 'X'\."
228 "from Function 'doesThrow': static.>"); 238 r"Actual: <Closure(: \(dynamic\) => dynamic "
239 r"from Function 'doesThrow': static\.)?>"));
229 }); 240 });
230 241
231 test('hasLength', () { 242 test('hasLength', () {
232 var a = new Map(); 243 var a = new Map();
233 var b = new List(); 244 var b = new List();
234 shouldPass(a, hasLength(0)); 245 shouldPass(a, hasLength(0));
235 shouldPass(b, hasLength(0)); 246 shouldPass(b, hasLength(0));
236 shouldPass('a', hasLength(1)); 247 shouldPass('a', hasLength(1));
237 shouldFail(0, hasLength(0), new PrefixMatcher( 248 shouldFail(0, hasLength(0), new PrefixMatcher(
238 "Expected: an object with length of <0> " 249 "Expected: an object with length of <0> "
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 shouldPass(w, new HasPrice(10)); 782 shouldPass(w, new HasPrice(10));
772 shouldPass(w, new HasPrice(greaterThan(0))); 783 shouldPass(w, new HasPrice(greaterThan(0)));
773 shouldFail(w, new HasPrice(greaterThan(10)), 784 shouldFail(w, new HasPrice(greaterThan(10)),
774 "Expected: Widget with a price that is a value greater than <10> " 785 "Expected: Widget with a price that is a value greater than <10> "
775 "But: price was <10>. " 786 "But: price was <10>. "
776 "Actual: <Instance of 'Widget'>"); 787 "Actual: <Instance of 'Widget'>");
777 }); 788 });
778 }); 789 });
779 } 790 }
780 791
OLDNEW
« no previous file with comments | « pkg/unittest/lib/src/pretty_print.dart ('k') | pkg/unittest/test/pretty_print_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698