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

Unified Diff: lib/unittest/matcher.dart

Issue 10441104: New expectation functions plus convert old tests to use these. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
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);
+}
+

Powered by Google App Engine
This is Rietveld 408576698