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

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

Issue 22999018: TestFailure + Error baseclass = stack traces! (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | « no previous file | no next file » | 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 extends Error{
9 String _message; 9 final String message;
10 10
11 get message => _message; 11 TestFailure(this.message);
12 set message(String value) => _message = value;
13 12
14 TestFailure(String message) : _message = message; 13 String toString() => message;
15
16 String toString() => _message;
17 } 14 }
18 15
19 /** 16 /**
20 * Useful utility for nesting match states. 17 * Useful utility for nesting match states.
21 */ 18 */
22 19
23 void addStateInfo(Map matchState, Map values) { 20 void addStateInfo(Map matchState, Map values) {
24 var innerState = new Map.from(matchState); 21 var innerState = new Map.from(matchState);
25 matchState.clear(); 22 matchState.clear();
26 matchState['state'] = innerState; 23 matchState['state'] = innerState;
27 matchState.addAll(values); 24 matchState.addAll(values);
28 } 25 }
29 26
30 /** 27 /**
31 * Some matchers, like those for Futures and exception testing, 28 * Some matchers, like those for Futures and exception testing,
32 * can fail in asynchronous sections, and throw exceptions. 29 * can fail in asynchronous sections, and throw exceptions.
33 * A user of this library will typically want to catch and handle 30 * A user of this library will typically want to catch and handle
34 * such exceptions. The [wrapAsync] property is a function that 31 * such exceptions. The [wrapAsync] property is a function that
35 * can wrap callbacks used by these Matchers so that they can be 32 * can wrap callbacks used by these Matchers so that they can be
36 * used safely. For example, the unittest library will set this 33 * used safely. For example, the unittest library will set this
37 * to be expectAsync1. By default this is an identity function. 34 * to be expectAsync1. By default this is an identity function.
38 */ 35 */
39 Function wrapAsync = (f, [id]) => f; 36 Function wrapAsync = (f, [id]) => f;
40 37
41 /** 38 /**
42 * This is the main assertion function. It asserts that [actual] 39 * This is the main assertion function. It asserts that [actual]
43 * matches the [matcher]. [reason] is optional and is typically not 40 * matches the [matcher]. [reason] is optional and is typically not
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 * formatter is returned; this allows custom expect handlers to easily 167 * formatter is returned; this allows custom expect handlers to easily
171 * get a reference to the default formatter. 168 * get a reference to the default formatter.
172 */ 169 */
173 ErrorFormatter configureExpectFormatter([ErrorFormatter formatter = null]) { 170 ErrorFormatter configureExpectFormatter([ErrorFormatter formatter = null]) {
174 if (formatter == null) { 171 if (formatter == null) {
175 formatter = _defaultErrorFormatter; 172 formatter = _defaultErrorFormatter;
176 } 173 }
177 return _assertErrorFormatter = formatter; 174 return _assertErrorFormatter = formatter;
178 } 175 }
179 176
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698