summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Tuple/prototype/indexOf/includes.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/non262/Tuple/prototype/indexOf/includes.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/includes.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/includes.js b/js/src/tests/non262/Tuple/prototype/indexOf/includes.js
new file mode 100644
index 0000000000..26ef2bfb03
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/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);