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

Unified Diff: dart/tools/testing/dart/utils.dart

Issue 118783003: Command class hieracy refactoring, environmentOverride extraction (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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 | « dart/tools/testing/dart/test_suite.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tools/testing/dart/utils.dart
diff --git a/dart/tools/testing/dart/utils.dart b/dart/tools/testing/dart/utils.dart
index 59c5021b171fe9c290309a2ec59ba93a8ca4d478..eacba54e39ec566a843012384eec7bf692a18ab7 100644
--- a/dart/tools/testing/dart/utils.dart
+++ b/dart/tools/testing/dart/utils.dart
@@ -236,6 +236,36 @@ class HashCodeBuilder {
int get value => _value;
}
+bool deepJsonCompare(Object a, Object b) {
+ if (a == null || a is num || a is String) {
+ return a == b;
+ } else if (a is List) {
+ if (b is List) {
+ if (a.length != b.length) return false;
+
+ for (int i = 0; i < a.length; i++) {
+ if (!deepJsonCompare(a[i], b[i])) return false;
+ }
+ return true;
+ }
+ return false;
+ } else if (a is Map) {
+ if (b is Map) {
+ if (a.length != b.length) return false;
+
+ for (var key in a.keys) {
+ if (!b.containsKey(key)) return false;
+ if (!deepJsonCompare(a[key], b[key])) return false;
+ }
+ return true;
+ }
+ return false;
+ } else {
+ throw new Exception("Can't compare two non json-like objects "
+ "(a: ${a.runtimeType}, b: ${b.runtimeType})");
+ }
+}
+
class UniqueObject {
static int _nextId = 1;
final int _hashCode;
« no previous file with comments | « dart/tools/testing/dart/test_suite.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698