| OLD | NEW |
| 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 part of matcher; | 5 part of matcher; |
| 6 | 6 |
| 7 /** The objects thrown by the default failure handler. */ | 7 /** The objects thrown by the default failure handler. */ |
| 8 class TestFailure { | 8 class TestFailure { |
| 9 String _message; | 9 String _message; |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 if (!doesMatch) { | 63 if (!doesMatch) { |
| 64 if (failureHandler == null) { | 64 if (failureHandler == null) { |
| 65 failureHandler = getOrCreateExpectFailureHandler(); | 65 failureHandler = getOrCreateExpectFailureHandler(); |
| 66 } | 66 } |
| 67 failureHandler.failMatch(actual, matcher, reason, matchState, verbose); | 67 failureHandler.failMatch(actual, matcher, reason, matchState, verbose); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 void fail(String message, {FailureHandler failureHandler}) { |
| 72 if (failureHandler == null) { |
| 73 failureHandler = getOrCreateExpectFailureHandler(); |
| 74 } |
| 75 failureHandler.fail(message); |
| 76 } |
| 77 |
| 71 /** | 78 /** |
| 72 * Takes an argument and returns an equivalent matcher. | 79 * Takes an argument and returns an equivalent matcher. |
| 73 * If the argument is already a matcher this does nothing, | 80 * If the argument is already a matcher this does nothing, |
| 74 * else if the argument is a function, it generates a predicate | 81 * else if the argument is a function, it generates a predicate |
| 75 * function matcher, else it generates an equals matcher. | 82 * function matcher, else it generates an equals matcher. |
| 76 */ | 83 */ |
| 77 Matcher wrapMatcher(x) { | 84 Matcher wrapMatcher(x) { |
| 78 if (x is Matcher) { | 85 if (x is Matcher) { |
| 79 return x; | 86 return x; |
| 80 } else if (x is Function) { | 87 } else if (x is Function) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 * formatter is returned; this allows custom expect handlers to easily | 173 * formatter is returned; this allows custom expect handlers to easily |
| 167 * get a reference to the default formatter. | 174 * get a reference to the default formatter. |
| 168 */ | 175 */ |
| 169 ErrorFormatter configureExpectFormatter([ErrorFormatter formatter = null]) { | 176 ErrorFormatter configureExpectFormatter([ErrorFormatter formatter = null]) { |
| 170 if (formatter == null) { | 177 if (formatter == null) { |
| 171 formatter = _defaultErrorFormatter; | 178 formatter = _defaultErrorFormatter; |
| 172 } | 179 } |
| 173 return _assertErrorFormatter = formatter; | 180 return _assertErrorFormatter = formatter; |
| 174 } | 181 } |
| 175 | 182 |
| OLD | NEW |