Index: pkg/testing/lib/src/chain.dart |
diff --git a/pkg/testing/lib/src/chain.dart b/pkg/testing/lib/src/chain.dart |
index 4d7063cc2079805f9aa670db1b4c9d05db0f0ceb..1dcd538b4c665fd38a4c4cfb4fee80a561bdb434 100644 |
--- a/pkg/testing/lib/src/chain.dart |
+++ b/pkg/testing/lib/src/chain.dart |
@@ -196,7 +196,8 @@ abstract class ChainContext { |
} |
if (description.multitestExpectations != null) { |
if (isError(description.multitestExpectations)) { |
- result = result.toNegativeTestResult(); |
+ result = toNegativeTestResult( |
+ result, description.multitestExpectations); |
} |
} else if (lastStep == lastStepRun && |
description.shortName.endsWith("negative_test")) { |
@@ -205,7 +206,7 @@ abstract class ChainContext { |
} else if (result.outcome == Expectation.FAIL) { |
result.addLog("Negative test reported an error as expeceted.\n"); |
} |
- result = result.toNegativeTestResult(); |
+ result = toNegativeTestResult(result); |
} |
if (!expectedOutcomes.contains(result.outcome)) { |
result.addLog("$sb"); |
@@ -316,13 +317,7 @@ class Result<O> { |
logs.add(log); |
} |
- Result<O> toNegativeTestResult() { |
- Expectation outcome = this.outcome; |
- if (outcome == Expectation.PASS) { |
- outcome = Expectation.FAIL; |
- } else if (outcome == Expectation.FAIL) { |
- outcome = Expectation.PASS; |
- } |
+ Result<O> copyWithOutcome(Expectation outcome) { |
return new Result<O>(output, outcome, error, trace) |
..logs.addAll(logs); |
} |
@@ -339,3 +334,22 @@ Future<Null> runChain( |
return context.run(suite, selectors); |
}); |
} |
+ |
+Result toNegativeTestResult(Result result, [Set<String> expectations]) { |
+ Expectation outcome = result.outcome; |
+ if (outcome == Expectation.PASS) { |
+ if (expectations == null) { |
+ outcome = Expectation.FAIL; |
+ } else if (expectations.contains("compile-time error")) { |
+ outcome = Expectation.MISSING_COMPILETIME_ERROR; |
+ } else if (expectations.contains("runtime error") || |
+ expectations.contains("dynamic type error")) { |
+ outcome = Expectation.MISSING_RUNTIME_ERROR; |
+ } else { |
+ outcome = Expectation.FAIL; |
+ } |
+ } else if (outcome == Expectation.FAIL) { |
+ outcome = Expectation.PASS; |
+ } |
+ return result.copyWithOutcome(outcome); |
+} |