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 --- .../prototype/bind/instance-length-tointeger.js | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 js/src/tests/test262/built-ins/Function/prototype/bind/instance-length-tointeger.js (limited to 'js/src/tests/test262/built-ins/Function/prototype/bind/instance-length-tointeger.js') diff --git a/js/src/tests/test262/built-ins/Function/prototype/bind/instance-length-tointeger.js b/js/src/tests/test262/built-ins/Function/prototype/bind/instance-length-tointeger.js new file mode 100644 index 0000000000..3d170b7222 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/bind/instance-length-tointeger.js @@ -0,0 +1,59 @@ +// Copyright (C) 2020 Alexey Shvayka. 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 non-negative integer. + ToInteger is performed on "length" value of target function. +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 Number, then + i. If targetLen is +∞𝔽, set L to +∞. + ii. Else if targetLen is -∞𝔽, set L to 0. + iii. Else, + 1. Let targetLenAsInt be ! ToIntegerOrInfinity(targetLen). + 2. Assert: targetLenAsInt is finite. + 3. Let argCount be the number of elements in args. + 4. Set L to max(targetLenAsInt - argCount, 0). + 7. Perform ! SetFunctionLength(F, L). + [...] + + ToInteger ( argument ) + + 1. Let number be ? ToNumber(argument). + 2. If number is NaN, +0, or -0, return +0. + 3. If number is +∞ or -∞, return number. + 4. Let integer be the Number value that is the same sign as number and whose magnitude is floor(abs(number)). + 5. If integer is -0, return +0. + 6. Return integer. +---*/ + +function fn() {} + +Object.defineProperty(fn, "length", {value: NaN}); +assert.sameValue(fn.bind().length, 0); + +Object.defineProperty(fn, "length", {value: -0}); +assert.sameValue(fn.bind().length, 0); + +Object.defineProperty(fn, "length", {value: Infinity}); +assert.sameValue(fn.bind().length, Infinity, "target length of infinity, zero bound arguments"); +assert.sameValue(fn.bind(0, 0).length, Infinity, "target length of infinity, one bound argument"); + +Object.defineProperty(fn, "length", {value: -Infinity}); +assert.sameValue(fn.bind().length, 0, "target length of negative infinity, zero bound arguments"); +assert.sameValue(fn.bind(0, 0).length, 0, "target length of negative infinity, one bound argument"); + +Object.defineProperty(fn, "length", {value: 3.66}); +assert.sameValue(fn.bind().length, 3); + +Object.defineProperty(fn, "length", {value: -0.77}); +assert.sameValue(fn.bind().length, 0); + +reportCompare(0, 0); -- cgit v1.2.3