Add throwing of missing range error to Date.prototype.toISOString()
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs.u-szeged@partner.samsung.com
This commit is contained in:
@@ -1164,10 +1164,9 @@ ecma_builtin_date_prototype_to_iso_string (ecma_value_t this_arg) /**< this argu
|
||||
|
||||
ecma_number_t *prim_num_p = ecma_get_number_from_value (prim_value);
|
||||
|
||||
if (ecma_number_is_nan (*prim_num_p))
|
||||
if (ecma_number_is_nan (*prim_num_p) || ecma_number_is_infinity (*prim_num_p))
|
||||
{
|
||||
ecma_string_t *magic_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_INVALID_DATE_UL);
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_string_value (magic_str_p));
|
||||
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_RANGE));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -65,10 +65,29 @@ catch (e)
|
||||
assert (e.message === "Incompatible type");
|
||||
}
|
||||
|
||||
assert (new Date (NaN).toISOString () == "Invalid Date");
|
||||
assert (new Date ("2015-07-16").toISOString () == "2015-07-16T00:00:00.000Z");
|
||||
assert (new Date ("2015-07-16T11:29:05.023").toISOString () == "2015-07-16T11:29:05.023Z");
|
||||
|
||||
try
|
||||
{
|
||||
new Date (NaN).toISOString ();
|
||||
assert (false);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
assert (e instanceof RangeError);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
new Date (Number.POSITIVE_INFINITY).toISOString ();
|
||||
assert (false);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
assert (e instanceof RangeError);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Date.prototype.toISOString.call(-1);
|
||||
|
||||
Reference in New Issue
Block a user