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

Side by Side Diff: pkg/scheduled_test/test/scheduled_test_test.dart

Issue 12208116: Roll back r18349. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « pkg/scheduled_test/lib/src/schedule.dart ('k') | no next file » | 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 library scheduled_test_test; 5 library scheduled_test_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:scheduled_test/scheduled_test.dart'; 9 import 'package:scheduled_test/scheduled_test.dart';
10 import 'package:scheduled_test/src/utils.dart'; 10 import 'package:scheduled_test/src/utils.dart';
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 }); 286 });
287 287
288 sleep(50).then(wrapAsync((_) => expect('foo', equals('bar')))); 288 sleep(50).then(wrapAsync((_) => expect('foo', equals('bar'))));
289 }); 289 });
290 290
291 test('test 2', () { 291 test('test 2', () {
292 expect(onCompleteRun, isTrue); 292 expect(onCompleteRun, isTrue);
293 }); 293 });
294 }, passing: ['test 2']); 294 }, passing: ['test 2']);
295 295
296 expectTestsPass('currentSchedule.errors contains the error in the onComplete ' 296 expectTestsPass('currentSchedule.error contains the error in the onComplete '
297 'queue', () { 297 'queue', () {
298 var errors; 298 var error;
299 test('test 1', () { 299 test('test 1', () {
300 currentSchedule.onComplete.schedule(() { 300 currentSchedule.onComplete.schedule(() {
301 errors = currentSchedule.errors; 301 error = currentSchedule.error;
302 }); 302 });
303 303
304 throw 'error'; 304 throw 'error';
305 }); 305 });
306 306
307 test('test 2', () { 307 test('test 2', () {
308 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 308 expect(error, new isInstanceOf<ScheduleError>());
309 expect(errors.map((e) => e.error), equals(['error'])); 309 expect(error.error, equals('error'));
310 }); 310 });
311 }, passing: ['test 2']); 311 }, passing: ['test 2']);
312 312
313 expectTestsPass('onComplete tasks can be scheduled during normal tasks', () { 313 expectTestsPass('onComplete tasks can be scheduled during normal tasks', () {
314 var onCompleteRun = false; 314 var onCompleteRun = false;
315 test('test 1', () { 315 test('test 1', () {
316 schedule(() { 316 schedule(() {
317 currentSchedule.onComplete.schedule(() { 317 currentSchedule.onComplete.schedule(() {
318 onCompleteRun = true; 318 onCompleteRun = true;
319 }); 319 });
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 }); 388 });
389 389
390 sleep(50).then(wrapAsync((_) => expect('foo', equals('bar')))); 390 sleep(50).then(wrapAsync((_) => expect('foo', equals('bar'))));
391 }); 391 });
392 392
393 test('test 2', () { 393 test('test 2', () {
394 expect(onExceptionRun, isTrue); 394 expect(onExceptionRun, isTrue);
395 }); 395 });
396 }, passing: ['test 2']); 396 }, passing: ['test 2']);
397 397
398 expectTestsPass('currentSchedule.errors contains the error in the ' 398 expectTestsPass('currentSchedule.error contains the error in the onException '
399 'onException queue', () { 399 'queue', () {
400 var errors; 400 var error;
401 test('test 1', () { 401 test('test 1', () {
402 currentSchedule.onException.schedule(() { 402 currentSchedule.onException.schedule(() {
403 errors = currentSchedule.errors; 403 error = currentSchedule.error;
404 }); 404 });
405 405
406 throw 'error'; 406 throw 'error';
407 }); 407 });
408 408
409 test('test 2', () { 409 test('test 2', () {
410 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 410 expect(error, new isInstanceOf<ScheduleError>());
411 expect(errors.map((e) => e.error), equals(['error'])); 411 expect(error.error, equals('error'));
412 }); 412 });
413 }, passing: ['test 2']); 413 }, passing: ['test 2']);
414 414
415 expectTestsPass('currentSchedule.errors contains an error passed into ' 415 expectTestsPass('currentSchedule.error contains an error passed into '
416 'signalError synchronously', () { 416 'signalError synchronously', () {
417 var errors; 417 var error;
418 test('test 1', () { 418 test('test 1', () {
419 currentSchedule.onException.schedule(() { 419 currentSchedule.onException.schedule(() {
420 errors = currentSchedule.errors; 420 error = currentSchedule.error;
421 }); 421 });
422 422
423 currentSchedule.signalError('error'); 423 currentSchedule.signalError('error');
424 }); 424 });
425 425
426 test('test 2', () { 426 test('test 2', () {
427 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 427 expect(error, new isInstanceOf<ScheduleError>());
428 expect(errors.map((e) => e.error), equals(['error'])); 428 expect(error.error, equals('error'));
429 }); 429 });
430 }, passing: ['test 2']); 430 }, passing: ['test 2']);
431 431
432 expectTestsPass('currentSchedule.errors contains an error passed into ' 432 expectTestsPass('currentSchedule.error contains an error passed into '
433 'signalError asynchronously', () { 433 'signalError asynchronously', () {
434 var errors; 434 var error;
435 test('test 1', () { 435 test('test 1', () {
436 currentSchedule.onException.schedule(() { 436 currentSchedule.onException.schedule(() {
437 errors = currentSchedule.errors; 437 error = currentSchedule.error;
438 }); 438 });
439 439
440 schedule(() => currentSchedule.signalError('error')); 440 schedule(() => currentSchedule.signalError('error'));
441 }); 441 });
442 442
443 test('test 2', () { 443 test('test 2', () {
444 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 444 expect(error, new isInstanceOf<ScheduleError>());
445 expect(errors.map((e) => e.error), equals(['error'])); 445 expect(error.error, equals('error'));
446 }); 446 });
447 }, passing: ['test 2']); 447 }, passing: ['test 2']);
448 448
449 expectTestsPass('currentSchedule.errors contains an error passed into ' 449 expectTestsPass('currentSchedule.error contains an error passed into '
450 'signalError out-of-band', () { 450 'signalError out-of-band', () {
451 var errors; 451 var error;
452 test('test 1', () { 452 test('test 1', () {
453 currentSchedule.onException.schedule(() { 453 currentSchedule.onException.schedule(() {
454 errors = currentSchedule.errors; 454 error = currentSchedule.error;
455 }); 455 });
456 456
457 sleep(50).then(wrapAsync((_) => currentSchedule.signalError('error'))); 457 sleep(50).then(wrapAsync((_) => currentSchedule.signalError('error')));
458 }); 458 });
459 459
460 test('test 2', () { 460 test('test 2', () {
461 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 461 expect(error, new isInstanceOf<ScheduleError>());
462 expect(errors.map((e) => e.error), equals(['error'])); 462 expect(error.error, equals('error'));
463 }); 463 });
464 }, passing: ['test 2']); 464 }, passing: ['test 2']);
465 465
466 expectTestsPass('currentSchedule.errors contains errors from both the task '
467 'queue and the onException queue in onComplete', () {
468 var errors;
469 test('test 1', () {
470 currentSchedule.onComplete.schedule(() {
471 errors = currentSchedule.errors;
472 });
473
474 currentSchedule.onException.schedule(() {
475 throw 'error2';
476 });
477
478 throw 'error1';
479 });
480
481 test('test 2', () {
482 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
483 expect(errors.map((e) => e.error), equals(['error1', 'error2']));
484 });
485 }, passing: ['test 2']);
486
487 expectTestsPass('currentSchedule.errors contains multiple out-of-band errors '
488 'from both the main task queue and onException in onComplete', () {
489 var errors;
490 test('test 1', () {
491 currentSchedule.onComplete.schedule(() {
492 errors = currentSchedule.errors;
493 });
494
495 currentSchedule.onException.schedule(() {
496 sleep(25).then(wrapAsync((_) {
497 throw 'error3';
498 }));
499 sleep(50).then(wrapAsync((_) {
500 throw 'error4';
501 }));
502 });
503
504 sleep(25).then(wrapAsync((_) {
505 throw 'error1';
506 }));
507 sleep(50).then(wrapAsync((_) {
508 throw 'error2';
509 }));
510 });
511
512 test('test 2', () {
513 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
514 expect(errors.map((e) => e.error),
515 orderedEquals(['error1', 'error2', 'error3', 'error4']));
516 });
517 }, passing: ['test 2']);
518
519 expectTestsPass('currentSchedule.errors contains both an out-of-band error '
520 'and an error raised afterwards in a task', () {
521 var errors;
522 test('test 1', () {
523 currentSchedule.onComplete.schedule(() {
524 errors = currentSchedule.errors;
525 });
526
527 sleep(25).then(wrapAsync((_) {
528 throw 'out-of-band';
529 }));
530
531 schedule(() => sleep(50).then((_) {
532 throw 'in-band';
533 }));
534 });
535
536 test('test 2', () {
537 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
538 expect(errors.map((e) => e.error), equals(['out-of-band', 'in-band']));
539 });
540 }, passing: ['test 2']);
541
542 expectTestsPass('currentSchedule.currentTask returns the current task while ' 466 expectTestsPass('currentSchedule.currentTask returns the current task while '
543 'executing a task', () { 467 'executing a task', () {
544 test('test', () { 468 test('test', () {
545 schedule(() => expect('foo', equals('foo')), 'task 1'); 469 schedule(() => expect('foo', equals('foo')), 'task 1');
546 470
547 schedule(() { 471 schedule(() {
548 expect(currentSchedule.currentTask.description, equals('task 2')); 472 expect(currentSchedule.currentTask.description, equals('task 2'));
549 }, 'task 2'); 473 }, 'task 2');
550 474
551 schedule(() => expect('bar', equals('bar')), 'task 3'); 475 schedule(() => expect('bar', equals('bar')), 'task 3');
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 }); 635 });
712 }); 636 });
713 637
714 group('group 2', () { 638 group('group 2', () {
715 test('test 2', () { 639 test('test 2', () {
716 expect(setUpRun, isFalse); 640 expect(setUpRun, isFalse);
717 }); 641 });
718 }); 642 });
719 }); 643 });
720 } 644 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/src/schedule.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698