Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions jerry-core/ecma/builtin-objects/ecma-builtin-string.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include "ecma-helpers.h"
#include "ecma-objects.h"
#include "ecma-string-object.h"
#ifndef CONFIG_DISABLE_ES2015_SYMBOL_BUILTIN
#include "ecma-symbol-object.h"
#endif /* !CONFIG_DISABLE_ES2015_SYMBOL_BUILTIN */
#include "ecma-try-catch-macro.h"
#include "jrt.h"

Expand Down Expand Up @@ -109,6 +112,9 @@ ecma_builtin_string_object_from_char_code (ecma_value_t this_arg, /**< 'this' ar
/**
* Handle calling [[Call]] of built-in String object
*
* See also:
* ECMA-262 v6, 21.1.1.1
*
* @return ecma value
*/
ecma_value_t
Expand All @@ -119,10 +125,19 @@ ecma_builtin_string_dispatch_call (const ecma_value_t *arguments_list_p, /**< ar

ecma_value_t ret_value = ECMA_VALUE_EMPTY;

/* 1. */
if (arguments_list_len == 0)
{
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
#ifndef CONFIG_DISABLE_ES2015_SYMBOL_BUILTIN
/* 2.a */
else if (ecma_is_value_symbol (arguments_list_p[0]))
{
ret_value = ecma_get_symbol_descriptive_string (arguments_list_p[0]);
}
#endif /* !CONFIG_DISABLE_ES2015_SYMBOL_BUILTIN */
/* 2.b */
else
{
ret_value = ecma_op_to_string (arguments_list_p[0]);
Expand Down
2 changes: 2 additions & 0 deletions tests/jerry/es2015/symbol-prototype-tostring.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ try {

var foo = Symbol ('foo');
assert (foo.toString () === "Symbol(foo)");
assert (String (foo) === "Symbol(foo)");

var fooObj = Object (foo);
assert (fooObj.toString () === "Symbol(foo)");
assert (String (fooObj) === "Symbol(foo)");