| OLD | NEW |
| (Empty) |
| 1 part of unittest; | |
| 2 | |
| 3 /// Setup and teardown functions for a group and its parents, the latter | |
| 4 /// for chaining. | |
| 5 class _GroupContext { | |
| 6 final _GroupContext parent; | |
| 7 | |
| 8 /// Description text of the current test group. | |
| 9 final String _name; | |
| 10 | |
| 11 /// Setup function called before each test in a group. | |
| 12 Function _testSetup; | |
| 13 | |
| 14 get testSetup => _testSetup; | |
| 15 | |
| 16 get parentSetup => (parent == null) ? null : parent.testSetup; | |
| 17 | |
| 18 set testSetup(Function setup) { | |
| 19 var preSetup = parentSetup; | |
| 20 if (preSetup == null) { | |
| 21 _testSetup = setup; | |
| 22 } else { | |
| 23 _testSetup = () { | |
| 24 var f = preSetup(); | |
| 25 if (f is Future) { | |
| 26 return f.then((_) => setup()); | |
| 27 } else { | |
| 28 return setup(); | |
| 29 } | |
| 30 }; | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 /// Teardown function called after each test in a group. | |
| 35 Function _testTeardown; | |
| 36 | |
| 37 get testTeardown => _testTeardown; | |
| 38 | |
| 39 get parentTeardown => (parent == null) ? null : parent.testTeardown; | |
| 40 | |
| 41 set testTeardown(Function teardown) { | |
| 42 var postTeardown = parentTeardown; | |
| 43 if (postTeardown == null) { | |
| 44 _testTeardown = teardown; | |
| 45 } else { | |
| 46 _testTeardown = () { | |
| 47 var f = teardown(); | |
| 48 if (f is Future) { | |
| 49 return f.then((_) => postTeardown()); | |
| 50 } else { | |
| 51 return postTeardown(); | |
| 52 } | |
| 53 }; | |
| 54 } | |
| 55 } | |
| 56 | |
| 57 String get fullName => (parent == null || parent == _environment.rootContext) | |
| 58 ? _name | |
| 59 : "${parent.fullName}$groupSep$_name"; | |
| 60 | |
| 61 _GroupContext([this.parent, this._name = '']) { | |
| 62 _testSetup = parentSetup; | |
| 63 _testTeardown = parentTeardown; | |
| 64 } | |
| 65 } | |
| OLD | NEW |