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

Unified Diff: pkg/unittest/test/unittest_test.dart

Issue 14092004: Chaining of setup/teardown. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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/unittest.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/test/unittest_test.dart
===================================================================
--- pkg/unittest/test/unittest_test.dart (revision 21816)
+++ pkg/unittest/test/unittest_test.dart (working copy)
@@ -68,6 +68,26 @@
}
}
+makeDelayedSetup(index, s) => () {
+ return new Future.delayed(new Duration(milliseconds:1), () {
+ s.write('l$index U ');
+ });
+};
+
+makeDelayedTeardown(index, s) => () {
+ return new Future.delayed(new Duration(milliseconds:1), () {
+ s.write('l$index D ');
+ });
+};
+
+makeImmediateSetup(index, s) => () {
+ s.write('l$index U ');
+};
+
+makeImmediateTeardown(index, s) => () {
+ s.write('l$index D ');
+};
+
runTest() {
port.receive((String testName, sendport) {
var testConfig = new TestConfiguration(sendport);
@@ -299,6 +319,31 @@
});
} else if (testName == 'runTests without tests') {
runTests();
+ } else if (testName == 'nested groups setup/teardown') {
+ StringBuffer s = new StringBuffer();
+ group('level 1', () {
+ setUp(makeDelayedSetup(1, s));
+ group('level 2', () {
+ setUp(makeImmediateSetup(2, s));
+ tearDown(makeDelayedTeardown(2, s));
+ group('level 3', () {
+ group('level 4', () {
+ setUp(makeDelayedSetup(4, s));
+ tearDown(makeImmediateTeardown(4, s));
+ group('level 5', () {
+ setUp(makeImmediateSetup(5, s));
+ group('level 6', () {
+ tearDown(makeDelayedTeardown(6, s));
+ test('inner', () {});
+ });
+ });
+ });
+ });
+ });
+ });
+ test('after nest', () {
+ expect(s.toString(), "l1 U l2 U l4 U l5 U l6 D l4 D l2 D ");
+ });
}
});
}
@@ -355,7 +400,10 @@
'foo6'),
'testCases immutable':
buildStatusString(1, 0, 0, 'testCases immutable'),
- 'runTests without tests': buildStatusString(0, 0, 0, null)
+ 'runTests without tests': buildStatusString(0, 0, 0, null),
+ 'nested groups setup/teardown':
+ buildStatusString(2, 0, 0,
+ 'level 1 level 2 level 3 level 4 level 5 level 6 inner::after nest')
};
tests.forEach((String name, String expected) {
« no previous file with comments | « pkg/unittest/lib/unittest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698