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

Side by Side Diff: packages/matcher/lib/src/string_matchers.dart

Issue 3014633002: Roll to pickup pool changes (Closed)
Patch Set: Created 3 years, 2 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 | « packages/matcher/lib/src/numeric_matchers.dart ('k') | packages/matcher/lib/src/util.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 import 'interfaces.dart'; 5 import 'interfaces.dart';
6 6
7 /// Returns a matcher which matches if the match argument is a string and 7 /// Returns a matcher which matches if the match argument is a string and
8 /// is equal to [value] when compared case-insensitively. 8 /// is equal to [value] when compared case-insensitively.
9 Matcher equalsIgnoringCase(String value) => new _IsEqualIgnoringCase(value); 9 Matcher equalsIgnoringCase(String value) => new _IsEqualIgnoringCase(value);
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 Matcher stringContainsInOrder(List<String> substrings) => 112 Matcher stringContainsInOrder(List<String> substrings) =>
113 new _StringContainsInOrder(substrings); 113 new _StringContainsInOrder(substrings);
114 114
115 class _StringContainsInOrder extends _StringMatcher { 115 class _StringContainsInOrder extends _StringMatcher {
116 final List<String> _substrings; 116 final List<String> _substrings;
117 117
118 const _StringContainsInOrder(this._substrings); 118 const _StringContainsInOrder(this._substrings);
119 119
120 bool matches(item, Map matchState) { 120 bool matches(item, Map matchState) {
121 if (!(item is String)) { 121 if (item is String) {
122 var from_index = 0;
123 for (var s in _substrings) {
124 from_index = item.indexOf(s, from_index);
125 if (from_index < 0) return false;
126 }
127 return true;
128 } else {
122 return false; 129 return false;
123 } 130 }
124 var from_index = 0;
125 for (var s in _substrings) {
126 from_index = item.indexOf(s, from_index);
127 if (from_index < 0) return false;
128 }
129 return true;
130 } 131 }
131 132
132 Description describe(Description description) => description.addAll( 133 Description describe(Description description) => description.addAll(
133 'a string containing ', ', ', ' in order', _substrings); 134 'a string containing ', ', ', ' in order', _substrings);
134 } 135 }
135 136
136 /// Returns a matcher that matches if the match argument is a string and 137 /// Returns a matcher that matches if the match argument is a string and
137 /// matches the regular expression given by [re]. 138 /// matches the regular expression given by [re].
138 /// 139 ///
139 /// [re] can be a [RegExp] instance or a [String]; in the latter case it will be 140 /// [re] can be a [RegExp] instance or a [String]; in the latter case it will be
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } else { 191 } else {
191 result.write(character); 192 result.write(character);
192 skipSpace = false; 193 skipSpace = false;
193 } 194 }
194 } 195 }
195 return result.toString().trim(); 196 return result.toString().trim();
196 } 197 }
197 198
198 bool _isWhitespace(String ch) => 199 bool _isWhitespace(String ch) =>
199 ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'; 200 ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
OLDNEW
« no previous file with comments | « packages/matcher/lib/src/numeric_matchers.dart ('k') | packages/matcher/lib/src/util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698