Revision: 4009
Author: [email protected]
Date: Wed Mar 3 06:19:04 2010
Log: Fix broken test in WebKit test suite and add the test in question to
V8 tests.
Review URL: http://codereview.chromium.org/661466
http://code.google.com/p/v8/source/detail?r=4009
Modified:
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/mjsunit/date.js
=======================================
--- /branches/bleeding_edge/src/runtime.cc Tue Mar 2 10:47:03 2010
+++ /branches/bleeding_edge/src/runtime.cc Wed Mar 3 06:19:04 2010
@@ -4969,9 +4969,25 @@
ASSERT(month >= 0);
ASSERT(month < 12);
- static const int base_day = 365*1969 + 1969/4 - 1969/100 + 1969/400;
- int year1 = year - 1;
- int day_from_year = 365 * year1 + year1 / 4 - year1 / 100 + year1 / 400 -
+ // year_delta is an arbitrary number such that:
+ // a) year_delta = -1 (mod 400)
+ // b) year + year_delta > 0 for years in the range defined by
+ // ECMA 262 - 15.9.1.1, i.e. upto 100,000,000 days on either side of
+ // Jan 1 1970. This is required so that we don't run into integer
+ // division of negative numbers.
+ // c) there shouldn't be overflow for 32-bit integers in the following
+ // operations.
+ static const int year_delta = 399999;
+ static const int base_day = 365 * (1970 + year_delta) +
+ (1970 + year_delta) / 4 -
+ (1970 + year_delta) / 100 +
+ (1970 + year_delta) / 400;
+
+ int year1 = year + year_delta;
+ int day_from_year = 365 * year1 +
+ year1 / 4 -
+ year1 / 100 +
+ year1 / 400 -
base_day;
if (year % 4 || (year % 100 == 0 && year % 400 != 0)) {
=======================================
--- /branches/bleeding_edge/test/mjsunit/date.js Mon Feb 16 02:18:34 2009
+++ /branches/bleeding_edge/test/mjsunit/date.js Wed Mar 3 06:19:04 2010
@@ -147,3 +147,17 @@
}
testToLocaleTimeString();
+
+
+// Modified test from WebKit
+// LayoutTests/fast/js/script-tests/date-utc-timeclip.js:
+
+assertEquals(Date.UTC(275760, 8, 12, 23, 59, 59, 999), 8639999999999999);
+assertEquals(Date.UTC(275760, 8, 13), 8640000000000000);
+assertTrue(isNaN(Date.UTC(275760, 8, 13, 0, 0, 0, 1)));
+assertTrue(isNaN(Date.UTC(275760, 8, 14)));
+
+assertEquals(Date.UTC(-271821, 3, 20, 0, 0, 0, 1), -8639999999999999);
+assertEquals(Date.UTC(-271821, 3, 20), -8640000000000000);
+assertTrue(isNaN(Date.UTC(-271821, 3, 19, 23, 59, 59, 999)));
+assertTrue(isNaN(Date.UTC(-271821, 3, 19)));
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev