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

Unified Diff: gin/test/expect.js

Issue 654843005: Mojo JS Bindings: add support for associative arrays (Mojo map type) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a typo Created 6 years, 2 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
Index: gin/test/expect.js
diff --git a/gin/test/expect.js b/gin/test/expect.js
index b5e0f216e7890e73c96f09c9033274f0c23879f9..597b5b1d5e32bb456109f10cea141fb480451b93 100644
--- a/gin/test/expect.js
+++ b/gin/test/expect.js
@@ -82,7 +82,7 @@ define(function() {
aStack.push(a);
bStack.push(b);
var size = 0, result = true;
- // Recursively compare objects and arrays.
+ // Recursively compare Maps, objects and arrays.
if (className == '[object Array]' || isArrayBufferClass(className)) {
// Compare array lengths to determine if a deep comparison is necessary.
size = a.length;
@@ -94,6 +94,16 @@ define(function() {
break;
}
}
+ } else if (className == '[object Map]') {
+ result = a.size == b.size;
+ if (result) {
+ var entries = a.entries();
+ for (var e = entries.next(); result && !e.done; e = entries.next()) {
+ var key = e.value[0];
+ var value = e.value[1];
+ result = b.has(key) && eq(value, b.get(key), aStack, bStack);
+ }
+ }
} else {
// Deep compare objects.
for (var key in a) {
« no previous file with comments | « no previous file | mojo/public/interfaces/bindings/tests/test_structs.mojom » ('j') | mojo/public/js/bindings/validator.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698