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 --- .../tests/non262/Tuple/prototype/includes/includes.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 js/src/tests/non262/Tuple/prototype/includes/includes.js (limited to 'js/src/tests/non262/Tuple/prototype/includes/includes.js') diff --git a/js/src/tests/non262/Tuple/prototype/includes/includes.js b/js/src/tests/non262/Tuple/prototype/includes/includes.js new file mode 100644 index 0000000000..26ef2bfb03 --- /dev/null +++ b/js/src/tests/non262/Tuple/prototype/includes/includes.js @@ -0,0 +1,18 @@ +// |reftest| skip-if(!this.hasOwnProperty("Tuple")) +/* +8.2.3.7 Tuple.prototype.includes ( searchElement [ , fromIndex ] ) +Tuple.prototype.includes is a distinct function that implements the same algorithm as Array.prototype.includes as defined in 22.1.3.13 except that ? thisTupleValue(this value) is used instead of directly accessing the this value. The implementation of the algorithm may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse, do not change, and their access is not observable. However, such optimization must not introduce any observable changes in the specified behaviour of the algorithm. + +This function is not generic, since thisTupleValue(this value) can return an abrupt completion: in that case, that exception is thrown instead of evaluating the algorithm. +*/ + +/* Step 1 */ +/* includes() should throw on a non-Tuple */ +let method = Tuple.prototype.includes; +assertEq(method.call(#[1,2,3,4,5,6], 2), true); +assertEq(method.call(Object(#[1,2,3,4,5,6]), 2), true); +assertThrowsInstanceOf(() => method.call("monkeys", 2), TypeError, + "value of TupleObject must be a Tuple"); + +/* Not sure what else to test, since it just calls the array method */ +reportCompare(0, 0); -- cgit v1.2.3