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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/lib/src/group_context.dart
diff --git a/pkg/unittest/lib/src/group_context.dart b/pkg/unittest/lib/src/group_context.dart
new file mode 100644
index 0000000000000000000000000000000000000000..668fb4749d1af00c082237acf83c095c4d53bce6
--- /dev/null
+++ b/pkg/unittest/lib/src/group_context.dart
@@ -0,0 +1,67 @@
+part of unittest;
+
+/**
+ * Setup and teardown functions for a group and its parents, the latter
+ * for chaining.
+ */
+class _GroupContext {
+ final _GroupContext parent;
+
+ /** Description text of the current test group. */
+ final String _name;
+
+ /** Setup function called before each test in a group. */
+ Function _testSetup;
+
+ get testSetup => _testSetup;
+
+ get parentSetup => (parent == null) ? null : parent.testSetup;
+
+ set testSetup(Function setup) {
+ var preSetup = parentSetup;
+ if (preSetup == null) {
+ _testSetup = setup;
+ } else {
+ _testSetup = () {
+ var f = preSetup();
+ if (f is Future) {
+ return f.then((_) => setup());
+ } else {
+ return setup();
+ }
+ };
+ }
+ }
+
+ /** Teardown function called after each test in a group. */
+ Function _testTeardown;
+
+ get testTeardown => _testTeardown;
+
+ get parentTeardown => (parent == null) ? null : parent.testTeardown;
+
+ set testTeardown(Function teardown) {
+ var postTeardown = parentTeardown;
+ if (postTeardown == null) {
+ _testTeardown = teardown;
+ } else {
+ _testTeardown = () {
+ var f = teardown();
+ if (f is Future) {
+ return f.then((_) => postTeardown());
+ } else {
+ return postTeardown();
+ }
+ };
+ }
+ }
+
+ String get fullName => (parent == null || parent == _rootContext)
+ ? _name
+ : "${parent.fullName}$groupSep$_name";
+
+ _GroupContext([this.parent, this._name = '']) {
+ _testSetup = parentSetup;
+ _testTeardown = parentTeardown;
+ }
+}
« 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