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