From 833a5d1a55ab2aed9ae7124e11156807050d8d10 Mon Sep 17 00:00:00 2001 From: Roland Takacs Date: Fri, 31 Jul 2015 13:32:05 +0200 Subject: [PATCH] Eliminate the year calculation from an infinity value. JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs.u-szeged@partner.samsung.com --- jerry-core/ecma/builtin-objects/ecma-builtin-date.cpp | 2 +- tests/jerry/date-tostring.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-date.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-date.cpp index c5cf88e56..12074b666 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-date.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-date.cpp @@ -141,7 +141,7 @@ ecma_date_construct_helper (const ecma_value_t *args, /**< arguments passed to t if (ecma_is_completion_value_empty (ret_value)) { - if (!ecma_number_is_nan (year)) + if (!ecma_number_is_nan (year) && !ecma_number_is_infinity (year)) { /* 8. */ int32_t y = ecma_number_to_int32 (year); diff --git a/tests/jerry/date-tostring.js b/tests/jerry/date-tostring.js index f34b90ac6..d459d70b4 100644 --- a/tests/jerry/date-tostring.js +++ b/tests/jerry/date-tostring.js @@ -14,6 +14,12 @@ // limitations under the License. assert (new Date (NaN) == "Invalid Date"); +assert (new Date (Infinity, 1, 1, 0, 0, 0) == "Invalid Date"); +assert (new Date (2015, Infinity, 1, 0, 0, 0) == "Invalid Date"); +assert (new Date (2015, 7, 1, 0, Infinity, 0) == "Invalid Date"); +assert (new Date (NaN, 1, 1, 0, 0, 0) == "Invalid Date"); +assert (new Date (2015, NaN, 1, 0, 0, 0) == "Invalid Date"); +assert (new Date (2015, 7, 1, 0, NaN, 0) == "Invalid Date"); assert (new Date ("2015-02-13") == "2015-02-13T00:00:00.000"); assert (new Date ("2015-07-08T11:29:05.023") == "2015-07-08T11:29:05.023");