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

Side by Side Diff: test/mjsunit/json.js

Issue 560032: Bad newline snuck in before commit. (Closed)
Patch Set: Created 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 JSON.stringify({a:"b",c:"d"}, null, 15)); 288 JSON.stringify({a:"b",c:"d"}, null, 15));
289 289
290 // Replaced wrapped primitives are unwrapped. 290 // Replaced wrapped primitives are unwrapped.
291 function newx(k, v) { return (k == "x") ? new v(42) : v; } 291 function newx(k, v) { return (k == "x") ? new v(42) : v; }
292 assertEquals('{"x":"42"}', JSON.stringify({x: String}, newx)); 292 assertEquals('{"x":"42"}', JSON.stringify({x: String}, newx));
293 assertEquals('{"x":42}', JSON.stringify({x: Number}, newx)); 293 assertEquals('{"x":42}', JSON.stringify({x: Number}, newx));
294 assertEquals('{"x":true}', JSON.stringify({x: Boolean}, newx)); 294 assertEquals('{"x":true}', JSON.stringify({x: Boolean}, newx));
295 295
296 assertEquals(undefined, JSON.stringify(undefined)); 296 assertEquals(undefined, JSON.stringify(undefined));
297 assertEquals(undefined, JSON.stringify(function () { })); 297 assertEquals(undefined, JSON.stringify(function () { }));
298 // 298 // Arrays with missing, undefined or function elements have those elements
299 Arrays with missing, undefined or function elements have those elements
300 // replaced by null. 299 // replaced by null.
301 assertEquals("[null,null,null]", 300 assertEquals("[null,null,null]",
302 JSON.stringify([undefined,,function(){}])); 301 JSON.stringify([undefined,,function(){}]));
303 302
304 // Objects with undefined or function properties (including replaced properties) 303 // Objects with undefined or function properties (including replaced properties)
305 // have those properties ignored. 304 // have those properties ignored.
306 assertEquals('{}', 305 assertEquals('{}',
307 JSON.stringify({a: undefined, b: function(){}, c: 42, d: 42}, 306 JSON.stringify({a: undefined, b: function(){}, c: 42, d: 42},
308 function(k, v) { if (k == "c") return undefined; 307 function(k, v) { if (k == "c") return undefined;
309 if (k == "d") return function(){}; 308 if (k == "d") return function(){};
310 return v; })); 309 return v; }));
311 310
312 TestInvalid('1); throw "foo"; (1'); 311 TestInvalid('1); throw "foo"; (1');
313 312
314 var x = 0; 313 var x = 0;
315 eval("(1); x++; (1)"); 314 eval("(1); x++; (1)");
316 TestInvalid('1); x++; (1'); 315 TestInvalid('1); x++; (1');
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698