Merge pull request #10 from dart-lang/failingTest-fail-when-pass

Fail @failingTest when the test passes.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 59b2b00..6e5b851 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog
 
+## 0.1.3
+
+- Fix `@failingTest` to fail when the test passes.
+
 ## 0.1.2
 
 - Update the pubspec `dependencies` section to include `package:test`
diff --git a/lib/test_reflective_loader.dart b/lib/test_reflective_loader.dart
index c833e61..9ebaf84 100644
--- a/lib/test_reflective_loader.dart
+++ b/lib/test_reflective_loader.dart
@@ -226,14 +226,24 @@
  * - An exception is thrown to the zone handler from a timer task.
  */
 Future _runFailingTest(ClassMirror classMirror, Symbol symbol) {
+  bool passed = false;
   return runZoned(() {
     return new Future.sync(() => _runTest(classMirror, symbol)).then((_) {
+      passed = true;
       test_package.fail('Test passed - expected to fail.');
     }).catchError((e) {
-      // an exception is not a failure for _runFailingTest
+      // if passed, and we call fail(), rethrow this exception
+      if (passed) {
+        throw e;
+      }
+      // otherwise, an exception is not a failure for _runFailingTest
     });
   }, onError: (e) {
-    // an exception is not a failure for _runFailingTest
+    // if passed, and we call fail(), rethrow this exception
+    if (passed) {
+      throw e;
+    }
+    // otherwise, an exception is not a failure for _runFailingTest
   });
 }
 
diff --git a/pubspec.yaml b/pubspec.yaml
index 73e6d63..1360d68 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
 name: test_reflective_loader
-version: 0.1.2
+version: 0.1.3
 description: Support for discovering tests and test suites using reflection.
 author: Dart Team <misc@dartlang.org>
 homepage: https://github.com/dart-lang/test_reflective_loader