| 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 import 'package:scheduled_test/scheduled_test.dart'; | 5 import 'package:scheduled_test/scheduled_test.dart'; |
| 6 import 'package:scheduled_test/src/mock_clock.dart' as mock_clock; | 6 import 'package:scheduled_test/src/mock_clock.dart' as mock_clock; |
| 7 | 7 |
| 8 import '../metatest.dart'; | 8 import '../metatest.dart'; |
| 9 import '../utils.dart'; | 9 import '../utils.dart'; |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 expectTestsPass("wrapFuture should return the value of the wrapped future", | 37 expectTestsPass("wrapFuture should return the value of the wrapped future", |
| 38 () { | 38 () { |
| 39 test('test', () { | 39 test('test', () { |
| 40 schedule(() { | 40 schedule(() { |
| 41 expect(wrapFuture(pumpEventQueue().then((_) => 'foo')), | 41 expect(wrapFuture(pumpEventQueue().then((_) => 'foo')), |
| 42 completion(equals('foo'))); | 42 completion(equals('foo'))); |
| 43 }); | 43 }); |
| 44 }); | 44 }); |
| 45 }); | 45 }); |
| 46 | 46 |
| 47 expectTestsPass("a returned future should be implicitly wrapped", |
| 48 () { |
| 49 test('test', () { |
| 50 var futureComplete = false; |
| 51 currentSchedule.onComplete.schedule(() => expect(futureComplete, isTrue)); |
| 52 |
| 53 return pumpEventQueue().then((_) => futureComplete = true); |
| 54 }); |
| 55 }); |
| 56 |
| 57 expectTestsPass("a returned future should not block the schedule", |
| 58 () { |
| 59 test('test', () { |
| 60 var futureComplete = false; |
| 61 schedule(() => expect(futureComplete, isFalse)); |
| 62 |
| 63 return pumpEventQueue().then((_) => futureComplete = true); |
| 64 }); |
| 65 }); |
| 66 |
| 47 expectTestsPass("wrapFuture should pass through the error of the wrapped " | 67 expectTestsPass("wrapFuture should pass through the error of the wrapped " |
| 48 "future", () { | 68 "future", () { |
| 49 var error; | 69 var error; |
| 50 test('test 1', () { | 70 test('test 1', () { |
| 51 schedule(() { | 71 schedule(() { |
| 52 wrapFuture(pumpEventQueue().then((_) { | 72 wrapFuture(pumpEventQueue().then((_) { |
| 53 throw 'error'; | 73 throw 'error'; |
| 54 })).catchError(wrapAsync((e) { | 74 })).catchError(wrapAsync((e) { |
| 55 error = e; | 75 error = e; |
| 56 })); | 76 })); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 74 throw 'error'; | 94 throw 'error'; |
| 75 })); | 95 })); |
| 76 }); | 96 }); |
| 77 | 97 |
| 78 test('test 2', () { | 98 test('test 2', () { |
| 79 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 99 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
| 80 expect(errors.map((e) => e.error), equals(['error'])); | 100 expect(errors.map((e) => e.error), equals(['error'])); |
| 81 }); | 101 }); |
| 82 }, passing: ['test 2']); | 102 }, passing: ['test 2']); |
| 83 } | 103 } |
| OLD | NEW |