From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../bind/instance-length-remaining-args.js | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 js/src/tests/test262/built-ins/Function/prototype/bind/instance-length-remaining-args.js (limited to 'js/src/tests/test262/built-ins/Function/prototype/bind/instance-length-remaining-args.js') diff --git a/js/src/tests/test262/built-ins/Function/prototype/bind/instance-length-remaining-args.js b/js/src/tests/test262/built-ins/Function/prototype/bind/instance-length-remaining-args.js new file mode 100644 index 0000000000..5a162187e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/bind/instance-length-remaining-args.js @@ -0,0 +1,37 @@ +// 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'); + +reportCompare(0, 0); -- cgit v1.2.3