Index: pkg/unittest/lib/src/expect.dart |
=================================================================== |
--- pkg/unittest/lib/src/expect.dart (revision 19164) |
+++ pkg/unittest/lib/src/expect.dart (working copy) |
@@ -4,6 +4,18 @@ |
part of matcher; |
+/** The objects thrown by the default failure handler. */ |
+class TestFailure { |
+ String _message; |
+ |
+ get message => _message; |
+ set message(String value) => _message = value; |
+ |
+ TestFailure(String message) : _message = message; |
+ |
+ String toString() => _message; |
+} |
+ |
/** |
* Some matchers, like those for Futures and exception testing, |
* can fail in asynchronous sections, and throw exceptions. |
@@ -24,8 +36,8 @@ |
* [matcher] can be a value in which case it will be wrapped in an |
* [equals] matcher. |
* |
- * If the assertion fails, then the default behavior is to throw an |
- * [ExpectException], but this behavior can be changed by calling |
+ * If the assertion fails, then the default behavior is to throw a |
+ * [TestFailure], but this behavior can be changed by calling |
* [configureExpectFailureHandler] and providing an alternative handler that |
* implements the [IFailureHandler] interface. It is also possible to |
* pass a [failureHandler] to [expect] as a final parameter for fine- |
@@ -75,7 +87,7 @@ |
// The handler for failed asserts. |
FailureHandler _assertFailureHandler = null; |
-// The default failure handler that throws ExpectExceptions. |
+// The default failure handler that throws [TestFailure]s. |
class DefaultFailureHandler implements FailureHandler { |
DefaultFailureHandler() { |
if (_assertErrorFormatter == null) { |
@@ -83,7 +95,7 @@ |
} |
} |
void fail(String reason) { |
- throw new ExpectException(reason); |
+ throw new TestFailure(reason); |
} |
void failMatch(actual, Matcher matcher, String reason, |
MatchState matchState, bool verbose) { |
@@ -95,7 +107,7 @@ |
* Changes or resets to the default the failure handler for expect() |
* [handler] is a reference to the new handler; if this is omitted |
* or null then the failure handler is reset to the default, which |
- * throws [ExpectExceptions] on [expect] assertion failures. |
+ * throws [TestFailure]s on [expect] assertion failures. |
*/ |
void configureExpectFailureHandler([FailureHandler handler = null]) { |
if (handler == null) { |