Chromium Code Reviews| Index: lib/unittest/matcher.dart |
| =================================================================== |
| --- lib/unittest/matcher.dart (revision 0) |
| +++ lib/unittest/matcher.dart (revision 0) |
| @@ -0,0 +1,40 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +/** |
| + * Matcher is the base class for all matchers. To implement a new |
| + * matcher, either add a class that implements from IMatcher or |
| + * a class that inherits from Matcher. Inheriting from Matcher has |
| + * the benefit that a default implementation of describeMismatch will |
| + * be provided. |
| + */ |
| + |
| +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
|
| + |
| + /** |
| + * This tests the matcher against a given [item] |
| + * and return true if the match succeeds; false otherwise. |
| + */ |
| + bool matches(item) { |
|
Bob Nystrom
2012/05/30 23:23:51
Just make this abstract.
gram
2012/06/01 17:33:15
Done.
|
| + throw new NotImplementedException(/*'matches'*/); |
| + } |
| + |
| + /** |
| + * This creates a textual description of a matcher, |
| + * by appending to [mismatchDescription]. |
| + */ |
| + IDescription describe(IDescription mismatchDescription) { |
|
Bob Nystrom
2012/05/30 23:23:51
This too.
gram
2012/06/01 17:33:15
Done.
|
| + throw new NotImplementedException(/*'describe'*/); |
| + } |
| + |
| + /** |
| + * 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.
|
| + * [item], by appending the description to [mismatchDescription]. |
| + * It does not check whether the [item] fails the match, as it is |
| + * only called after a failed match. |
| + */ |
| + IDescription describeMismatch(item, IDescription mismatchDescription) => |
| + mismatchDescription.append('was ').appendDescriptionOf(item); |
| +} |
| + |