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

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

Issue 2099503002: Add a dedicated Result for skipped tests. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 6 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/backend/state.dart ('k') | lib/src/runner/engine.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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import '../backend/invoker.dart'; 7 import '../backend/invoker.dart';
8 import '../backend/state.dart';
9 import 'expect.dart'; 8 import 'expect.dart';
10 9
11 /// An object used to detect unpassed arguments. 10 /// An object used to detect unpassed arguments.
12 const _PLACEHOLDER = const Object(); 11 const _PLACEHOLDER = const Object();
13 12
14 // Functions used to check how many arguments a callback takes. 13 // Functions used to check how many arguments a callback takes.
15 typedef _Func0(); 14 typedef _Func0();
16 typedef _Func1(a); 15 typedef _Func1(a);
17 typedef _Func2(a, b); 16 typedef _Func2(a, b);
18 typedef _Func3(a, b, c); 17 typedef _Func3(a, b, c);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 a3 = _PLACEHOLDER, a4 = _PLACEHOLDER, a5 = _PLACEHOLDER]) => 162 a3 = _PLACEHOLDER, a4 = _PLACEHOLDER, a5 = _PLACEHOLDER]) =>
164 _run([a0, a1, a2, a3, a4, a5].where((a) => a != _PLACEHOLDER)); 163 _run([a0, a1, a2, a3, a4, a5].where((a) => a != _PLACEHOLDER));
165 164
166 /// Runs the wrapped function with [args] and returns its return value. 165 /// Runs the wrapped function with [args] and returns its return value.
167 _run(Iterable args) { 166 _run(Iterable args) {
168 // Note that in the old test, this returned `null` if it encountered an 167 // Note that in the old test, this returned `null` if it encountered an
169 // error, where now it just re-throws that error because Zone machinery will 168 // error, where now it just re-throws that error because Zone machinery will
170 // pass it to the invoker anyway. 169 // pass it to the invoker anyway.
171 try { 170 try {
172 _actualCalls++; 171 _actualCalls++;
173 if (_invoker.liveTest.isComplete && 172 if (_invoker.liveTest.state.shouldBeDone) {
174 _invoker.liveTest.state.result == Result.success) {
175 throw 'Callback ${_id}called ($_actualCalls) after test case ' 173 throw 'Callback ${_id}called ($_actualCalls) after test case '
176 '${_invoker.liveTest.test.name} had already completed.$_reason'; 174 '${_invoker.liveTest.test.name} had already completed.$_reason';
177 } else if (_maxExpectedCalls >= 0 && _actualCalls > _maxExpectedCalls) { 175 } else if (_maxExpectedCalls >= 0 && _actualCalls > _maxExpectedCalls) {
178 throw new TestFailure('Callback ${_id}called more times than expected ' 176 throw new TestFailure('Callback ${_id}called more times than expected '
179 '($_maxExpectedCalls).$_reason'); 177 '($_maxExpectedCalls).$_reason');
180 } 178 }
181 179
182 return Function.apply(_callback, args.toList()); 180 return Function.apply(_callback, args.toList());
183 } catch (error, stackTrace) { 181 } catch (error, stackTrace) {
184 _zone.handleUncaughtError(error, stackTrace); 182 _zone.handleUncaughtError(error, stackTrace);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 Function expectAsyncUntil(Function callback, bool isDone(), 239 Function expectAsyncUntil(Function callback, bool isDone(),
242 {String id, String reason}) { 240 {String id, String reason}) {
243 if (Invoker.current == null) { 241 if (Invoker.current == null) {
244 throw new StateError( 242 throw new StateError(
245 "expectAsyncUntil() may only be called within a test."); 243 "expectAsyncUntil() may only be called within a test.");
246 } 244 }
247 245
248 return new _ExpectedFunction(callback, 0, -1, 246 return new _ExpectedFunction(callback, 0, -1,
249 id: id, reason: reason, isDone: isDone).func; 247 id: id, reason: reason, isDone: isDone).func;
250 } 248 }
OLDNEW
« no previous file with comments | « lib/src/backend/state.dart ('k') | lib/src/runner/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698