Fix attributes of length property for bound function (#3659)

fix length property of bound function objects to be configurable (ECMA-262 v6, 19.2.4.1)

JerryScript-DCO-1.0-Signed-off-by: HyukWoo Park hyukwoo.park@samsung.com
This commit is contained in:
Hyukwoo Park
2020-04-04 09:04:02 +09:00
committed by GitHub
parent e470b13096
commit 73a78bd223
7 changed files with 153 additions and 58 deletions
+19 -1
View File
@@ -105,8 +105,10 @@ var builtin_typedArrays = [
/* test length property of function objects */
var normal_func = function () {};
var arrow_func = () => {};
var bound_func = normal_func.bind({});
var nested_bound_func = arrow_func.bind().bind(1);
var functions = [normal_func, arrow_func];
var functions = [normal_func, arrow_func, bound_func, nested_bound_func];
for (func of functions) {
var desc = Object.getOwnPropertyDescriptor(func, 'length');
@@ -121,3 +123,19 @@ var builtin_typedArrays = [
assert(func.hasOwnProperty('length') === false);
}
})();
(function() {
/* changing the length of f affects the bound function */
function f(a,b,c) {}
Object.defineProperty(f, "length", { value: 30 });
var g = f.bind(1,2)
assert(g.length === 29);
})();
(function() {
/* changing the length of f does not affect the bound function */
function f(a,b,c) {}
var g = f.bind(1,2)
Object.defineProperty(f, "length", { value: 30 });
assert(g.length === 2);
})();