Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: pkg/unittest/lib/src/group_context.dart

Issue 149573006: pkg/unittest: more lock-down, cleanup (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fighting cl Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 part of unittest;
2
3 /**
4 * Setup and teardown functions for a group and its parents, the latter
5 * for chaining.
6 */
7 class _GroupContext {
8 final _GroupContext parent;
9
10 /** Description text of the current test group. */
11 final String _name;
12
13 /** Setup function called before each test in a group. */
14 Function _testSetup;
15
16 get testSetup => _testSetup;
17
18 get parentSetup => (parent == null) ? null : parent.testSetup;
19
20 set testSetup(Function setup) {
21 var preSetup = parentSetup;
22 if (preSetup == null) {
23 _testSetup = setup;
24 } else {
25 _testSetup = () {
26 var f = preSetup();
27 if (f is Future) {
28 return f.then((_) => setup());
29 } else {
30 return setup();
31 }
32 };
33 }
34 }
35
36 /** Teardown function called after each test in a group. */
37 Function _testTeardown;
38
39 get testTeardown => _testTeardown;
40
41 get parentTeardown => (parent == null) ? null : parent.testTeardown;
42
43 set testTeardown(Function teardown) {
44 var postTeardown = parentTeardown;
45 if (postTeardown == null) {
46 _testTeardown = teardown;
47 } else {
48 _testTeardown = () {
49 var f = teardown();
50 if (f is Future) {
51 return f.then((_) => postTeardown());
52 } else {
53 return postTeardown();
54 }
55 };
56 }
57 }
58
59 String get fullName => (parent == null || parent == _rootContext)
60 ? _name
61 : "${parent.fullName}$groupSep$_name";
62
63 _GroupContext([this.parent, this._name = '']) {
64 _testSetup = parentSetup;
65 _testTeardown = parentTeardown;
66 }
67 }
OLDNEW
« no previous file with comments | « pkg/unittest/lib/html_enhanced_config.dart ('k') | pkg/unittest/lib/src/spread_args_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698