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

Unified Diff: pkg/testing/lib/src/expectation.dart

Issue 2913153002: Add RuntimeError to default expectations and handle expectation groups correctly. (Closed)
Patch Set: Created 3 years, 7 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/testing/lib/src/chain.dart ('k') | pkg/testing/lib/src/stdio_process.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/testing/lib/src/expectation.dart
diff --git a/pkg/testing/lib/src/expectation.dart b/pkg/testing/lib/src/expectation.dart
index 642ca220e214cd0f304180f07779776a21818ab3..11ef0ee26b8c4286962b9f8c2f6deda4870770f1 100644
--- a/pkg/testing/lib/src/expectation.dart
+++ b/pkg/testing/lib/src/expectation.dart
@@ -34,7 +34,29 @@ class Expectation {
const Expectation(this.name, this.group);
+ /// Returns the canonical expectation representing [group]. That is, one of
+ /// the above expectations (except for `Meta` which returns `this`).
+ Expectation get canonical => fromGroup(group) ?? this;
+
String toString() => name;
+
+ static Expectation fromGroup(ExpectationGroup group) {
+ switch (group) {
+ case ExpectationGroup.Crash:
+ return Expectation.Crash;
+ case ExpectationGroup.Fail:
+ return Expectation.Fail;
+ case ExpectationGroup.Meta:
+ return null;
+ case ExpectationGroup.Pass:
+ return Expectation.Pass;
+ case ExpectationGroup.Skip:
+ return Expectation.Skip;
+ case ExpectationGroup.Timeout:
+ return Expectation.Timeout;
+ }
+ throw "Unhandled group: '$group'.";
+ }
}
class ExpectationSet {
@@ -49,6 +71,7 @@ class ExpectationSet {
const Expectation("MissingCompileTimeError", ExpectationGroup.Fail),
"missingruntimeerror":
const Expectation("MissingRuntimeError", ExpectationGroup.Fail),
+ "runtimeerror": const Expectation("RuntimeError", ExpectationGroup.Fail),
});
final Map<String, Expectation> internalMap;
« no previous file with comments | « pkg/testing/lib/src/chain.dart ('k') | pkg/testing/lib/src/stdio_process.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698