From f80d7e777761ee4b4791c52e98e2761d6edeee21 Mon Sep 17 00:00:00 2001 From: Alexey Shvayka Date: Tue, 18 Aug 2020 22:54:19 +0300 Subject: [PATCH] Merge & refactor bound function "length" property descriptor tests --- .../prototype/bind/15.3.4.5-13.b-1.js | 14 --------- .../Function/prototype/bind/15.3.4.5-15-1.js | 17 ----------- .../Function/prototype/bind/15.3.4.5-15-2.js | 19 ------------ .../Function/prototype/bind/15.3.4.5-15-3.js | 18 ----------- .../Function/prototype/bind/15.3.4.5-15-4.js | 24 --------------- .../Function/prototype/bind/15.3.4.5-15-5.js | 21 ------------- .../bind/instance-length-prop-desc.js | 30 +++++++++++++++++++ 7 files changed, 30 insertions(+), 113 deletions(-) delete mode 100644 test/built-ins/Function/prototype/bind/15.3.4.5-13.b-1.js delete mode 100644 test/built-ins/Function/prototype/bind/15.3.4.5-15-1.js delete mode 100644 test/built-ins/Function/prototype/bind/15.3.4.5-15-2.js delete mode 100644 test/built-ins/Function/prototype/bind/15.3.4.5-15-3.js delete mode 100644 test/built-ins/Function/prototype/bind/15.3.4.5-15-4.js delete mode 100644 test/built-ins/Function/prototype/bind/15.3.4.5-15-5.js create mode 100644 test/built-ins/Function/prototype/bind/instance-length-prop-desc.js diff --git a/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-1.js b/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-1.js deleted file mode 100644 index c1dfb471a2..0000000000 --- a/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.3.4.5-13.b-1 -description: Function.prototype.bind, bound fn has a 'length' own property ----*/ - -function foo() {} -var o = {}; - -var bf = foo.bind(o); - -assert(bf.hasOwnProperty('length'), 'bf.hasOwnProperty("length") !== true'); diff --git a/test/built-ins/Function/prototype/bind/15.3.4.5-15-1.js b/test/built-ins/Function/prototype/bind/15.3.4.5-15-1.js deleted file mode 100644 index e2ca7cfe83..0000000000 --- a/test/built-ins/Function/prototype/bind/15.3.4.5-15-1.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.3.4.5-15-1 -description: Function.prototype.bind, 'length' is a data valued own property ----*/ - -function foo() {} -var o = {}; - -var bf = foo.bind(o); -var desc = Object.getOwnPropertyDescriptor(bf, 'length'); - -assert.sameValue(desc.hasOwnProperty('value'), true, 'desc.hasOwnProperty("value")'); -assert.sameValue(desc.hasOwnProperty('get'), false, 'desc.hasOwnProperty("get")'); -assert.sameValue(desc.hasOwnProperty('set'), false, 'desc.hasOwnProperty("set")'); diff --git a/test/built-ins/Function/prototype/bind/15.3.4.5-15-2.js b/test/built-ins/Function/prototype/bind/15.3.4.5-15-2.js deleted file mode 100644 index 11cad43ede..0000000000 --- a/test/built-ins/Function/prototype/bind/15.3.4.5-15-2.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.3.4.5-15-2 -description: > - Function.prototype.bind, 'length' is a data valued own property ----*/ - -function foo() {} -var o = {}; - -var bf = foo.bind(o); -var desc = Object.getOwnPropertyDescriptor(bf, 'length'); - -assert.sameValue(desc.value, 0, 'desc.value'); -assert.sameValue(desc.enumerable, false, 'desc.enumerable'); -assert.sameValue(desc.writable, false, 'desc.writable'); -assert.sameValue(desc.configurable, true, 'desc.configurable'); diff --git a/test/built-ins/Function/prototype/bind/15.3.4.5-15-3.js b/test/built-ins/Function/prototype/bind/15.3.4.5-15-3.js deleted file mode 100644 index 8c5f06f4c0..0000000000 --- a/test/built-ins/Function/prototype/bind/15.3.4.5-15-3.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.3.4.5-15-3 -description: > - Function.prototype.bind - The [[Writable]] attribute of length - property in F set as false -includes: [propertyHelper.js] ----*/ - -function foo() {} -var obj = foo.bind({}); -var flength = obj.length; - -assert(obj.hasOwnProperty("length")); -verifyNotWritable(obj, "length", null, 100); -assert.sameValue(obj.length, flength); diff --git a/test/built-ins/Function/prototype/bind/15.3.4.5-15-4.js b/test/built-ins/Function/prototype/bind/15.3.4.5-15-4.js deleted file mode 100644 index 1ac7dc4c67..0000000000 --- a/test/built-ins/Function/prototype/bind/15.3.4.5-15-4.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.3.4.5-15-4 -description: > - Function.prototype.bind - The [[Enumerable]] attribute of length - property in F set as false ----*/ - -var canEnumerable = false; -var hasProperty = false; - -function foo() {} -var obj = foo.bind({}); -hasProperty = obj.hasOwnProperty("length"); -for (var prop in obj) { - if (prop === "length") { - canEnumerable = true; - } -} - -assert(hasProperty, 'hasProperty !== true'); -assert.sameValue(canEnumerable, false, 'canEnumerable'); diff --git a/test/built-ins/Function/prototype/bind/15.3.4.5-15-5.js b/test/built-ins/Function/prototype/bind/15.3.4.5-15-5.js deleted file mode 100644 index 447d9d6171..0000000000 --- a/test/built-ins/Function/prototype/bind/15.3.4.5-15-5.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2012 Ecma International. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 15.3.4.5-15-5 -description: > - Function.prototype.bind - The [[Configurable]] attribute of length - property in F set as true ----*/ - -var canConfigurable = false; -var hasProperty = false; - -function foo() {} -var obj = foo.bind({}); -hasProperty = obj.hasOwnProperty("length"); -delete obj.length; -canConfigurable = !obj.hasOwnProperty("length"); - -assert(hasProperty, 'hasProperty !== true'); -assert(canConfigurable, 'canConfigurable !== true'); diff --git a/test/built-ins/Function/prototype/bind/instance-length-prop-desc.js b/test/built-ins/Function/prototype/bind/instance-length-prop-desc.js new file mode 100644 index 0000000000..5b930bb365 --- /dev/null +++ b/test/built-ins/Function/prototype/bind/instance-length-prop-desc.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-function.prototype.bind +description: > + "length" property of a bound function has correct descriptor. +info: | + Function.prototype.bind ( thisArg, ...args ) + + [...] + 8. Perform ! SetFunctionLength(F, L). + [...] + + SetFunctionLength ( F, length ) + + [...] + 4. Return ! DefinePropertyOrThrow(F, "length", PropertyDescriptor { [[Value]]: + length, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }). +includes: [propertyHelper.js] +---*/ + +function fn() {} + +verifyProperty(fn.bind(null), "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true, +});