Update Symbol.split functions for String and Regexp to match new standard (#3942)

In newest ES standard limit parameter is calculated using
ToUint32 function instead of ToLength.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
This commit is contained in:
Rafal Walczyna
2020-06-30 16:03:11 +02:00
committed by GitHub
parent 3e866258db
commit 9d2b7334bc
6 changed files with 48 additions and 5 deletions
@@ -795,10 +795,13 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_value, /**< this a
uint32_t limit = UINT32_MAX;
if (!ecma_is_value_undefined (limit_value))
{
if (ECMA_IS_VALUE_ERROR (ecma_op_to_length (limit_value, &limit)))
/* ECMA-262 v11, 21.1.3.20 6 */
ecma_number_t num;
if (ECMA_IS_VALUE_ERROR (ecma_get_number (limit_value, &num)))
{
goto cleanup_string;
}
limit = ecma_number_to_uint32 (num);
}
/* 12. */
@@ -2113,10 +2113,13 @@ ecma_regexp_split_helper (ecma_value_t this_arg, /**< this value */
uint32_t limit = UINT32_MAX;
if (!ecma_is_value_undefined (limit_arg))
{
if (ECMA_IS_VALUE_ERROR (ecma_op_to_length (limit_arg, &limit)))
/* ECMA-262 v11, 21.2.5.13 13 */
ecma_number_t num;
if (ECMA_IS_VALUE_ERROR (ecma_get_number (limit_arg, &num)))
{
goto cleanup_splitter;
}
limit = ecma_number_to_uint32 (num);
}
/* 15. */
@@ -2215,6 +2218,12 @@ ecma_regexp_split_helper (ecma_value_t this_arg, /**< this value */
goto cleanup_array;
}
/* ECMA-262 v11, 21.2.5.11 19.d.ii */
if (end_index > string_length)
{
end_index = string_length;
}
/* 24.f.iii. */
if (previous_index == end_index)
{