| 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 library unittestTest; | 5 library unittest.returning_future_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'package:metatest/metatest.dart'; |
| 8 import 'dart:isolate'; | |
| 9 | |
| 10 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 11 | 9 |
| 12 part 'utils.dart'; | 10 import 'utils.dart'; |
| 13 | 11 |
| 14 var testName = 'test returning future'; | 12 void main() => initTests(_test); |
| 15 | 13 |
| 16 var testFunction = (_) { | 14 void _test(message) { |
| 17 test("successful", () { | 15 initMetatest(message); |
| 18 return _defer(() { | 16 |
| 19 expect(true, true); | 17 expectTestResults('returning futures', () { |
| 18 test("successful", () { |
| 19 return defer(() { |
| 20 expect(true, true); |
| 21 }); |
| 20 }); | 22 }); |
| 21 }); | 23 // We repeat the fail and error tests, because during development |
| 22 // We repeat the fail and error tests, because during development | 24 // I had a situation where either worked fine on their own, and |
| 23 // I had a situation where either worked fine on their own, and | 25 // error/fail worked, but fail/error would time out. |
| 24 // error/fail worked, but fail/error would time out. | 26 test("error1", () { |
| 25 test("error1", () { | 27 var callback = expectAsync(() {}); |
| 26 var callback = expectAsync(() {}); | 28 var excesscallback = expectAsync(() {}); |
| 27 var excesscallback = expectAsync(() {}); | 29 return defer(() { |
| 28 return _defer(() { | 30 excesscallback(); |
| 29 excesscallback(); | 31 excesscallback(); |
| 30 excesscallback(); | 32 excesscallback(); |
| 31 excesscallback(); | 33 callback(); |
| 32 callback(); | 34 }); |
| 33 }); | 35 }); |
| 34 }); | 36 test("fail1", () { |
| 35 test("fail1", () { | 37 return defer(() { |
| 36 return _defer(() { | 38 expect(true, false); |
| 37 expect(true, false); | 39 }); |
| 38 }); | 40 }); |
| 39 }); | 41 test("error2", () { |
| 40 test("error2", () { | 42 var callback = expectAsync(() {}); |
| 41 var callback = expectAsync(() {}); | 43 var excesscallback = expectAsync(() {}); |
| 42 var excesscallback = expectAsync(() {}); | 44 return defer(() { |
| 43 return _defer(() { | 45 excesscallback(); |
| 44 excesscallback(); | 46 excesscallback(); |
| 45 excesscallback(); | 47 callback(); |
| 46 callback(); | 48 }); |
| 47 }); | 49 }); |
| 48 }); | 50 test("fail2", () { |
| 49 test("fail2", () { | 51 return defer(() { |
| 50 return _defer(() { | 52 fail('failure'); |
| 51 fail('failure'); | 53 }); |
| 52 }); | 54 }); |
| 53 }); | 55 test('foo5', () { |
| 54 test('foo5', () { | 56 }); |
| 55 }); | 57 }, [{ |
| 56 }; | 58 'result': 'pass' |
| 57 | 59 }, { |
| 58 var expected = buildStatusString(2, 4, 0, | 60 'result': 'fail', |
| 59 'successful::' | 61 'message': 'Callback called more times than expected (1).' |
| 60 'error1:Callback called more times than expected (1).:' | 62 }, { |
| 61 'fail1:Expected: <false> Actual: <true>:' | 63 'result': 'fail', |
| 62 'error2:Callback called more times than expected (1).:' | 64 'message': 'Expected: <false>\n Actual: <true>\n' |
| 63 'fail2:failure:' | 65 }, { |
| 64 'foo5'); | 66 'result': 'fail', |
| 67 'message': 'Callback called more times than expected (1).' |
| 68 }, { |
| 69 'result': 'fail', |
| 70 'message': 'failure' |
| 71 }, { |
| 72 'result': 'pass' |
| 73 }]); |
| 74 } |
| OLD | NEW |