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

Side by Side Diff: pkg/unittest/lib/src/iterable_matchers.dart

Issue 50413005: Reapply "Remove @deprecated features." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head Created 7 years, 1 month 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
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 part of matcher; 5 part of matcher;
6 6
7 /** 7 /**
8 * Returns a matcher which matches [Iterable]s in which all elements 8 * Returns a matcher which matches [Iterable]s in which all elements
9 * match the given [matcher]. 9 * match the given [matcher].
10 */ 10 */
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 mismatchDescription.add(' at index $index'); 52 mismatchDescription.add(' at index $index');
53 return mismatchDescription; 53 return mismatchDescription;
54 } 54 }
55 return super.describeMismatch(item, mismatchDescription, 55 return super.describeMismatch(item, mismatchDescription,
56 matchState, verbose); 56 matchState, verbose);
57 } 57 }
58 } 58 }
59 59
60 /** 60 /**
61 * Deprecated form of [anyElement].
62 */
63 @deprecated
64 Matcher someElement(matcher) => new _AnyElement(wrapMatcher(matcher));
65
66 /**
67 * Returns a matcher which matches [Iterable]s in which at least one 61 * Returns a matcher which matches [Iterable]s in which at least one
68 * element matches the given [matcher]. 62 * element matches the given [matcher].
69 */ 63 */
70 Matcher anyElement(matcher) => new _AnyElement(wrapMatcher(matcher)); 64 Matcher anyElement(matcher) => new _AnyElement(wrapMatcher(matcher));
71 65
72 class _AnyElement extends _IterableMatcher { 66 class _AnyElement extends _IterableMatcher {
73 Matcher _matcher; 67 Matcher _matcher;
74 68
75 _AnyElement(this._matcher); 69 _AnyElement(this._matcher);
76 70
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 iterator.moveNext(); 218 iterator.moveNext();
225 if (!_comparator(e, iterator.current)) { 219 if (!_comparator(e, iterator.current)) {
226 addStateInfo(matchState, {'index': i, 'expected': e, 220 addStateInfo(matchState, {'index': i, 'expected': e,
227 'actual': iterator.current}); 221 'actual': iterator.current});
228 return false; 222 return false;
229 } 223 }
230 i++; 224 i++;
231 } 225 }
232 return true; 226 return true;
233 } 227 }
234 228
235 Description describe(Description description) => 229 Description describe(Description description) =>
236 description.add('pairwise $_description ').addDescriptionOf(_expected); 230 description.add('pairwise $_description ').addDescriptionOf(_expected);
237 231
238 Description describeMismatch(item, Description mismatchDescription, 232 Description describeMismatch(item, Description mismatchDescription,
239 Map matchState, bool verbose) { 233 Map matchState, bool verbose) {
240 if (item is !Iterable) { 234 if (item is !Iterable) {
241 return mismatchDescription.add('is not an Iterable'); 235 return mismatchDescription.add('is not an Iterable');
242 } else if (item.length != _expected.length) { 236 } else if (item.length != _expected.length) {
243 return mismatchDescription. 237 return mismatchDescription.
244 add('has length ${item.length} instead of ${_expected.length}'); 238 add('has length ${item.length} instead of ${_expected.length}');
245 } else { 239 } else {
246 return mismatchDescription. 240 return mismatchDescription.
247 add('has '). 241 add('has ').
248 addDescriptionOf(matchState["actual"]). 242 addDescriptionOf(matchState["actual"]).
249 add(' which is not $_description '). 243 add(' which is not $_description ').
250 addDescriptionOf(matchState["expected"]). 244 addDescriptionOf(matchState["expected"]).
251 add(' at index ${matchState["index"]}'); 245 add(' at index ${matchState["index"]}');
252 } 246 }
253 } 247 }
254 } 248 }
255 249
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698