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

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

Issue 994703003: Fix equalsIgnoringWhitespace examples. (Closed) Base URL: git@github.com:dart-lang/matcher@master
Patch Set: Created 5 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
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('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 matcher.string_matchers; 5 library matcher.string_matchers;
6 6
7 import 'interfaces.dart'; 7 import 'interfaces.dart';
8 8
9 /// Returns a matcher which matches if the match argument is a string and 9 /// Returns a matcher which matches if the match argument is a string and
10 /// is equal to [value] when compared case-insensitively. 10 /// is equal to [value] when compared case-insensitively.
(...skipping 16 matching lines...) Expand all
27 27
28 /// Returns a matcher which matches if the match argument is a string and 28 /// Returns a matcher which matches if the match argument is a string and
29 /// is equal to [value], ignoring whitespace. 29 /// is equal to [value], ignoring whitespace.
30 /// 30 ///
31 /// In this matcher, "ignoring whitespace" means comparing with all runs of 31 /// In this matcher, "ignoring whitespace" means comparing with all runs of
32 /// whitespace collapsed to single space characters and leading and trailing 32 /// whitespace collapsed to single space characters and leading and trailing
33 /// whitespace removed. 33 /// whitespace removed.
34 /// 34 ///
35 /// For example, the following will all match successfully: 35 /// For example, the following will all match successfully:
36 /// 36 ///
37 /// expect("hello world", equalsIgnoringCase("hello world")); 37 /// expect("hello world", equalsIgnoringWhitespace("hello world"));
38 /// expect(" hello world", equalsIgnoringCase("hello world")); 38 /// expect(" hello world", equalsIgnoringWhitespace("hello world"));
39 /// expect("hello world ", equalsIgnoringCase("hello world")); 39 /// expect("hello world ", equalsIgnoringWhitespace("hello world"));
40 /// 40 ///
41 /// The following will not match: 41 /// The following will not match:
42 /// 42 ///
43 /// expect("helloworld", equalsIgnoringCase("hello world")); 43 /// expect("helloworld", equalsIgnoringWhitespace("hello world"));
44 /// expect("he llo world", equalsIgnoringCase("hello world")); 44 /// expect("he llo world", equalsIgnoringWhitespace("hello world"));
45 Matcher equalsIgnoringWhitespace(String value) => 45 Matcher equalsIgnoringWhitespace(String value) =>
46 new _IsEqualIgnoringWhitespace(value); 46 new _IsEqualIgnoringWhitespace(value);
47 47
48 class _IsEqualIgnoringWhitespace extends _StringMatcher { 48 class _IsEqualIgnoringWhitespace extends _StringMatcher {
49 final String _value; 49 final String _value;
50 final String _matchValue; 50 final String _matchValue;
51 51
52 _IsEqualIgnoringWhitespace(String value) 52 _IsEqualIgnoringWhitespace(String value)
53 : _value = value, 53 : _value = value,
54 _matchValue = collapseWhitespace(value); 54 _matchValue = collapseWhitespace(value);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } else { 192 } else {
193 result.write(character); 193 result.write(character);
194 skipSpace = false; 194 skipSpace = false;
195 } 195 }
196 } 196 }
197 return result.toString().trim(); 197 return result.toString().trim();
198 } 198 }
199 199
200 bool _isWhitespace(String ch) => 200 bool _isWhitespace(String ch) =>
201 ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'; 201 ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698