Update RegExp.prototype.exec so that it returns 'null' instead of 'undefined' in case argument doesn't match corresponding regular expression.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan 2015-07-10 23:39:26 +03:00 committed by Evgeny Gavrin
parent 8aa2571699
commit f8770020f7
3 changed files with 3 additions and 3 deletions

View File

@ -117,7 +117,7 @@ ecma_builtin_regexp_prototype_test (ecma_value_t this_arg, /**< this argument */
ecma_builtin_regexp_prototype_exec (this_arg, arg),
ret_value);
if (ecma_is_value_undefined (match_value))
if (ecma_is_value_null (match_value))
{
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
}

View File

@ -1318,7 +1318,7 @@ ecma_regexp_exec_helper (ecma_object_t *obj_p, /**< RegExp object */
}
else
{
ret_value = ecma_make_normal_completion_value (ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED));
ret_value = ecma_make_normal_completion_value (ecma_make_simple_value (ECMA_SIMPLE_VALUE_NULL));
}
}
MEM_FINALIZE_LOCAL_ARRAY (num_of_iter_p);

View File

@ -17,7 +17,7 @@ var r;
r = new RegExp ("a");
assert (r.exec ("a") == "a");
assert (r.exec ("b") == undefined);
assert (r.exec ("b") == null);
try {
r.exec.call({}, "a");
assert (false)