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

Unified Diff: pkg/analysis_testing/lib/reflective_tests.dart

Issue 393043005: Modify reflective tests to allow setUp and tearDown to return futures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_testing/lib/reflective_tests.dart
diff --git a/pkg/analysis_testing/lib/reflective_tests.dart b/pkg/analysis_testing/lib/reflective_tests.dart
index cdb617c82a5c94afdb709f178c90ff4954e7a8f7..2c737f7910d74df36c85d58208c30837eccd80af 100644
--- a/pkg/analysis_testing/lib/reflective_tests.dart
+++ b/pkg/analysis_testing/lib/reflective_tests.dart
@@ -66,34 +66,21 @@ void runReflectiveTests(Type type) {
_runTest(ClassMirror classMirror, Symbol symbol) {
InstanceMirror instanceMirror = classMirror.newInstance(new Symbol(''), []);
- bool shouldRunTearDown = true;
- _invokeSymbolIfExists(instanceMirror, #setUp);
- try {
- var testReturn = instanceMirror.invoke(symbol, []).reflectee;
- if (testReturn is Future) {
- shouldRunTearDown = false;
- return testReturn.whenComplete(() {
- _invokeTearDown(instanceMirror);
- });
- } else {
- return testReturn;
- }
- } finally {
- if (shouldRunTearDown) {
- _invokeTearDown(instanceMirror);
- }
- }
+ return _invokeSymbolIfExists(instanceMirror, #setUp).then(
+ (_) => instanceMirror.invoke(symbol, []).reflectee).whenComplete(
+ () => _invokeSymbolIfExists(instanceMirror, #tearDown));
}
-void _invokeTearDown(InstanceMirror instanceMirror) {
- _invokeSymbolIfExists(instanceMirror, #tearDown);
-}
-
-
-void _invokeSymbolIfExists(InstanceMirror instanceMirror, Symbol symbol) {
+Future _invokeSymbolIfExists(InstanceMirror instanceMirror, Symbol symbol) {
+ var invocationResult = null;
try {
- instanceMirror.invoke(symbol, []);
+ invocationResult = instanceMirror.invoke(symbol, []).reflectee;
} on NoSuchMethodError catch (e) {
}
+ if (invocationResult is Future) {
+ return invocationResult;
+ } else {
+ return new Future.value(invocationResult);
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698