Fix broken test in WebKit test suite and add the test in question to V8 tests.
Review URL: http://codereview.chromium.org/661466 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4009 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
d51f2c96cb
commit
d49a5db0a4
@ -4969,9 +4969,25 @@ static Object* Runtime_DateMakeDay(Arguments args) {
|
||||
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)) {
|
||||
|
@ -147,3 +147,17 @@ function testToLocaleTimeString() {
|
||||
}
|
||||
|
||||
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)));
|
||||
|
Loading…
Reference in New Issue
Block a user