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.nested_groups_setup_teardown_test; | |
6 | |
7 import 'dart:async'; | |
8 | |
9 import 'package:unittest/unittest.dart'; | |
10 | |
11 import 'package:metatest/metatest.dart'; | |
12 | |
13 void main() => initTests(_test); | |
14 | |
15 void _test(message) { | |
16 initMetatest(message); | |
17 | |
18 expectTestsPass('nested groups setup/teardown', () { | |
19 StringBuffer s = new StringBuffer(); | |
20 group('level 1', () { | |
21 setUp(makeDelayedSetup(1, s)); | |
22 group('level 2', () { | |
23 setUp(makeImmediateSetup(2, s)); | |
24 tearDown(makeDelayedTeardown(2, s)); | |
25 group('level 3', () { | |
26 group('level 4', () { | |
27 setUp(makeDelayedSetup(4, s)); | |
28 tearDown(makeImmediateTeardown(4, s)); | |
29 group('level 5', () { | |
30 setUp(makeImmediateSetup(5, s)); | |
31 group('level 6', () { | |
32 tearDown(makeDelayedTeardown(6, s)); | |
33 test('inner', () {}); | |
34 }); | |
35 }); | |
36 }); | |
37 }); | |
38 }); | |
39 }); | |
40 test('after nest', () { | |
41 expect(s.toString(), "l1 U l2 U l4 U l5 U l6 D l4 D l2 D "); | |
42 }); | |
43 }); | |
44 } | |
45 | |
46 | |
47 Function makeDelayedSetup(int index, StringBuffer s) => () { | |
48 return new Future.delayed(new Duration(milliseconds: 1), () { | |
49 s.write('l$index U '); | |
50 }); | |
51 }; | |
52 | |
53 Function makeDelayedTeardown(int index, StringBuffer s) => () { | |
54 return new Future.delayed(new Duration(milliseconds: 1), () { | |
55 s.write('l$index D '); | |
56 }); | |
57 }; | |
58 | |
59 Function makeImmediateSetup(int index, StringBuffer s) => () { | |
60 s.write('l$index U '); | |
61 }; | |
62 | |
63 Function makeImmediateTeardown(int index, StringBuffer s) => () { | |
64 s.write('l$index D '); | |
65 }; | |
OLD | NEW |