summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Tuple/constructor/8.2.1.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/constructor/8.2.1.js
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/Tuple/constructor/8.2.1.js')
-rw-r--r--js/src/tests/non262/Tuple/constructor/8.2.1.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/js/src/tests/non262/Tuple/constructor/8.2.1.js b/js/src/tests/non262/Tuple/constructor/8.2.1.js
new file mode 100644
index 0000000000..0e43551f8f
--- /dev/null
+++ b/js/src/tests/non262/Tuple/constructor/8.2.1.js
@@ -0,0 +1,55 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.1 The Tuple Constructor
+The Tuple constructor:
+
+is the intrinsic object %Tuple%.
+*/
+
+assertEq(typeof Tuple, "function");
+assertEq(typeof Tuple.prototype, "object");
+
+/*
+is the initial value of the "Tuple" property of the global object.
+*/
+assertEq(this.Tuple, Tuple);
+
+/*
+creates and initializes a new Tuple object when called as a function.
+*/
+assertEq(Tuple(), #[]);
+assertEq(Tuple(1), #[1]);
+assertEq(Tuple("a", 1, true), #["a", 1, true]);
+/* 8.2.1.1
+3. For each element e of items,
+a. If Type(e) is Object, throw a TypeError exception.
+*/
+assertThrowsInstanceOf(() => Tuple("a", new Object()), TypeError,
+ "Object in Tuple");
+
+/*
+is not intended to be used with the new operator or to be subclassed.
+*/
+/* 8.2.1.1
+1. If NewTarget is not undefined, throw a TypeError exception.
+*/
+assertThrowsInstanceOf(() => new Tuple(1, 2, 3), TypeError, "Tuple is not intended to be used with the new operator");
+
+
+/* It may be used as the value of an extends clause of a class definition but a super call to the Tuple constructor will cause an exception.
+*/
+class C extends Tuple{}; // class declaration is allowed
+// super() is called implicitly
+assertThrowsInstanceOf (() => new C(), TypeError, "super call to Tuple constructor");
+class D extends Tuple {
+ constructor() {
+ super();
+ }
+};
+// Explicit call to super() will also throw
+assertThrowsInstanceOf(() => new D(), TypeError, "super call to Tuple constructor");
+
+reportCompare(0, 0);
+
+
+