mirror of https://github.com/tc39/test262.git
Merge & refactor bound function "length" property descriptor tests
This commit is contained in:
parent
897a05954f
commit
f80d7e7777
|
@ -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');
|
|
|
@ -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")');
|
|
|
@ -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');
|
|
|
@ -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);
|
|
|
@ -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');
|
|
|
@ -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');
|
|
|
@ -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,
|
||||||
|
});
|
Loading…
Reference in New Issue