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 --- js/src/tests/non262/Tuple/constructor/8.2.1.js | 55 ++++++++++++++++++++++ js/src/tests/non262/Tuple/constructor/8.2.2.js | 11 +++++ .../tests/non262/Tuple/constructor/call-method.js | 17 +++++++ .../non262/Tuple/constructor/is-a-constructor.js | 4 ++ js/src/tests/non262/Tuple/constructor/length.js | 13 +++++ js/src/tests/non262/Tuple/constructor/name.js | 20 ++++++++ 6 files changed, 120 insertions(+) create mode 100644 js/src/tests/non262/Tuple/constructor/8.2.1.js create mode 100644 js/src/tests/non262/Tuple/constructor/8.2.2.js create mode 100644 js/src/tests/non262/Tuple/constructor/call-method.js create mode 100644 js/src/tests/non262/Tuple/constructor/is-a-constructor.js create mode 100644 js/src/tests/non262/Tuple/constructor/length.js create mode 100644 js/src/tests/non262/Tuple/constructor/name.js (limited to 'js/src/tests/non262/Tuple/constructor') 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); + + -- cgit v1.2.3