diff --git a/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-2.js b/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-2.js deleted file mode 100644 index a99ce8cd2e..0000000000 --- a/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-2.js +++ /dev/null @@ -1,16 +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-2 -description: > - Function.prototype.bind, 'length' set to remaining number of - expected args ----*/ - -function foo(x, y) {} -var o = {}; - -var bf = foo.bind(o); - -assert.sameValue(bf.length, 2, 'bf.length'); diff --git a/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-3.js b/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-3.js deleted file mode 100644 index c712aad440..0000000000 --- a/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-3.js +++ /dev/null @@ -1,16 +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-3 -description: > - Function.prototype.bind, 'length' set to remaining number of - expected args (all args prefilled) ----*/ - -function foo(x, y) {} -var o = {}; - -var bf = foo.bind(o, 42, 101); - -assert.sameValue(bf.length, 0, 'bf.length'); diff --git a/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-4.js b/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-4.js deleted file mode 100644 index 8fe162a201..0000000000 --- a/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-4.js +++ /dev/null @@ -1,16 +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-4 -description: > - Function.prototype.bind, 'length' set to remaining number of - expected args (target takes 0 args) ----*/ - -function foo() {} -var o = {}; - -var bf = foo.bind(o); - -assert.sameValue(bf.length, 0, 'bf.length'); diff --git a/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-5.js b/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-5.js deleted file mode 100644 index c95236da25..0000000000 --- a/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-5.js +++ /dev/null @@ -1,16 +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-5 -description: > - Function.prototype.bind, 'length' set to remaining number of - expected args (target provided extra args) ----*/ - -function foo() {} -var o = {}; - -var bf = foo.bind(o, 42); - -assert.sameValue(bf.length, 0, 'bf.length'); diff --git a/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-6.js b/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-6.js deleted file mode 100644 index 8b50e13470..0000000000 --- a/test/built-ins/Function/prototype/bind/15.3.4.5-13.b-6.js +++ /dev/null @@ -1,16 +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-6 -description: > - Function.prototype.bind, 'length' set to remaining number of - expected args ----*/ - -function foo(x, y) {} -var o = {}; - -var bf = foo.bind(o, 42); - -assert.sameValue(bf.length, 1, 'bf.length'); diff --git a/test/built-ins/Function/prototype/bind/instance-length-remaining-args.js b/test/built-ins/Function/prototype/bind/instance-length-remaining-args.js new file mode 100644 index 0000000000..d2406b8ca9 --- /dev/null +++ b/test/built-ins/Function/prototype/bind/instance-length-remaining-args.js @@ -0,0 +1,35 @@ +// 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" value of a bound function is set to remaining number + of arguments expected by target function. Extra arguments are ignored. +info: | + Function.prototype.bind ( thisArg, ...args ) + + [...] + 5. Let targetHasLength be ? HasOwnProperty(Target, "length"). + 6. If targetHasLength is true, then + a. Let targetLen be ? Get(Target, "length"). + b. If Type(targetLen) is not Number, let L be 0. + c. Else, + i. Set targetLen to ! ToInteger(targetLen). + ii. Let L be the larger of 0 and the result of targetLen minus the number of elements of args. + 7. Else, let L be 0. + 8. Perform ! SetFunctionLength(F, L). + [...] +---*/ + +function foo() {} + +assert.sameValue(foo.bind(null).length, 0, '0/0'); +assert.sameValue(foo.bind(null, 1).length, 0, '1/0'); + +function bar(x, y) {} + +assert.sameValue(bar.bind(null).length, 2, '0/2'); +assert.sameValue(bar.bind(null, 1).length, 1, '1/2'); +assert.sameValue(bar.bind(null, 1, 2).length, 0, '2/2'); +assert.sameValue(bar.bind(null, 1, 2, 3).length, 0, '3/2');