From f1248b9780e29c440d29ad1765898d9784a67710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20B=C3=A1tyai?= Date: Tue, 21 Jul 2015 14:34:24 +0200 Subject: [PATCH] Fix Number.prototype.toString() when radix is undefined. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com --- .../ecma/builtin-objects/ecma-builtin-number-prototype.cpp | 3 ++- tests/jerry/number-prototype-to-string.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.cpp index 5a0730244e..03763b0d43 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.cpp @@ -97,7 +97,8 @@ ecma_builtin_number_prototype_object_to_string (ecma_value_t this_arg, /**< this if (arguments_list_len == 0 || ecma_number_is_nan (this_arg_number) || ecma_number_is_infinity (this_arg_number) - || ecma_number_is_zero (this_arg_number)) + || ecma_number_is_zero (this_arg_number) + || (arguments_list_len > 0 && ecma_is_value_undefined (arguments_list_p[0]))) { ecma_string_t *ret_str_p = ecma_new_ecma_string_from_number (this_arg_number); diff --git a/tests/jerry/number-prototype-to-string.js b/tests/jerry/number-prototype-to-string.js index a1e669b398..64fef3bfee 100644 --- a/tests/jerry/number-prototype-to-string.js +++ b/tests/jerry/number-prototype-to-string.js @@ -43,6 +43,7 @@ assert((-0.0001).toString(4) === "-0.000000122031232023223013010030231") assert((-0).toString(16) === "0"); assert((1e+73).toString(35) === "2nx1mg1l0w4ujlpt449c5qfrkkmtpgpsfsc2prlaqtnjbli2") assert((-1e+73).toString(35) === "-2nx1mg1l0w4ujlpt449c5qfrkkmtpgpsfsc2prlaqtnjbli2") +assert((1).toString(undefined) === "1") assert((123400).toString(2) === "11110001000001000"); assert((123400).toString(3) === "20021021101");