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

Side by Side Diff: tests/lib/mirrors/repo_19173/interfaces.dart

Issue 312713003: Repro for Issue 19173 - Mirrors + dart2js + checked mode (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: oops Created 6 years, 6 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
OLDNEW
(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 library matcher.interfaces;
6
7 // To decouple the reporting of errors, and allow for extensibility of
8 // matchers, we make use of some interfaces.
9
10 /// The ErrorFormatter type is used for functions that
11 /// can be used to build up error reports upon [expect] failures.
12 /// There is one built-in implementation ([defaultErrorFormatter])
13 /// which is used by the default failure handler. If the failure handler
14 /// is replaced it may be desirable to replace the [stringDescription]
15 /// error formatter with another.
16 typedef String ErrorFormatter(actual, Matcher matcher, String reason,
17 Map matchState, bool verbose);
18
19 /// Matchers build up their error messages by appending to
20 /// Description objects. This interface is implemented by
21 /// StringDescription. This interface is unlikely to need
22 /// other implementations, but could be useful to replace in
23 /// some cases - e.g. language conversion.
24 abstract class Description {
25 int get length;
26
27 /// Change the value of the description.
28 Description replace(String text);
29
30 /// This is used to add arbitrary text to the description.
31 Description add(String text);
32
33 /// This is used to add a meaningful description of a value.
34 Description addDescriptionOf(value);
35
36 /// This is used to add a description of an [Iterable] [list],
37 /// with appropriate [start] and [end] markers and inter-element [separator].
38 Description addAll(String start, String separator, String end, Iterable list);
39 }
40
41 /// [expect] Matchers must implement/extend the Matcher class.
42 /// The base Matcher class has a generic implementation of [describeMismatch]
43 /// so this does not need to be provided unless a more clear description is
44 /// required. The other two methods ([matches] and [describe])
45 /// must always be provided as they are highly matcher-specific.
46 abstract class Matcher {
47 const Matcher();
48
49 /// This does the matching of the actual vs expected values.
50 /// [item] is the actual value. [matchState] can be supplied
51 /// and may be used to add details about the mismatch that are too
52 /// costly to determine in [describeMismatch].
53 bool matches(item, Map matchState);
54
55 /// This builds a textual description of the matcher.
56 Description describe(Description description);
57
58 /// This builds a textual description of a specific mismatch. [item]
59 /// is the value that was tested by [matches]; [matchState] is
60 /// the [Map] that was passed to and supplemented by [matches]
61 /// with additional information about the mismact, and [mismatchDescription]
62 /// is the [Description] that is being built to decribe the mismatch.
63 /// A few matchers make use of the [verbose] flag to provide detailed
64 /// information that is not typically included but can be of help in
65 /// diagnosing failures, such as stack traces.
66 Description describeMismatch(item, Description mismatchDescription,
67 Map matchState, bool verbose) => mismatchDescription;
68 }
69
70 /// Failed matches are reported using a default IFailureHandler.
71 /// The default implementation simply throws [TestFailure]s;
72 /// this can be replaced by some other implementation of
73 /// IFailureHandler by calling configureExpectHandler.
74 abstract class FailureHandler {
75 /// This handles failures given a textual decription
76 void fail(String reason);
77
78 /// This handles failures given the actual [value], the [matcher]
79 /// the [reason] (argument from [expect]), some additonal [matchState]
80 /// generated by the [matcher], and a verbose flag which controls in
81 /// some cases how much [matchState] information is used. It will use
82 /// these to create a detailed error message (typically by calling
83 /// an [ErrorFormatter]) and then call [fail] with this message.
84 void failMatch(actual, Matcher matcher, String reason,
85 Map matchState, bool verbose);
86 }
OLDNEW
« no previous file with comments | « tests/lib/mirrors/repo_19173/expect.dart ('k') | tests/lib/mirrors/repo_19173/pretty_print.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698