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

Side by Side Diff: pkg/unittest/matcher.dart

Issue 11027072: Abstract is now required on abstract classes so adding that. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « pkg/unittest/core_matchers.dart ('k') | pkg/unittest/string_matchers.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 /** 5 /**
6 * MatchState is a simple wrapper around an arbitrary object. 6 * MatchState is a simple wrapper around an arbitrary object.
7 * [Matcher] [matches] methods can use this to store useful 7 * [Matcher] [matches] methods can use this to store useful
8 * information upon match failures, and this information will 8 * information upon match failures, and this information will
9 * be passed to [describeMismatch]. Each [Matcher] is responsible 9 * be passed to [describeMismatch]. Each [Matcher] is responsible
10 * for its own use of this state, so the state created by [matches] 10 * for its own use of this state, so the state created by [matches]
11 * should be consistent with that expected by [describeMismatch] in 11 * should be consistent with that expected by [describeMismatch] in
12 * the same [Matcher] class, but can vary between classes. The inner 12 * the same [Matcher] class, but can vary between classes. The inner
13 * state, if set, will typically be a [Map] with a number of key-value 13 * state, if set, will typically be a [Map] with a number of key-value
14 * pairs containing relevant state information. 14 * pairs containing relevant state information.
15 */ 15 */
16 class MatchState { 16 class MatchState {
17 var state = null; 17 var state = null;
18 18
19 MatchState([this.state]); 19 MatchState([this.state]);
20 } 20 }
21 21
22 /** 22 /**
23 * BaseMatcher is the base class for all matchers. To implement a new 23 * BaseMatcher is the base class for all matchers. To implement a new
24 * matcher, either add a class that implements from IMatcher or 24 * matcher, either add a class that implements from IMatcher or
25 * a class that inherits from Matcher. Inheriting from Matcher has 25 * a class that inherits from Matcher. Inheriting from Matcher has
26 * the benefit that a default implementation of describeMismatch will 26 * the benefit that a default implementation of describeMismatch will
27 * be provided. 27 * be provided.
28 */ 28 */
29 class BaseMatcher implements Matcher { 29 abstract class BaseMatcher implements Matcher {
30 const BaseMatcher(); 30 const BaseMatcher();
31 31
32 /** 32 /**
33 * Tests the matcher against a given [item] 33 * Tests the matcher against a given [item]
34 * and return true if the match succeeds; false otherwise. 34 * and return true if the match succeeds; false otherwise.
35 * [matchState] may be used to return additional info for 35 * [matchState] may be used to return additional info for
36 * the use of [describeMismatch]. 36 * the use of [describeMismatch].
37 */ 37 */
38 abstract bool matches(item, MatchState matchState); 38 abstract bool matches(item, MatchState matchState);
39 39
40 /** 40 /**
41 * Creates a textual description of a matcher, 41 * Creates a textual description of a matcher,
42 * by appending to [mismatchDescription]. 42 * by appending to [mismatchDescription].
43 */ 43 */
44 abstract Description describe(Description mismatchDescription); 44 abstract Description describe(Description mismatchDescription);
45 45
46 /** 46 /**
47 * Generates a description of the matcher failed for a particular 47 * Generates a description of the matcher failed for a particular
48 * [item], by appending the description to [mismatchDescription]. 48 * [item], by appending the description to [mismatchDescription].
49 * It does not check whether the [item] fails the match, as it is 49 * It does not check whether the [item] fails the match, as it is
50 * only called after a failed match. There may be additional info 50 * only called after a failed match. There may be additional info
51 * about the mismatch in [matchState]. 51 * about the mismatch in [matchState].
52 */ 52 */
53 Description describeMismatch(item, Description mismatchDescription, 53 Description describeMismatch(item, Description mismatchDescription,
54 MatchState matchState, bool verbose) => 54 MatchState matchState, bool verbose) =>
55 mismatchDescription.add('was ').addDescriptionOf(item); 55 mismatchDescription.add('was ').addDescriptionOf(item);
56 } 56 }
OLDNEW
« no previous file with comments | « pkg/unittest/core_matchers.dart ('k') | pkg/unittest/string_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698