diff --git a/implementation-contributed/javascriptcore/stress/date-utc-optional.js b/implementation-contributed/javascriptcore/stress/date-utc-optional.js new file mode 100644 index 0000000000..f14f7c60c6 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/date-utc-optional.js @@ -0,0 +1,16 @@ +function shouldBe(actual, expected) { + if (actual !== expected) + throw new Error('bad value: ' + actual); +} + +for (var i = 0; i < 1e5; ++i) { + shouldBe(Number.isNaN(Date.UTC()), true); + shouldBe(Date.UTC(2018), 1514764800000); + shouldBe(Date.UTC(2018, 1), 1517443200000); + shouldBe(Date.UTC(2018, 1, 2), 1517529600000); + shouldBe(Date.UTC(2018, 1, 2, 3), 1517540400000); + shouldBe(Date.UTC(2018, 1, 2, 3, 4), 1517540640000); + shouldBe(Date.UTC(2018, 1, 2, 3, 4, 5), 1517540645000); + shouldBe(Date.UTC(2018, 1, 2, 3, 4, 5, 6), 1517540645006); + shouldBe(Date.UTC(2018, 1, 2, 3, 4, 5, 6, 7), 1517540645006); +}