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

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

Issue 928333004: pkg/matcher: Small tweaks to improve analysis (Closed) Base URL: https://github.com/dart-lang/matcher.git@master
Patch Set: nits Created 5 years, 10 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
« no previous file with comments | « lib/src/core_matchers.dart ('k') | no next file » | 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 matcher.iterable_matchers; 5 library matcher.iterable_matchers;
6 6
7 import 'core_matchers.dart'; 7 import 'core_matchers.dart';
8 import 'description.dart'; 8 import 'description.dart';
9 import 'interfaces.dart'; 9 import 'interfaces.dart';
10 import 'util.dart'; 10 import 'util.dart';
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 /// Returns a matcher which matches [Iterable]s that have the same length and 113 /// Returns a matcher which matches [Iterable]s that have the same length and
114 /// the same elements as [expected], but not necessarily in the same order. 114 /// the same elements as [expected], but not necessarily in the same order.
115 /// 115 ///
116 /// Note that this is O(n^2) so should only be used on small objects. 116 /// Note that this is O(n^2) so should only be used on small objects.
117 Matcher unorderedEquals(Iterable expected) => new _UnorderedEquals(expected); 117 Matcher unorderedEquals(Iterable expected) => new _UnorderedEquals(expected);
118 118
119 class _UnorderedEquals extends _UnorderedMatches { 119 class _UnorderedEquals extends _UnorderedMatches {
120 final List _expectedValues; 120 final List _expectedValues;
121 121
122 _UnorderedEquals(Iterable expected) 122 _UnorderedEquals(Iterable expected)
123 : super(expected.map(equals)), 123 : _expectedValues = expected.toList(),
124 _expectedValues = expected.toList(); 124 super(expected.map(equals));
125 125
126 Description describe(Description description) => description 126 Description describe(Description description) => description
127 .add('equals ') 127 .add('equals ')
128 .addDescriptionOf(_expectedValues) 128 .addDescriptionOf(_expectedValues)
129 .add(' unordered'); 129 .add(' unordered');
130 } 130 }
131 131
132 /// Iterable matchers match against [Iterable]s. We add this intermediate 132 /// Iterable matchers match against [Iterable]s. We add this intermediate
133 /// class to give better mismatch error messages than the base Matcher class. 133 /// class to give better mismatch error messages than the base Matcher class.
134 abstract class _IterableMatcher extends Matcher { 134 abstract class _IterableMatcher extends Matcher {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } else { 258 } else {
259 return mismatchDescription 259 return mismatchDescription
260 .add('has ') 260 .add('has ')
261 .addDescriptionOf(matchState["actual"]) 261 .addDescriptionOf(matchState["actual"])
262 .add(' which is not $_description ') 262 .add(' which is not $_description ')
263 .addDescriptionOf(matchState["expected"]) 263 .addDescriptionOf(matchState["expected"])
264 .add(' at index ${matchState["index"]}'); 264 .add(' at index ${matchState["index"]}');
265 } 265 }
266 } 266 }
267 } 267 }
OLDNEW
« no previous file with comments | « lib/src/core_matchers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698