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_using_runasync_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('test returning future using scheduleMicrotask', () { | |
18 test("successful", () { | |
19 return new Future.sync(() { | |
20 scheduleMicrotask(() { | |
21 expect(true, true); | |
22 }); | |
23 }); | |
24 }); | |
25 test("fail1", () { | |
26 var callback = expectAsync(() {}); | |
27 return new Future.sync(() { | |
28 scheduleMicrotask(() { | |
29 expect(true, false); | |
30 callback(); | |
31 }); | |
32 }); | |
33 }); | |
34 test('error1', () { | |
35 var callback = expectAsync(() {}); | |
36 var excesscallback = expectAsync(() {}); | |
37 return new Future.sync(() { | |
38 scheduleMicrotask(() { | |
39 excesscallback(); | |
40 excesscallback(); | |
41 callback(); | |
42 }); | |
43 }); | |
44 }); | |
45 test("fail2", () { | |
46 var callback = expectAsync(() {}); | |
47 return new Future.sync(() { | |
48 scheduleMicrotask(() { | |
49 fail('failure'); | |
50 callback(); | |
51 }); | |
52 }); | |
53 }); | |
54 test('error2', () { | |
55 var callback = expectAsync(() {}); | |
56 var excesscallback = expectAsync(() {}); | |
57 return new Future.sync(() { | |
58 scheduleMicrotask(() { | |
59 excesscallback(); | |
60 excesscallback(); | |
61 excesscallback(); | |
62 callback(); | |
63 }); | |
64 }); | |
65 }); | |
66 test('foo6', () { | |
67 }); | |
68 }, [{ | |
69 'description': 'successful', | |
70 'result': 'pass', | |
71 }, { | |
72 'description': 'fail1', | |
73 'message': 'Expected: <false>\n' ' Actual: <true>\n' '', | |
74 'result': 'fail', | |
75 }, { | |
76 'description': 'error1', | |
77 'message': 'Callback called more times than expected (1).', | |
78 'result': 'fail', | |
79 }, { | |
80 'description': 'fail2', | |
81 'message': 'failure', | |
82 'result': 'fail', | |
83 }, { | |
84 'description': 'error2', | |
85 'message': 'Callback called more times than expected (1).', | |
86 'result': 'fail', | |
87 }, { | |
88 'description': 'foo6', | |
89 'result': 'pass', | |
90 }]); | |
91 } | |
OLD | NEW |