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 {'description': 'successful', 'result': 'pass',}, | |
69 { | |
70 'description': 'fail1', | |
71 'message': 'Expected: <false>\n' ' Actual: <true>\n' '', | |
72 'result': 'fail', | |
73 }, | |
74 { | |
75 'description': 'error1', | |
76 'message': 'Callback called more times than expected (1).', | |
77 'result': 'fail', | |
78 }, | |
79 {'description': 'fail2', 'message': 'failure', 'result': 'fail',}, | |
80 { | |
81 'description': 'error2', | |
82 'message': 'Callback called more times than expected (1).', | |
83 'result': 'fail', | |
84 }, | |
85 {'description': 'foo6', 'result': 'pass',} | |
86 ]); | |
87 } | |
OLD | NEW |