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

Side by Side Diff: client/testing/unittest/unittestsuite.dart

Issue 8363040: Implement measurement using futures (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: take2 Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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
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) {
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
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();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698