From f8770020f724f2937cf9c34df01f247fc986952f Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Fri, 10 Jul 2015 23:39:26 +0300 Subject: [PATCH] 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 --- .../ecma/builtin-objects/ecma-builtin-regexp-prototype.cpp | 2 +- jerry-core/ecma/operations/ecma-regexp-object.cpp | 2 +- tests/jerry/regexp-routines.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.cpp index 0f2627c7c..49f42e0e5 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.cpp @@ -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); } diff --git a/jerry-core/ecma/operations/ecma-regexp-object.cpp b/jerry-core/ecma/operations/ecma-regexp-object.cpp index 2e3417638..5500094e4 100644 --- a/jerry-core/ecma/operations/ecma-regexp-object.cpp +++ b/jerry-core/ecma/operations/ecma-regexp-object.cpp @@ -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); diff --git a/tests/jerry/regexp-routines.js b/tests/jerry/regexp-routines.js index df3653ca5..b2e5335b7 100644 --- a/tests/jerry/regexp-routines.js +++ b/tests/jerry/regexp-routines.js @@ -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)