| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** | 5 /** |
| 6 * Description text of the current test group. If multiple groups are nested, | 6 * Description text of the current test group. If multiple groups are nested, |
| 7 * this will contain all of their text concatenated. | 7 * this will contain all of their text concatenated. |
| 8 */ | 8 */ |
| 9 String _currentGroup = ''; | 9 String _currentGroup = ''; |
| 10 | 10 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 _platformDefer(() { | 153 _platformDefer(() { |
| 154 assert (_currentTest == 0); | 154 assert (_currentTest == 0); |
| 155 _nextBatch(); | 155 _nextBatch(); |
| 156 }); | 156 }); |
| 157 } | 157 } |
| 158 | 158 |
| 159 /** Runs a single test. */ | 159 /** Runs a single test. */ |
| 160 _runTest(TestCase testCase) { | 160 _runTest(TestCase testCase) { |
| 161 try { | 161 try { |
| 162 // TODO(sigmund): remove this declaration once dartc supports trapping error | |
| 163 // traces. | |
| 164 var trace = ''; | |
| 165 _callbacksCalled = 0; | 162 _callbacksCalled = 0; |
| 166 _state = _RUNNING_TEST; | 163 _state = _RUNNING_TEST; |
| 167 | 164 |
| 168 testCase.test(); | 165 testCase.test(); |
| 169 | 166 |
| 170 if (_state != _UNCAUGHT_ERROR) { | 167 if (_state != _UNCAUGHT_ERROR) { |
| 171 if (testCase.callbacks == _callbacksCalled) { | 168 if (testCase.callbacks == _callbacksCalled) { |
| 172 testCase.pass(); | 169 testCase.pass(); |
| 173 } | 170 } |
| 174 } | 171 } |
| 175 | 172 |
| 176 } catch (ExpectException e, var trace) { | 173 } catch (ExpectException e, var trace) { |
| 177 if (_state != _UNCAUGHT_ERROR) { | 174 if (_state != _UNCAUGHT_ERROR) { |
| 178 testCase.fail(e.message, trace.toString()); | 175 //TODO(pquitslund) remove guard once dartc reliably propagates traces |
| 176 testCase.fail(e.message, trace == null ? '' : trace.toString()); |
| 179 } | 177 } |
| 180 } catch (var e, var trace) { | 178 } catch (var e, var trace) { |
| 181 if (_state != _UNCAUGHT_ERROR) { | 179 if (_state != _UNCAUGHT_ERROR) { |
| 182 testCase.error('Caught ${e}', trace.toString()); | 180 //TODO(pquitslund) remove guard once dartc reliably propagates traces |
| 181 testCase.error('Caught ${e}', trace == null ? '' : trace.toString()); |
| 183 } | 182 } |
| 184 } finally { | 183 } finally { |
| 185 _state = _READY; | 184 _state = _READY; |
| 186 } | 185 } |
| 187 } | 186 } |
| 188 | 187 |
| 189 /** | 188 /** |
| 190 * Runs a batch of tests, yielding whenever an asynchronous test starts | 189 * Runs a batch of tests, yielding whenever an asynchronous test starts |
| 191 * running. Tests will resume executing when such asynchronous test calls | 190 * running. Tests will resume executing when such asynchronous test calls |
| 192 * [done] or if it fails with an exception. | 191 * [done] or if it fails with an exception. |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 } | 343 } |
| 345 | 344 |
| 346 void error(String message, String stackTrace) { | 345 void error(String message, String stackTrace) { |
| 347 result = _ERROR; | 346 result = _ERROR; |
| 348 this.message = message; | 347 this.message = message; |
| 349 this.stackTrace = stackTrace; | 348 this.stackTrace = stackTrace; |
| 350 } | 349 } |
| 351 } | 350 } |
| 352 | 351 |
| 353 typedef void TestFunction(); | 352 typedef void TestFunction(); |
| OLD | NEW |