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

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

Issue 12393017: Fix issue with async callbacks that get called synchronously while running test case function causi… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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
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
11 get message => _message; 11 get message => _message;
12 set message(String value) => _message = value; 12 set message(String value) => _message = value;
13 13
14 TestFailure(String message) : _message = message; 14 TestFailure(String message) : _message = message;
15 15
16 String toString() => _message; 16 String toString() => _message;
17 } 17 }
18 18
19 /** 19 /**
20 * Some matchers, like those for Futures and exception testing, 20 * Some matchers, like those for Futures and exception testing,
21 * can fail in asynchronous sections, and throw exceptions. 21 * can fail in asynchronous sections, and throw exceptions.
22 * A user of this library will typically want to catch and handle 22 * A user of this library will typically want to catch and handle
23 * such exceptions. The [wrapAsync] property is a function that 23 * such exceptions. The [wrapAsync] property is a function that
24 * can wrap callbacks used by these Matchers so that they can be 24 * can wrap callbacks used by these Matchers so that they can be
25 * used safely. For example, the unittest library will set this 25 * used safely. For example, the unittest library will set this
26 * to be expectAsync1. By default this is an identity function. 26 * to be expectAsync1. By default this is an identity function.
27 */ 27 */
28 Function wrapAsync = (f) => f; 28 Function wrapAsync = (f, [id]) => f;
29 29
30 /** 30 /**
31 * This is the main assertion function. It asserts that [actual] 31 * This is the main assertion function. It asserts that [actual]
32 * matches the [matcher]. [reason] is optional and is typically not 32 * matches the [matcher]. [reason] is optional and is typically not
33 * supplied, as a reason is generated from the matcher; if [reason] 33 * supplied, as a reason is generated from the matcher; if [reason]
34 * is included it is appended to the reason generated by the matcher. 34 * is included it is appended to the reason generated by the matcher.
35 * 35 *
36 * [matcher] can be a value in which case it will be wrapped in an 36 * [matcher] can be a value in which case it will be wrapped in an
37 * [equals] matcher. 37 * [equals] matcher.
38 * 38 *
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 * formatter is returned; this allows custom expect handlers to easily 173 * formatter is returned; this allows custom expect handlers to easily
174 * get a reference to the default formatter. 174 * get a reference to the default formatter.
175 */ 175 */
176 ErrorFormatter configureExpectFormatter([ErrorFormatter formatter = null]) { 176 ErrorFormatter configureExpectFormatter([ErrorFormatter formatter = null]) {
177 if (formatter == null) { 177 if (formatter == null) {
178 formatter = _defaultErrorFormatter; 178 formatter = _defaultErrorFormatter;
179 } 179 }
180 return _assertErrorFormatter = formatter; 180 return _assertErrorFormatter = formatter;
181 } 181 }
182 182
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698