summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Tuple/of
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/of
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/Tuple/of')
-rw-r--r--js/src/tests/non262/Tuple/of/length.js20
-rw-r--r--js/src/tests/non262/Tuple/of/name.js9
-rw-r--r--js/src/tests/non262/Tuple/of/not-a-constructor.js9
-rw-r--r--js/src/tests/non262/Tuple/of/of.js29
-rw-r--r--js/src/tests/non262/Tuple/of/prop-desc.js9
5 files changed, 76 insertions, 0 deletions
diff --git a/js/src/tests/non262/Tuple/of/length.js b/js/src/tests/non262/Tuple/of/length.js
new file mode 100644
index 0000000000..5038d3fc5e
--- /dev/null
+++ b/js/src/tests/non262/Tuple/of/length.js
@@ -0,0 +1,20 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var desc = Object.getOwnPropertyDescriptor(Tuple.of, "length");
+assertEq(desc.value, 0);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+desc = Object.getOwnPropertyDescriptor(Tuple.of, "name");
+assertEq(desc.value, "of");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.of), false);
+
+assertThrowsInstanceOf(() => {
+ new Tuple.of(1, 2, 3);
+}, TypeError, '`new Tuple.of(1, 2, 3)` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/of/name.js b/js/src/tests/non262/Tuple/of/name.js
new file mode 100644
index 0000000000..f09e793010
--- /dev/null
+++ b/js/src/tests/non262/Tuple/of/name.js
@@ -0,0 +1,9 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+var desc = Object.getOwnPropertyDescriptor(Tuple.of, "name");
+assertEq(desc.value, "of");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/of/not-a-constructor.js b/js/src/tests/non262/Tuple/of/not-a-constructor.js
new file mode 100644
index 0000000000..b397a820cd
--- /dev/null
+++ b/js/src/tests/non262/Tuple/of/not-a-constructor.js
@@ -0,0 +1,9 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+assertEq(isConstructor(Tuple.of), false);
+
+assertThrowsInstanceOf(() => {
+ new Tuple.of(1, 2, 3);
+}, TypeError, '`new Tuple.of(1, 2, 3)` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/of/of.js b/js/src/tests/non262/Tuple/of/of.js
new file mode 100644
index 0000000000..bbda64608d
--- /dev/null
+++ b/js/src/tests/non262/Tuple/of/of.js
@@ -0,0 +1,29 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.2.3 Tuple.of ( ...items )
+The of method takes any number of arguments, and performs the following steps:
+
+1. Let items be the List of arguments passed to this function.
+2. For each element e of items,
+a. If Type(e) is Object, throw a TypeError exception.
+3. Let tuple be a new Tuple value whose [[Sequence]] is items.
+4. Return tuple.
+*/
+
+assertEq(Tuple.of(), #[]);
+assertEq(Tuple.of(undefined), #[undefined]);
+assertEq(Tuple.of(null), #[null]);
+assertEq(Tuple.of(1), #[1]);
+assertEq(Tuple.of(1, 2), #[1,2]);
+assertEq(Tuple.of(true, 5, "monkeys", #[3, 4]), #[true, 5, "monkeys", #[3, 4]]);
+assertEq(Tuple.of(undefined, false, null, undefined), #[undefined, false, null, undefined]);
+
+/* Step 2a. */
+assertThrowsInstanceOf(() => Tuple.of([1, 2, 3]), TypeError,
+ "Tuple can't contain Object");
+assertThrowsInstanceOf(() => Tuple.of([]), TypeError,
+ "Tuple can't contain Object");
+assertThrowsInstanceOf(() => Tuple.of(new Object(), [1, 2, 3], new String("a")), TypeError,
+ "Tuple can't contain Object");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/of/prop-desc.js b/js/src/tests/non262/Tuple/of/prop-desc.js
new file mode 100644
index 0000000000..e797646531
--- /dev/null
+++ b/js/src/tests/non262/Tuple/of/prop-desc.js
@@ -0,0 +1,9 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+var desc = Object.getOwnPropertyDescriptor(Tuple, "of");
+assertEq(desc.value, Tuple.of);
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+reportCompare(0, 0);