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

Unified Diff: test/mjsunit/json.js

Issue 7348008: Merge up to 8597 to experimental/gc from the bleeding edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 5 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 | « test/mjsunit/hex-parsing.js ('k') | test/mjsunit/keywords-and-reserved_words.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/json.js
===================================================================
--- test/mjsunit/json.js (revision 8618)
+++ test/mjsunit/json.js (working copy)
@@ -67,7 +67,7 @@
valueOf: "not callable",
toString: "not callable either",
toISOString: function() { return 42; }};
-assertThrows("d4.toJSON()", TypeError); // ToPrimitive throws.
+assertThrows("d4.toJSON()", TypeError); // ToPrimitive throws.
var d5 = {toJSON: Date.prototype.toJSON,
valueOf: "not callable",
@@ -196,9 +196,6 @@
TestInvalid('"Unterminated string\\"');
TestInvalid('"Unterminated string\\\\\\"');
-// JavaScript RegExp literals not valid in JSON.
-TestInvalid('/true/');
-
// Test bad JSON that would be good JavaScript (ES5).
TestInvalid("{true:42}");
TestInvalid("{false:42}");
@@ -259,6 +256,7 @@
JSON.stringify([1, 2, [3, [4], 5], 6, 7], null));
assertEquals("[2,4,[6,[8],10],12,14]",
JSON.stringify([1, 2, [3, [4], 5], 6, 7], DoubleNumbers));
+assertEquals('["a","ab","abc"]', JSON.stringify(["a","ab","abc"]));
var circular = [1, 2, 3];
circular[2] = circular;
@@ -382,7 +380,7 @@
reJSON.toJSON = function() { return "has toJSON"; };
assertEquals(
- '[37,null,1,"foo","37","true",null,"has toJSON",null,"has toJSON"]',
+ '[37,null,1,"foo","37","true",null,"has toJSON",{},"has toJSON"]',
JSON.stringify([num37, numFoo, numTrue,
strFoo, str37, strTrue,
func, funcJSON, re, reJSON]));
@@ -397,6 +395,9 @@
var counter = { get toJSON() { getCount++;
return function() { callCount++;
return 42; }; } };
+
+// RegExps are not callable, so they are stringified as objects.
+assertEquals('{}', JSON.stringify(/regexp/));
assertEquals('42', JSON.stringify(counter));
assertEquals(1, getCount);
assertEquals(1, callCount);
@@ -419,9 +420,9 @@
// We don't currently allow plain properties called __proto__ in JSON
// objects in JSON.parse. Instead we read them as we would JS object
// literals. If we change that, this test should change with it.
-//
-// Parse a non-object value as __proto__. This must not create a
-// __proto__ property different from the original, and should not
+//
+// Parse a non-object value as __proto__. This must not create a
+// __proto__ property different from the original, and should not
// change the original.
var o = JSON.parse('{"__proto__":5}');
assertEquals(Object.prototype, o.__proto__); // __proto__ isn't changed.
« no previous file with comments | « test/mjsunit/hex-parsing.js ('k') | test/mjsunit/keywords-and-reserved_words.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698