Make date-constructor test more portable
The timezone offset in effect on Dec 25, 1995 won't be applicable in years far away from 1995 (e.g. year 1111). Calculate the timezone offset in Feb 1, 1995 and run other tests on the same day. This issue has been hidden because the current implementation doesn't take into account the history of timezone offset changes(crbug.com/3547), but was exposed when a correct implementation based on ICU was tried. ( https://chromium-review.googlesource.com/c/v8/v8/+/572148 ). Bug: v8:7268 Test: webkit/date-constructor Change-Id: I09834cff0baa47d6c8981e7712ebf39541e5ecb7 Reviewed-on: https://chromium-review.googlesource.com/861196 Commit-Queue: Jungshik Shin <jshin@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#50515}
This commit is contained in:
parent
61ad57ebfb
commit
e6138f5411
@ -27,37 +27,36 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
|
||||
|
||||
|
||||
PASS isNaN(new Date("")) is true
|
||||
PASS new Date(1111).getTime() is 1111
|
||||
PASS new Date(object).getTime() is 1111
|
||||
PASS new Date(new Date(1111)).getTime() is 1111
|
||||
PASS new Date(new Date(1111).toString()).getTime() is 1000
|
||||
PASS new Date(1111, 1).getTime() - timeZoneOffset is -27104803200000
|
||||
PASS new Date(1111, 1, 1).getTime() - timeZoneOffset is -27104803200000
|
||||
PASS new Date(1111, 1, 1, 1).getTime() - timeZoneOffset is -27104799600000
|
||||
PASS new Date(1111, 1, 1, 1, 1).getTime() - timeZoneOffset is -27104799540000
|
||||
PASS new Date(1111, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is -27104799539000
|
||||
PASS new Date(1111, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is -27104799538999
|
||||
PASS new Date(1111, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is -27104799538999
|
||||
PASS new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is -27104799538999
|
||||
PASS new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is -27104799538999
|
||||
PASS new Date(new Date(1111, 1)).getTime() - timeZoneOffset is -27104803200000
|
||||
PASS new Date(new Date(1111, 1, 1)).getTime() - timeZoneOffset is -27104803200000
|
||||
PASS new Date(new Date(1111, 1, 1, 1)).getTime() - timeZoneOffset is -27104799600000
|
||||
PASS new Date(new Date(1111, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -27104799539000
|
||||
PASS new Date(new Date(1111, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -27104799538999
|
||||
PASS new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -27104799538999
|
||||
PASS new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -27104799538999
|
||||
PASS new Date(1995).getTime() is 1995
|
||||
PASS new Date(object).getTime() is 1995
|
||||
PASS new Date(new Date(1995)).getTime() is 1995
|
||||
PASS new Date(new Date(1995).toString()).getTime() is 1000
|
||||
PASS new Date(1995, 1).getTime() - timeZoneOffset is 791596800000
|
||||
PASS new Date(1995, 1, 1).getTime() - timeZoneOffset is 791596800000
|
||||
PASS new Date(1995, 1, 1, 1).getTime() - timeZoneOffset is 791600400000
|
||||
PASS new Date(1995, 1, 1, 1, 1).getTime() - timeZoneOffset is 791600460000
|
||||
PASS new Date(1995, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is 791600461000
|
||||
PASS new Date(1995, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is 791600461001
|
||||
PASS new Date(1995, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is 791600461001
|
||||
PASS new Date(1995, 1, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is 791600461001
|
||||
PASS new Date(new Date(1995, 1)).getTime() - timeZoneOffset is 791596800000
|
||||
PASS new Date(new Date(1995, 1, 1)).getTime() - timeZoneOffset is 791596800000
|
||||
PASS new Date(new Date(1995, 1, 1, 1)).getTime() - timeZoneOffset is 791600400000
|
||||
PASS new Date(new Date(1995, 1, 1, 1, 1)).getTime() - timeZoneOffset is 791600460000
|
||||
PASS new Date(new Date(1995, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is 791600461000
|
||||
PASS new Date(new Date(1995, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is 791600461001
|
||||
PASS new Date(new Date(1995, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is 791600461001
|
||||
PASS new Date(new Date(1995, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is 791600461001
|
||||
PASS Number(new Date(new Date(Infinity, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
|
||||
PASS Number(new Date(new Date(1, Infinity, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
|
||||
PASS Number(new Date(new Date(1, 1, Infinity, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
|
||||
PASS Number(new Date(new Date(1, 1, 1, Infinity, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
|
||||
PASS Number(new Date(new Date(1, 1, 1, 1, Infinity, 1, 1, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
|
||||
PASS Number(new Date(new Date(1, 1, 1, 1, 1, Infinity, 1, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
|
||||
PASS Number(new Date(new Date(1, 1, 1, 1, 1, 1, Infinity, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
|
||||
PASS Number(new Date(new Date(1, 1, 1, 1, 1, 1, 1, 1, Infinity)).getTime() - timeZoneOffset) is -2174770738999
|
||||
PASS Number(new Date(new Date(95, Infinity, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
|
||||
PASS Number(new Date(new Date(95, 1, Infinity, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
|
||||
PASS Number(new Date(new Date(95, 1, 1, Infinity, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
|
||||
PASS Number(new Date(new Date(95, 1, 1, 1, Infinity, 1, 1, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
|
||||
PASS Number(new Date(new Date(95, 1, 1, 1, 1, Infinity, 1, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
|
||||
PASS Number(new Date(new Date(95, 1, 1, 1, 1, 1, Infinity, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
|
||||
PASS Number(new Date(new Date(95, 1, 1, 1, 1, 1, 1, 1, Infinity)).getTime() - timeZoneOffset) is 791600461001
|
||||
PASS testStr is "1234567"
|
||||
PASS testStr is "1234567"
|
||||
PASS successfullyParsed is true
|
||||
|
||||
TEST COMPLETE
|
||||
|
||||
|
@ -28,44 +28,44 @@ description(
|
||||
);
|
||||
|
||||
var object = new Object;
|
||||
object.valueOf = function() { return 1111; }
|
||||
object.valueOf = function() { return 1995; }
|
||||
object.toString = function() { return "2222"; }
|
||||
|
||||
shouldBe('isNaN(new Date(""))', 'true');
|
||||
|
||||
var timeZoneOffset = Date.parse("Dec 25 1995") - Date.parse("Dec 25 1995 GMT");
|
||||
var timeZoneOffset = Date.parse("Feb 1 1995") - Date.parse("Feb 1 1995 GMT");
|
||||
|
||||
shouldBe('new Date(1111).getTime()', '1111');
|
||||
shouldBe('new Date(object).getTime()', '1111');
|
||||
shouldBe('new Date(new Date(1111)).getTime()', '1111');
|
||||
shouldBe('new Date(new Date(1111).toString()).getTime()', '1000');
|
||||
shouldBe('new Date(1995).getTime()', '1995');
|
||||
shouldBe('new Date(object).getTime()', '1995');
|
||||
shouldBe('new Date(new Date(1995)).getTime()', '1995');
|
||||
shouldBe('new Date(new Date(1995).toString()).getTime()', '1000');
|
||||
|
||||
shouldBe('new Date(1111, 1).getTime() - timeZoneOffset', '-27104803200000');
|
||||
shouldBe('new Date(1111, 1, 1).getTime() - timeZoneOffset', '-27104803200000');
|
||||
shouldBe('new Date(1111, 1, 1, 1).getTime() - timeZoneOffset', '-27104799600000');
|
||||
shouldBe('new Date(1111, 1, 1, 1, 1).getTime() - timeZoneOffset', '-27104799540000');
|
||||
shouldBe('new Date(1111, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '-27104799539000');
|
||||
shouldBe('new Date(1111, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '-27104799538999');
|
||||
shouldBe('new Date(1111, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '-27104799538999');
|
||||
shouldBe('new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '-27104799538999');
|
||||
shouldBe('new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '-27104799538999');
|
||||
shouldBe('new Date(1995, 1).getTime() - timeZoneOffset', '791596800000');
|
||||
shouldBe('new Date(1995, 1, 1).getTime() - timeZoneOffset', '791596800000');
|
||||
shouldBe('new Date(1995, 1, 1, 1).getTime() - timeZoneOffset', '791600400000');
|
||||
shouldBe('new Date(1995, 1, 1, 1, 1).getTime() - timeZoneOffset', '791600460000');
|
||||
shouldBe('new Date(1995, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '791600461000');
|
||||
shouldBe('new Date(1995, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '791600461001');
|
||||
shouldBe('new Date(1995, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '791600461001');
|
||||
shouldBe('new Date(1995, 1, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '791600461001');
|
||||
|
||||
shouldBe('new Date(new Date(1111, 1)).getTime() - timeZoneOffset', '-27104803200000');
|
||||
shouldBe('new Date(new Date(1111, 1, 1)).getTime() - timeZoneOffset', '-27104803200000');
|
||||
shouldBe('new Date(new Date(1111, 1, 1, 1)).getTime() - timeZoneOffset', '-27104799600000');
|
||||
shouldBe('new Date(new Date(1111, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '-27104799539000');
|
||||
shouldBe('new Date(new Date(1111, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '-27104799538999');
|
||||
shouldBe('new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '-27104799538999');
|
||||
shouldBe('new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '-27104799538999');
|
||||
shouldBe('new Date(new Date(1995, 1)).getTime() - timeZoneOffset', '791596800000');
|
||||
shouldBe('new Date(new Date(1995, 1, 1)).getTime() - timeZoneOffset', '791596800000');
|
||||
shouldBe('new Date(new Date(1995, 1, 1, 1)).getTime() - timeZoneOffset', '791600400000');
|
||||
shouldBe('new Date(new Date(1995, 1, 1, 1, 1)).getTime() - timeZoneOffset', '791600460000');
|
||||
shouldBe('new Date(new Date(1995, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '791600461000');
|
||||
shouldBe('new Date(new Date(1995, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '791600461001');
|
||||
shouldBe('new Date(new Date(1995, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '791600461001');
|
||||
shouldBe('new Date(new Date(1995, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '791600461001');
|
||||
|
||||
shouldBe("Number(new Date(new Date(Infinity, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
|
||||
shouldBe("Number(new Date(new Date(1, Infinity, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
|
||||
shouldBe("Number(new Date(new Date(1, 1, Infinity, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
|
||||
shouldBe("Number(new Date(new Date(1, 1, 1, Infinity, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
|
||||
shouldBe("Number(new Date(new Date(1, 1, 1, 1, Infinity, 1, 1, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
|
||||
shouldBe("Number(new Date(new Date(1, 1, 1, 1, 1, Infinity, 1, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
|
||||
shouldBe("Number(new Date(new Date(1, 1, 1, 1, 1, 1, Infinity, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
|
||||
shouldBe("Number(new Date(new Date(1, 1, 1, 1, 1, 1, 1, 1, Infinity)).getTime() - timeZoneOffset)", '-2174770738999');
|
||||
shouldBe("Number(new Date(new Date(95, Infinity, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
|
||||
shouldBe("Number(new Date(new Date(95, 1, Infinity, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
|
||||
shouldBe("Number(new Date(new Date(95, 1, 1, Infinity, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
|
||||
shouldBe("Number(new Date(new Date(95, 1, 1, 1, Infinity, 1, 1, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
|
||||
shouldBe("Number(new Date(new Date(95, 1, 1, 1, 1, Infinity, 1, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
|
||||
shouldBe("Number(new Date(new Date(95, 1, 1, 1, 1, 1, Infinity, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
|
||||
shouldBe("Number(new Date(new Date(95, 1, 1, 1, 1, 1, 1, 1, Infinity)).getTime() - timeZoneOffset)", '791600461001');
|
||||
|
||||
// In Firefox, the results of the following tests are timezone-dependent, which likely implies that the implementation is not quite correct.
|
||||
// Our results are even worse, though, as the dates are clipped: (new Date(1111, 1201).getTime()) == (new Date(1111, 601).getTime())
|
||||
|
Loading…
Reference in New Issue
Block a user