summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Tuple/constructor
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
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/constructor.js18
-rw-r--r--js/src/tests/non262/Tuple/constructor/8.2.1.js55
-rw-r--r--js/src/tests/non262/Tuple/constructor/8.2.2.js11
-rw-r--r--js/src/tests/non262/Tuple/constructor/call-method.js17
-rw-r--r--js/src/tests/non262/Tuple/constructor/is-a-constructor.js4
-rw-r--r--js/src/tests/non262/Tuple/constructor/length.js13
-rw-r--r--js/src/tests/non262/Tuple/constructor/name.js20
7 files changed, 138 insertions, 0 deletions
diff --git a/js/src/tests/non262/Tuple/constructor.js b/js/src/tests/non262/Tuple/constructor.js
new file mode 100644
index 0000000000..067a5d5ea2
--- /dev/null
+++ b/js/src/tests/non262/Tuple/constructor.js
@@ -0,0 +1,18 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+assertThrowsInstanceOf(
+ () => new Tuple(),
+ TypeError,
+ "Tuple is not a constructor"
+);
+
+assertEq(typeof Tuple(), "tuple");
+assertEq(typeof Object(Tuple()), "object");
+assertEq(Tuple() instanceof Tuple, false);
+assertEq(Object(Tuple()) instanceof Tuple, true);
+
+assertEq(Tuple().__proto__, Tuple.prototype);
+assertEq(Object(Tuple()).__proto__, Tuple.prototype);
+assertEq(Tuple.prototype.constructor, Tuple);
+
+if (typeof reportCompare === "function") reportCompare(0, 0);
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);
+
+
+
diff --git a/js/src/tests/non262/Tuple/constructor/8.2.2.js b/js/src/tests/non262/Tuple/constructor/8.2.2.js
new file mode 100644
index 0000000000..938f7896d7
--- /dev/null
+++ b/js/src/tests/non262/Tuple/constructor/8.2.2.js
@@ -0,0 +1,11 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+/*
+8.2.2 Properties of the Tuple Constructor
+The Tuple constructor:
+
+has a [[Prototype]] internal slot whose value is %Function.prototype%.
+*/
+assertEq(Object.getPrototypeOf(Tuple), Function.prototype);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/constructor/call-method.js b/js/src/tests/non262/Tuple/constructor/call-method.js
new file mode 100644
index 0000000000..8675240029
--- /dev/null
+++ b/js/src/tests/non262/Tuple/constructor/call-method.js
@@ -0,0 +1,17 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+10.2 ECMAScript Function Objects
+...
+All ECMAScript function objects have the [[Call]] internal method defined here. ECMAScript functions that are also constructors in addition have the [[Construct]] internal method.
+*/
+
+assertEq(Tuple.call(), #[]);
+assertEq(Tuple.call(undefined), #[]);
+assertEq(Tuple.call(undefined, 1), #[1]);
+assertEq(Tuple.call(2, 1), #[1]);
+assertEq(Tuple.call(#[], 1), #[1]);
+assertEq(Tuple.call(undefined, 1, 2, 3), #[1,2,3]);
+assertEq(Tuple.call(6, 1, 2, 3), #[1,2,3]);
+assertEq(Tuple.call(#[1], 1, 2, 3), #[1,2,3]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/constructor/is-a-constructor.js b/js/src/tests/non262/Tuple/constructor/is-a-constructor.js
new file mode 100644
index 0000000000..4ad4ee1560
--- /dev/null
+++ b/js/src/tests/non262/Tuple/constructor/is-a-constructor.js
@@ -0,0 +1,4 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+assertEq(isConstructor(Tuple), true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/constructor/length.js b/js/src/tests/non262/Tuple/constructor/length.js
new file mode 100644
index 0000000000..67169ef0d1
--- /dev/null
+++ b/js/src/tests/non262/Tuple/constructor/length.js
@@ -0,0 +1,13 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+18 ECMAScript Standard Built-in Objects
+...
+Every built-in function object, including constructors, has a "length" property whose value is a non-negative integral Number. Unless otherwise specified, this value is equal to the number of required parameters shown in the subclause heading for the function description. Optional parameters and rest parameters are not included in the parameter count.
+*/
+var desc = Object.getOwnPropertyDescriptor(Tuple, "length");
+assertEq(desc.value, 0);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/constructor/name.js b/js/src/tests/non262/Tuple/constructor/name.js
new file mode 100644
index 0000000000..6656c2ee54
--- /dev/null
+++ b/js/src/tests/non262/Tuple/constructor/name.js
@@ -0,0 +1,20 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+18 ECMAScript Standard Built-in Objects
+
+Every built-in function object, including constructors, has a "name" property whose value is a String. Unless otherwise specified, this value is the name that is given to the function in this specification. Functions that are identified as anonymous functions use the empty String as the value of the "name" property.
+...
+Unless otherwise specified, the "name" property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
+*/
+
+
+var desc = Object.getOwnPropertyDescriptor(Tuple, "name");
+assertEq(desc.value, "Tuple");
+
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+reportCompare(0, 0);
+
+