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

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

Issue 8392036: Fix error handling in Date.prototype.toISOString. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Lasse Reichstein. Created 9 years, 1 month 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 | « src/runtime.cc ('k') | test/test262/test262.status » ('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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 var d = new Date(); 150 var d = new Date();
151 var s = d.toLocaleTimeString(); 151 var s = d.toLocaleTimeString();
152 assertEquals(8, s.length); 152 assertEquals(8, s.length);
153 } 153 }
154 154
155 testToLocaleTimeString(); 155 testToLocaleTimeString();
156 156
157 // Test that -0 is treated correctly in MakeDay. 157 // Test that -0 is treated correctly in MakeDay.
158 var d = new Date(); 158 var d = new Date();
159 assertDoesNotThrow("d.setDate(-0)"); 159 assertDoesNotThrow("d.setDate(-0)");
160 assertDoesNotThrow("new Date(-0, -0, -0, -0, -0, -0. -0)"); 160 assertDoesNotThrow("new Date(-0, -0, -0, -0, -0, -0, -0)");
161 assertDoesNotThrow("new Date(0x40000000, 0x40000000, 0x40000000," + 161 assertDoesNotThrow("new Date(0x40000000, 0x40000000, 0x40000000," +
162 "0x40000000, 0x40000000, 0x40000000, 0x40000000)") 162 "0x40000000, 0x40000000, 0x40000000, 0x40000000)")
163 assertDoesNotThrow("new Date(-0x40000001, -0x40000001, -0x40000001," + 163 assertDoesNotThrow("new Date(-0x40000001, -0x40000001, -0x40000001," +
164 "-0x40000001, -0x40000001, -0x40000001, -0x40000001)") 164 "-0x40000001, -0x40000001, -0x40000001, -0x40000001)")
165 165
166 166
167 // Modified test from WebKit 167 // Modified test from WebKit
168 // LayoutTests/fast/js/script-tests/date-utc-timeclip.js: 168 // LayoutTests/fast/js/script-tests/date-utc-timeclip.js:
169 169
170 assertEquals(8639999999999999, Date.UTC(275760, 8, 12, 23, 59, 59, 999)); 170 assertEquals(8639999999999999, Date.UTC(275760, 8, 12, 23, 59, 59, 999));
171 assertEquals(8640000000000000, Date.UTC(275760, 8, 13)); 171 assertEquals(8640000000000000, Date.UTC(275760, 8, 13));
172 assertTrue(isNaN(Date.UTC(275760, 8, 13, 0, 0, 0, 1))); 172 assertTrue(isNaN(Date.UTC(275760, 8, 13, 0, 0, 0, 1)));
173 assertTrue(isNaN(Date.UTC(275760, 8, 14))); 173 assertTrue(isNaN(Date.UTC(275760, 8, 14)));
174 174
175 assertEquals(Date.UTC(-271821, 3, 20, 0, 0, 0, 1), -8639999999999999); 175 assertEquals(Date.UTC(-271821, 3, 20, 0, 0, 0, 1), -8639999999999999);
176 assertEquals(Date.UTC(-271821, 3, 20), -8640000000000000); 176 assertEquals(Date.UTC(-271821, 3, 20), -8640000000000000);
177 assertTrue(isNaN(Date.UTC(-271821, 3, 19, 23, 59, 59, 999))); 177 assertTrue(isNaN(Date.UTC(-271821, 3, 19, 23, 59, 59, 999)));
178 assertTrue(isNaN(Date.UTC(-271821, 3, 19))); 178 assertTrue(isNaN(Date.UTC(-271821, 3, 19)));
179 179
180 180
181 // Test creation of large date values. 181 // Test creation with large date values.
182 d = new Date(1969, 12, 1, 99999999999); 182 d = new Date(1969, 12, 1, 99999999999);
183 assertTrue(isNaN(d.getTime())); 183 assertTrue(isNaN(d.getTime()));
184 d = new Date(1969, 12, 1, -99999999999); 184 d = new Date(1969, 12, 1, -99999999999);
185 assertTrue(isNaN(d.getTime())); 185 assertTrue(isNaN(d.getTime()));
186 d = new Date(1969, 12, 1, Infinity); 186 d = new Date(1969, 12, 1, Infinity);
187 assertTrue(isNaN(d.getTime())); 187 assertTrue(isNaN(d.getTime()));
188 d = new Date(1969, 12, 1, -Infinity); 188 d = new Date(1969, 12, 1, -Infinity);
189 assertTrue(isNaN(d.getTime())); 189 assertTrue(isNaN(d.getTime()));
190 190
191
192 // Test creation with obscure date values.
193 var timezoneOffset = new Date().getTimezoneOffset();
194 d = new Date(1970, 0, 1 + 100000001, -24, -timezoneOffset);
195 assertFalse(isNaN(d.getTime()));
196 assertEquals(8640000000000000, d.getTime())
197 d = new Date(1970, 0, 1 - 100000001, 24, -timezoneOffset);
198 assertFalse(isNaN(d.getTime()));
199 assertEquals(-8640000000000000, d.getTime())
200
201
191 // Parsing ES5 ISO-8601 dates. 202 // Parsing ES5 ISO-8601 dates.
192 // When TZ is omitted, it defaults to 'Z' meaning UTC. 203 // When TZ is omitted, it defaults to 'Z' meaning UTC.
193 204
194 // Check epoch. 205 // Check epoch.
195 assertEquals(0, Date.parse("1970-01-01T00:00:00.000+00:00")); 206 assertEquals(0, Date.parse("1970-01-01T00:00:00.000+00:00"));
196 assertEquals(0, Date.parse("1970-01-01T00:00:00.000-00:00")); 207 assertEquals(0, Date.parse("1970-01-01T00:00:00.000-00:00"));
197 assertEquals(0, Date.parse("1970-01-01T00:00:00.000Z")); 208 assertEquals(0, Date.parse("1970-01-01T00:00:00.000Z"));
198 assertEquals(0, Date.parse("1970-01-01T00:00:00.000")); 209 assertEquals(0, Date.parse("1970-01-01T00:00:00.000"));
199 assertEquals(0, Date.parse("1970-01-01T00:00:00")); 210 assertEquals(0, Date.parse("1970-01-01T00:00:00"));
200 assertEquals(0, Date.parse("1970-01-01T00:00")); 211 assertEquals(0, Date.parse("1970-01-01T00:00"));
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 var hh = (i < 10) ? "0" + i : "" + i; 311 var hh = (i < 10) ? "0" + i : "" + i;
301 for (var j = 0; j < 60; j += 15) { 312 for (var j = 0; j < 60; j += 15) {
302 var mm = (j < 10) ? "0" + j : "" + j; 313 var mm = (j < 10) ? "0" + j : "" + j;
303 var ms = (i * 60 + j) * 60000; 314 var ms = (i * 60 + j) * 60000;
304 var string = "1972-03-28T23:50:03.500-" + hh + ":" + mm; 315 var string = "1972-03-28T23:50:03.500-" + hh + ":" + mm;
305 assertEquals(70674603500 + ms, Date.parse(string), string); 316 assertEquals(70674603500 + ms, Date.parse(string), string);
306 string = "1972-03-28T23:50:03.500+" + hh + ":" + mm; 317 string = "1972-03-28T23:50:03.500+" + hh + ":" + mm;
307 assertEquals(70674603500 - ms, Date.parse(string), string); 318 assertEquals(70674603500 - ms, Date.parse(string), string);
308 } 319 }
309 } 320 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698