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

Unified Diff: corelib/src/expect.dart

Issue 9369006: First prototype of import map generator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix path to JSON. Created 8 years, 10 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 | « client/testing/unittest/unittest_vm.dart ('k') | tools/test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: corelib/src/expect.dart
diff --git a/corelib/src/expect.dart b/corelib/src/expect.dart
index 6428ca59c5add6c1f983e3e0850aa55a03e11bd5..e02e6a963eb6be99057830458fa30638db222783 100644
--- a/corelib/src/expect.dart
+++ b/corelib/src/expect.dart
@@ -116,6 +116,30 @@ class Expect {
}
}
+ /**
+ * Checks that all [expected] and [actual] have the same set of keys (using
+ * the semantics of [Map.containsKey] to determine what "same" means. For
+ * each key, checks that the values in both maps are equal using [:==:].
+ */
+ static void mapEquals(Map expected, Map actual, [String reason = null]) {
+ String msg = _getMessage(reason);
+
+ // Make sure all of the values are present in both and match.
+ for (final key in expected.getKeys()) {
+ if (!actual.containsKey(key)) {
+ _fail('Expect.mapEquals(missing expected key: <$key>$msg) fails');
+ }
+
+ Expect.equals(expected[key], actual[key]);
+ }
+
+ // Make sure the actual map doesn't have any extra keys.
+ for (final key in actual.getKeys()) {
+ if (!expected.containsKey(key)) {
+ _fail('Expect.mapEquals(unexpected key: <$key>$msg) fails');
+ }
+ }
+ }
/**
* Specialized equality test for strings. When the strings don't match,
« no previous file with comments | « client/testing/unittest/unittest_vm.dart ('k') | tools/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698