mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Implement Function.prototype.toString.
JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
This commit is contained in:
parent
7952b1cae7
commit
62cb842434
@ -213,3 +213,4 @@ ECMA_MAGIC_STRING_DEF (ECMA_MAGIC_STRING__EMPTY, "")
|
|||||||
* Implementation-defined magic strings
|
* Implementation-defined magic strings
|
||||||
*/
|
*/
|
||||||
ECMA_MAGIC_STRING_DEF (ECMA_MAGIC_STRING_JERRY_UL, "Jerry")
|
ECMA_MAGIC_STRING_DEF (ECMA_MAGIC_STRING_JERRY_UL, "Jerry")
|
||||||
|
ECMA_MAGIC_STRING_DEF (ECMA_MAGIC_STRING__FUNCTION_TO_STRING, "function(){/* ecmascript */}")
|
||||||
|
|||||||
@ -55,7 +55,18 @@
|
|||||||
static ecma_completion_value_t
|
static ecma_completion_value_t
|
||||||
ecma_builtin_function_prototype_object_to_string (ecma_value_t this_arg) /**< this argument */
|
ecma_builtin_function_prototype_object_to_string (ecma_value_t this_arg) /**< this argument */
|
||||||
{
|
{
|
||||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
|
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||||
|
|
||||||
|
if (!ecma_op_is_callable (this_arg))
|
||||||
|
{
|
||||||
|
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ecma_string_t *function_to_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING__FUNCTION_TO_STRING);
|
||||||
|
ret_value = ecma_make_normal_completion_value (ecma_make_string_value (function_to_string_p));
|
||||||
|
}
|
||||||
|
return ret_value;
|
||||||
} /* ecma_builtin_function_prototype_object_to_string */
|
} /* ecma_builtin_function_prototype_object_to_string */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
28
tests/jerry/function_prototype_tostring.js
Normal file
28
tests/jerry/function_prototype_tostring.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright 2015 Samsung Electronics Co., Ltd.
|
||||||
|
// Copyright 2015 University of Szeged
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
assert (Math.cos.toString() === "function(){/* ecmascript */}");
|
||||||
|
|
||||||
|
function none() { return 1; }
|
||||||
|
assert (none.toString() === "function(){/* ecmascript */}");
|
||||||
|
|
||||||
|
function single(b) { return 1; }
|
||||||
|
assert (single.toString() === "function(){/* ecmascript */}");
|
||||||
|
|
||||||
|
function multiple(a,b) { return 1; }
|
||||||
|
assert (multiple.toString() === "function(){/* ecmascript */}");
|
||||||
|
|
||||||
|
function lots(a,b,c,d,e,f,g,h,i,j,k) { return 1; }
|
||||||
|
assert (lots.toString() === "function(){/* ecmascript */}");
|
||||||
Loading…
x
Reference in New Issue
Block a user