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

Side by Side Diff: lib/src/frontend/expect_async.dart

Issue 1053443002: Rename the package to "test". (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 8 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
« no previous file with comments | « lib/src/frontend/expect.dart ('k') | lib/src/frontend/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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library unittest.frontend.expect_async; 5 library test.frontend.expect_async;
6 6
7 import '../backend/invoker.dart'; 7 import '../backend/invoker.dart';
8 import '../backend/state.dart'; 8 import '../backend/state.dart';
9 import 'expect.dart'; 9 import 'expect.dart';
10 10
11 /// An object used to detect unpassed arguments. 11 /// An object used to detect unpassed arguments.
12 const _PLACEHOLDER = const Object(); 12 const _PLACEHOLDER = const Object();
13 13
14 // Functions used to check how many arguments a callback takes. 14 // Functions used to check how many arguments a callback takes.
15 typedef _Func0(); 15 typedef _Func0();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 _max5([a0 = _PLACEHOLDER, a1 = _PLACEHOLDER, a2 = _PLACEHOLDER, 156 _max5([a0 = _PLACEHOLDER, a1 = _PLACEHOLDER, a2 = _PLACEHOLDER,
157 a3 = _PLACEHOLDER, a4 = _PLACEHOLDER]) => _max6(a0, a1, a2, a3, a4); 157 a3 = _PLACEHOLDER, a4 = _PLACEHOLDER]) => _max6(a0, a1, a2, a3, a4);
158 158
159 _max6([a0 = _PLACEHOLDER, a1 = _PLACEHOLDER, a2 = _PLACEHOLDER, 159 _max6([a0 = _PLACEHOLDER, a1 = _PLACEHOLDER, a2 = _PLACEHOLDER,
160 a3 = _PLACEHOLDER, a4 = _PLACEHOLDER, a5 = _PLACEHOLDER]) => 160 a3 = _PLACEHOLDER, a4 = _PLACEHOLDER, a5 = _PLACEHOLDER]) =>
161 _run([a0, a1, a2, a3, a4, a5].where((a) => a != _PLACEHOLDER)); 161 _run([a0, a1, a2, a3, a4, a5].where((a) => a != _PLACEHOLDER));
162 162
163 /// Runs the wrapped function with [args] and returns its return value. 163 /// Runs the wrapped function with [args] and returns its return value.
164 _run(Iterable args) { 164 _run(Iterable args) {
165 // Note that in the old unittest, this returned `null` if it encountered an 165 // Note that in the old test, this returned `null` if it encountered an
166 // error, where now it just re-throws that error because Zone machinery will 166 // error, where now it just re-throws that error because Zone machinery will
167 // pass it to the invoker anyway. 167 // pass it to the invoker anyway.
168 try { 168 try {
169 _actualCalls++; 169 _actualCalls++;
170 if (_invoker.liveTest.isComplete && 170 if (_invoker.liveTest.isComplete &&
171 _invoker.liveTest.state.result == Result.success) { 171 _invoker.liveTest.state.result == Result.success) {
172 throw 'Callback ${_id}called ($_actualCalls) after test case ' 172 throw 'Callback ${_id}called ($_actualCalls) after test case '
173 '${_invoker.liveTest.test.name} had already completed.$_reason'; 173 '${_invoker.liveTest.test.name} had already completed.$_reason';
174 } else if (_maxExpectedCalls >= 0 && _actualCalls > _maxExpectedCalls) { 174 } else if (_maxExpectedCalls >= 0 && _actualCalls > _maxExpectedCalls) {
175 throw new TestFailure('Callback ${_id}called more times than expected ' 175 throw new TestFailure('Callback ${_id}called more times than expected '
(...skipping 18 matching lines...) Expand all
194 // Mark this callback as complete and remove it from the test case's 194 // Mark this callback as complete and remove it from the test case's
195 // oustanding callback count; if that hits zero the test is done. 195 // oustanding callback count; if that hits zero the test is done.
196 _complete = true; 196 _complete = true;
197 _invoker.removeOutstandingCallback(); 197 _invoker.removeOutstandingCallback();
198 } 198 }
199 } 199 }
200 200
201 /// Indicate that [callback] is expected to be called [count] number of times 201 /// Indicate that [callback] is expected to be called [count] number of times
202 /// (by default 1). 202 /// (by default 1).
203 /// 203 ///
204 /// The unittest framework will wait for the callback to run the [count] times 204 /// The test framework will wait for the callback to run the [count] times
205 /// before it considers the current test to be complete. [callback] may take up 205 /// before it considers the current test to be complete. [callback] may take up
206 /// to six optional or required positional arguments; named arguments are not 206 /// to six optional or required positional arguments; named arguments are not
207 /// supported. 207 /// supported.
208 /// 208 ///
209 /// [max] can be used to specify an upper bound on the number of calls; if this 209 /// [max] can be used to specify an upper bound on the number of calls; if this
210 /// is exceeded the test will fail. If [max] is `0` (the default), the callback 210 /// is exceeded the test will fail. If [max] is `0` (the default), the callback
211 /// is expected to be called exactly [count] times. If [max] is `-1`, the 211 /// is expected to be called exactly [count] times. If [max] is `-1`, the
212 /// callback is allowed to be called any number of times greater than [count]. 212 /// callback is allowed to be called any number of times greater than [count].
213 /// 213 ///
214 /// Both [id] and [reason] are optional and provide extra information about the 214 /// Both [id] and [reason] are optional and provide extra information about the
(...skipping 10 matching lines...) Expand all
225 /// true will the callback be considered complete. [callback] may take up to six 225 /// true will the callback be considered complete. [callback] may take up to six
226 /// optional or required positional arguments; named arguments are not 226 /// optional or required positional arguments; named arguments are not
227 /// supported. 227 /// supported.
228 /// 228 ///
229 /// Both [id] and [reason] are optional and provide extra information about the 229 /// Both [id] and [reason] are optional and provide extra information about the
230 /// callback when debugging. [id] should be the name of the callback, while 230 /// callback when debugging. [id] should be the name of the callback, while
231 /// [reason] should be the reason the callback is expected to be called. 231 /// [reason] should be the reason the callback is expected to be called.
232 Function expectAsyncUntil(Function callback, bool isDone(), 232 Function expectAsyncUntil(Function callback, bool isDone(),
233 {String id, String reason}) => new _ExpectedFunction(callback, 0, -1, 233 {String id, String reason}) => new _ExpectedFunction(callback, 0, -1,
234 id: id, reason: reason, isDone: isDone).func; 234 id: id, reason: reason, isDone: isDone).func;
OLDNEW
« no previous file with comments | « lib/src/frontend/expect.dart ('k') | lib/src/frontend/future_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698