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

Side by Side Diff: pkg/unittest/lib/src/expect.dart

Issue 12328143: pkg/unittest: Moved `fail` to matcher library (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixes to align with r19166 Created 7 years, 9 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/lib/src/core_matchers.dart ('k') | pkg/unittest/lib/src/future_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 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
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
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
OLDNEW
« no previous file with comments | « pkg/unittest/lib/src/core_matchers.dart ('k') | pkg/unittest/lib/src/future_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698