| OLD | NEW |
| 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 /** | 7 /** |
| 8 * Represents the state for an individual unit test. | 8 * Represents the state for an individual unit test. |
| 9 * | 9 * |
| 10 * Create by calling [test] or [solo_test]. | 10 * Create by calling [test] or [solo_test]. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 Future _runTest() { | 76 Future _runTest() { |
| 77 _prepTest(); | 77 _prepTest(); |
| 78 // Increment/decrement callbackFunctionsOutstanding to prevent | 78 // Increment/decrement callbackFunctionsOutstanding to prevent |
| 79 // synchronous 'async' callbacks from causing the test to be | 79 // synchronous 'async' callbacks from causing the test to be |
| 80 // marked as complete before the body is completely executed. | 80 // marked as complete before the body is completely executed. |
| 81 ++_callbackFunctionsOutstanding; | 81 ++_callbackFunctionsOutstanding; |
| 82 var f = testFunction(); | 82 var f = testFunction(); |
| 83 --_callbackFunctionsOutstanding; | 83 --_callbackFunctionsOutstanding; |
| 84 if (f is Future) { | 84 if (f is Future) { |
| 85 f.then((_) => _finishTest()) | 85 return f.then((_) => _finishTest()) |
| 86 .catchError((e) => fail("${e.error}")); | 86 .catchError((e) => fail("${e.error}")); |
| 87 return f; | |
| 88 } else { | 87 } else { |
| 89 _finishTest(); | 88 _finishTest(); |
| 90 return null; | 89 return null; |
| 91 } | 90 } |
| 92 } | 91 } |
| 93 | 92 |
| 94 void _finishTest() { | 93 void _finishTest() { |
| 95 if (result == null && _callbackFunctionsOutstanding == 0) { | 94 if (result == null && _callbackFunctionsOutstanding == 0) { |
| 96 pass(); | 95 pass(); |
| 97 } | 96 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 void error(String messageText, [String stack = '']) { | 202 void error(String messageText, [String stack = '']) { |
| 204 _complete(ERROR, messageText, stack); | 203 _complete(ERROR, messageText, stack); |
| 205 } | 204 } |
| 206 | 205 |
| 207 void _markCallbackComplete() { | 206 void _markCallbackComplete() { |
| 208 if (--_callbackFunctionsOutstanding == 0 && !isComplete) { | 207 if (--_callbackFunctionsOutstanding == 0 && !isComplete) { |
| 209 pass(); | 208 pass(); |
| 210 } | 209 } |
| 211 } | 210 } |
| 212 } | 211 } |
| OLD | NEW |