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

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

Issue 543057: Fix the tests that change because of change to toISOString format. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/mirror-date.js » ('j') | 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 GenericToJSONChecks(Boolean, true, false); 58 GenericToJSONChecks(Boolean, true, false);
59 GenericToJSONChecks(Boolean, false, true); 59 GenericToJSONChecks(Boolean, false, true);
60 60
61 // String toJSON 61 // String toJSON
62 assertEquals("flot", "flot".toJSON()); 62 assertEquals("flot", "flot".toJSON());
63 assertEquals("flot", "flot".toJSON(3)); 63 assertEquals("flot", "flot".toJSON(3));
64 assertEquals("tolf", (new String("tolf")).toJSON()); 64 assertEquals("tolf", (new String("tolf")).toJSON());
65 GenericToJSONChecks(String, "x", "y"); 65 GenericToJSONChecks(String, "x", "y");
66 66
67 // Date toJSON 67 // Date toJSON
68 assertEquals("1970-01-01T00:00:00Z", new Date(0).toJSON()); 68 assertEquals("1970-01-01T00:00:00.000Z", new Date(0).toJSON());
69 assertEquals("1979-01-11T08:00:00Z", new Date("1979-01-11 08:00 GMT").toJSON()); 69 assertEquals("1979-01-11T08:00:00.000Z", new Date("1979-01-11 08:00 GMT").toJSON ());
70 assertEquals("2005-05-05T05:05:05Z", new Date("2005-05-05 05:05:05 GMT").toJSON( )); 70 assertEquals("2005-05-05T05:05:05.000Z", new Date("2005-05-05 05:05:05 GMT").toJ SON());
71 var n1 = new Date(10000); 71 var n1 = new Date(10000);
72 n1.toISOString = function () { return "foo"; }; 72 n1.toISOString = function () { return "foo"; };
73 assertEquals("foo", n1.toJSON()); 73 assertEquals("foo", n1.toJSON());
74 var n2 = new Date(10001); 74 var n2 = new Date(10001);
75 n2.toISOString = null; 75 n2.toISOString = null;
76 assertThrows(function () { n2.toJSON(); }, TypeError); 76 assertThrows(function () { n2.toJSON(); }, TypeError);
77 var n3 = new Date(10002); 77 var n3 = new Date(10002);
78 n3.toISOString = function () { return {}; }; 78 n3.toISOString = function () { return {}; };
79 assertThrows(function () { n3.toJSON(); }, TypeError, "result_not_primitive"); 79 assertThrows(function () { n3.toJSON(); }, TypeError, "result_not_primitive");
80 var n4 = new Date(10003); 80 var n4 = new Date(10003);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 function checkIllegal(str) { 199 function checkIllegal(str) {
200 assertThrows(function () { JSON.parse(str); }, SyntaxError); 200 assertThrows(function () { JSON.parse(str); }, SyntaxError);
201 } 201 }
202 202
203 checkIllegal('1); throw "foo"; (1'); 203 checkIllegal('1); throw "foo"; (1');
204 204
205 var x = 0; 205 var x = 0;
206 eval("(1); x++; (1)"); 206 eval("(1); x++; (1)");
207 checkIllegal('1); x++; (1'); 207 checkIllegal('1); x++; (1');
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/mirror-date.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698