Chromium Code Reviews| 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 // TODO(rnystrom): This code is gradually moving from a Java/JUnit style to | 5 // TODO(rnystrom): This code is gradually moving from a Java/JUnit style to |
| 6 // something closer to JS/Jasmine. Eventually, the UnitTestSuite class can go | 6 // something closer to JS/Jasmine. Eventually, the UnitTestSuite class can go |
| 7 // away completely (or become private to this library) and the only exposed API | 7 // away completely (or become private to this library) and the only exposed API |
| 8 // will be group()/test()/expect(). Until then, both ways are supported, which | 8 // will be group()/test()/expect(). Until then, both ways are supported, which |
| 9 // is why things look a bit weird in here. | 9 // is why things look a bit weird in here. |
| 10 | 10 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 final testCase = new TestCase( | 298 final testCase = new TestCase( |
| 299 _currentSuite._tests.length + 1, _fullSpec(spec), body, callbacks); | 299 _currentSuite._tests.length + 1, _fullSpec(spec), body, callbacks); |
| 300 _currentSuite._tests.add(testCase); | 300 _currentSuite._tests.add(testCase); |
| 301 | 301 |
| 302 if (callbacks < 1) { | 302 if (callbacks < 1) { |
| 303 testCase.recordError( | 303 testCase.recordError( |
| 304 'Async tests must wait for at least one callback ', ''); | 304 'Async tests must wait for at least one callback ', ''); |
| 305 } | 305 } |
| 306 } | 306 } |
| 307 | 307 |
| 308 void serialInvokeAsync(List closures) { | |
| 309 final length = closures.length; | |
| 310 if (length > 0) { | |
|
nweiz
2011/10/28 03:58:38
Style nit: if (length == 0) return;
Jacob
2011/10/31 22:09:50
For this case i think the code is slightly easier
| |
| 311 int i = 0; | |
| 312 void invokeNext() { | |
| 313 closures[i](); | |
| 314 i++; | |
| 315 if (i < length) { | |
| 316 window.setTimeout(invokeNext, 0); | |
| 317 } | |
| 318 } | |
| 319 window.setTimeout(invokeNext, 0); | |
| 320 } | |
| 321 } | |
| 322 | |
| 308 /** | 323 /** |
| 309 * Creates a new named group of tests. Calls to group() or test() within the | 324 * Creates a new named group of tests. Calls to group() or test() within the |
| 310 * body of the function passed to this will inherit this group's description. | 325 * body of the function passed to this will inherit this group's description. |
| 311 */ | 326 */ |
| 312 void group(String description, void body()) { | 327 void group(String description, void body()) { |
| 313 _ensureActiveSuite(); | 328 _ensureActiveSuite(); |
| 314 | 329 |
| 315 // Concatenate the new group. | 330 // Concatenate the new group. |
| 316 final oldGroup = _currentGroup; | 331 final oldGroup = _currentGroup; |
| 317 if (_currentGroup != '') { | 332 if (_currentGroup != '') { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 </tr>"""; | 539 </tr>"""; |
| 525 if (stackTrace != null) { | 540 if (stackTrace != null) { |
| 526 message += | 541 message += |
| 527 "<tr><td></td><td colspan='2'><pre>${stackTrace}</pre></td></tr>"; | 542 "<tr><td></td><td colspan='2'><pre>${stackTrace}</pre></td></tr>"; |
| 528 } | 543 } |
| 529 fail = true; | 544 fail = true; |
| 530 } | 545 } |
| 531 } | 546 } |
| 532 | 547 |
| 533 typedef void TestFunction(); | 548 typedef void TestFunction(); |
| OLD | NEW |