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

Unified Diff: test/mjsunit/mjsunit.js

Issue 93066: Built-in JSON support (Closed)
Patch Set: Created 11 years, 8 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: test/mjsunit/mjsunit.js
diff --git a/test/mjsunit/mjsunit.js b/test/mjsunit/mjsunit.js
index 320e8d15d360e23daa3e88ff257b35b628c49080..2c52a31e604451065363bc1fc90d1452a7b20427 100644
--- a/test/mjsunit/mjsunit.js
+++ b/test/mjsunit/mjsunit.js
@@ -51,6 +51,25 @@ function fail(expected, found, name_opt) {
}
+function deepObjectEquals(a, b) {
+ var aProps = [];
+ for (var key in a)
+ aProps.push(key);
+ var bProps = [];
+ for (var key in b)
+ bProps.push(key);
+ aProps.sort();
+ bProps.sort();
+ if (!deepEquals(aProps, bProps))
+ return false;
+ for (var i = 0; i < aProps.length; i++) {
+ if (!deepEquals(a[aProps[i]], b[aProps[i]]))
+ return false;
+ }
+ return true;
+}
+
+
function deepEquals(a, b) {
if (a == b) return true;
if (typeof a == "number" && typeof b == "number" && isNaN(a) && isNaN(b)) {
@@ -73,8 +92,9 @@ function deepEquals(a, b) {
}
}
return true;
+ } else {
+ return deepObjectEquals(a, b);
}
- return false;
}
@@ -130,12 +150,20 @@ function assertNotNull(value, name_opt) {
}
-function assertThrows(code) {
+function assertThrows(code, type_opt, cause_opt) {
var threwException = true;
try {
- eval(code);
+ if (typeof code == 'function') {
+ code();
+ } else {
+ eval(code);
+ }
threwException = false;
} catch (e) {
+ if (typeof type_opt == 'function')
+ assertInstanceof(e, type_opt);
+ if (arguments.length >= 3)
+ assertEquals(e.type, cause_opt);
// Do nothing.
}
if (!threwException) assertTrue(false, "did not throw exception");
« src/objects.h ('K') | « test/mjsunit/json.js ('k') | tools/visual_studio/js2c.cmd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698