Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * Matcher is the base class for all matchers. To implement a new | |
| 7 * matcher, either add a class that implements from IMatcher or | |
| 8 * a class that inherits from Matcher. Inheriting from Matcher has | |
| 9 * the benefit that a default implementation of describeMismatch will | |
| 10 * be provided. | |
| 11 */ | |
| 12 | |
| 13 class Matcher implements IMatcher { | |
|
Bob Nystrom
2012/05/30 23:23:51
I would get rid of the separate interface and just
gram
2012/06/01 17:33:15
I'd rather not, if that's okay with you. Implement
Bob Nystrom
2012/06/01 18:22:22
No, it works fine in checked mode. Implicit interf
| |
| 14 | |
| 15 /** | |
| 16 * This tests the matcher against a given [item] | |
| 17 * and return true if the match succeeds; false otherwise. | |
| 18 */ | |
| 19 bool matches(item) { | |
|
Bob Nystrom
2012/05/30 23:23:51
Just make this abstract.
gram
2012/06/01 17:33:15
Done.
| |
| 20 throw new NotImplementedException(/*'matches'*/); | |
| 21 } | |
| 22 | |
| 23 /** | |
| 24 * This creates a textual description of a matcher, | |
| 25 * by appending to [mismatchDescription]. | |
| 26 */ | |
| 27 IDescription describe(IDescription mismatchDescription) { | |
|
Bob Nystrom
2012/05/30 23:23:51
This too.
gram
2012/06/01 17:33:15
Done.
| |
| 28 throw new NotImplementedException(/*'describe'*/); | |
| 29 } | |
| 30 | |
| 31 /** | |
| 32 * This generates a description of the matcher failed for a particular | |
|
Bob Nystrom
2012/05/30 23:23:51
"Generates a description of why the matcher failed
gram
2012/06/01 17:33:15
Done.
| |
| 33 * [item], by appending the description to [mismatchDescription]. | |
| 34 * It does not check whether the [item] fails the match, as it is | |
| 35 * only called after a failed match. | |
| 36 */ | |
| 37 IDescription describeMismatch(item, IDescription mismatchDescription) => | |
| 38 mismatchDescription.append('was ').appendDescriptionOf(item); | |
| 39 } | |
| 40 | |
| OLD | NEW |