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