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

Side by Side Diff: lib/src/test_case.dart

Issue 846143003: Reformatted code (Closed) Base URL: https://github.com/dart-lang/unittest.git@master
Patch Set: Created 5 years, 11 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/spread_args_helper.dart ('k') | lib/src/utils.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 unittest; 5 part of unittest;
6 6
7 /// Represents the state for an individual unit test. 7 /// Represents the state for an individual unit test.
8 /// 8 ///
9 /// Create by calling [test] or [solo_test]. 9 /// Create by calling [test] or [solo_test].
10 class TestCase { 10 class TestCase {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (result != null) return new Future.value(); 97 if (result != null) return new Future.value();
98 _config.onTestStart(this); 98 _config.onTestStart(this);
99 _startTime = new DateTime.now(); 99 _startTime = new DateTime.now();
100 _runningTime = null; 100 _runningTime = null;
101 ++_callbackFunctionsOutstanding; 101 ++_callbackFunctionsOutstanding;
102 var testReturn = _testFunction(); 102 var testReturn = _testFunction();
103 // If _testFunction() returned a future, we want to wait for it like we 103 // If _testFunction() returned a future, we want to wait for it like we
104 // would a callback, so if a failure occurs while waiting, we can abort. 104 // would a callback, so if a failure occurs while waiting, we can abort.
105 if (testReturn is Future) { 105 if (testReturn is Future) {
106 ++_callbackFunctionsOutstanding; 106 ++_callbackFunctionsOutstanding;
107 testReturn.catchError(_errorHandler('Test')) 107 testReturn
108 .catchError(_errorHandler('Test'))
108 .whenComplete(_markCallbackComplete); 109 .whenComplete(_markCallbackComplete);
109 } 110 }
110 }).catchError(_errorHandler('Test')).then((_) { 111 }).catchError(_errorHandler('Test')).then((_) {
111 _markCallbackComplete(); 112 _markCallbackComplete();
112 if (result == null) { 113 if (result == null) {
113 // Outstanding callbacks exist; we need to return a Future. 114 // Outstanding callbacks exist; we need to return a Future.
114 _testComplete = new Completer(); 115 _testComplete = new Completer();
115 return _testComplete.future.whenComplete(() { 116 return _testComplete.future.whenComplete(() {
116 if (_tearDown != null) { 117 if (_tearDown != null) {
117 return _tearDown(); 118 return _tearDown();
(...skipping 17 matching lines...) Expand all
135 if (_stackTrace == null) _stackTrace = stack; 136 if (_stackTrace == null) _stackTrace = stack;
136 if (result == null) { 137 if (result == null) {
137 _result = testResult; 138 _result = testResult;
138 _config.onTestResult(this); 139 _config.onTestResult(this);
139 } else { 140 } else {
140 _result = testResult; 141 _result = testResult;
141 _config.onTestResultChanged(this); 142 _config.onTestResultChanged(this);
142 } 143 }
143 } 144 }
144 145
145 void _complete(String testResult, [String messageText = '', 146 void _complete(String testResult,
146 StackTrace stack]) { 147 [String messageText = '', StackTrace stack]) {
147 if (runningTime == null) { 148 if (runningTime == null) {
148 // The startTime can be `null` if an error happened during setup. In this 149 // The startTime can be `null` if an error happened during setup. In this
149 // case we simply report a running time of 0. 150 // case we simply report a running time of 0.
150 if (startTime != null) { 151 if (startTime != null) {
151 _runningTime = new DateTime.now().difference(startTime); 152 _runningTime = new DateTime.now().difference(startTime);
152 } else { 153 } else {
153 _runningTime = const Duration(seconds: 0); 154 _runningTime = const Duration(seconds: 0);
154 } 155 }
155 } 156 }
156 _setResult(testResult, messageText, stack); 157 _setResult(testResult, messageText, stack);
(...skipping 25 matching lines...) Expand all
182 } 183 }
183 184
184 void _markCallbackComplete() { 185 void _markCallbackComplete() {
185 if (--_callbackFunctionsOutstanding == 0 && !isComplete) { 186 if (--_callbackFunctionsOutstanding == 0 && !isComplete) {
186 _pass(); 187 _pass();
187 } 188 }
188 } 189 }
189 190
190 String toString() => _result != null ? "$description: $result" : description; 191 String toString() => _result != null ? "$description: $result" : description;
191 } 192 }
OLDNEW
« no previous file with comments | « lib/src/spread_args_helper.dart ('k') | lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698