Skip to content

Commit bbfddea

Browse files
szledangalpeter
authored andcommitted
Fix Date(Number.POSITIVE_INFINITY) assertion fail in the Date constructor
JerryScript-DCO-1.0-Signed-off-by: Szilard Ledan szledan.u-szeged@partner.samsung.com
1 parent 6038173 commit bbfddea

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-date.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,11 @@ ecma_builtin_date_dispatch_construct (const ecma_value_t *arguments_list_p, /**<
556556

557557
if (ecma_is_completion_value_empty (ret_value))
558558
{
559+
if (!ecma_number_is_nan (*prim_value_num_p) && ecma_number_is_infinity (*prim_value_num_p))
560+
{
561+
*prim_value_num_p = ecma_number_make_nan ();
562+
}
563+
559564
ecma_property_t *class_prop_p = ecma_create_internal_property (obj_p,
560565
ECMA_INTERNAL_PROPERTY_CLASS);
561566
class_prop_p->u.internal_property.value = LIT_MAGIC_STRING_DATE_UL;

tests/jerry/date-tostring.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ catch (e)
4444
}
4545

4646
assert (new Date (NaN).toTimeString () == "Invalid Date");
47+
assert (Date (Number.POSITIVE_INFINITY).toString () === "Invalid Date");
4748
assert (new Date ("2015-02-13").toTimeString () == "00:00:00.000");
4849
assert (new Date ("2015-07-08T11:29:05.023").toTimeString () == "11:29:05.023");
4950

0 commit comments

Comments
 (0)