From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../Uint32Array/BYTES_PER_ELEMENT.js | 23 +++ .../TypedArrayConstructors/Uint32Array/browser.js | 0 .../Uint32Array/constructor.js | 13 ++ .../Uint32Array/is-a-constructor.js | 26 +++ .../TypedArrayConstructors/Uint32Array/length.js | 30 ++++ .../TypedArrayConstructors/Uint32Array/name.js | 30 ++++ .../TypedArrayConstructors/Uint32Array/proto.js | 16 ++ .../Uint32Array/prototype.js | 22 +++ .../Uint32Array/prototype/BYTES_PER_ELEMENT.js | 23 +++ .../Uint32Array/prototype/browser.js | 0 .../Uint32Array/prototype/constructor.js | 26 +++ .../Uint32Array/prototype/not-typedarray-object.js | 19 +++ .../Uint32Array/prototype/proto.js | 17 ++ .../Uint32Array/prototype/shell.js | 0 .../TypedArrayConstructors/Uint32Array/shell.js | 185 +++++++++++++++++++++ 15 files changed, 430 insertions(+) create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/BYTES_PER_ELEMENT.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/browser.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/constructor.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/is-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/length.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/name.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/proto.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/BYTES_PER_ELEMENT.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/browser.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/constructor.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/not-typedarray-object.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/proto.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/shell.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/shell.js (limited to 'js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array') diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/BYTES_PER_ELEMENT.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/BYTES_PER_ELEMENT.js new file mode 100644 index 0000000000..d6bfc95a61 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/BYTES_PER_ELEMENT.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray.bytes_per_element +description: > + The initial value of Uint32Array.BYTES_PER_ELEMENT is 4. +info: | + The value of TypedArray.BYTES_PER_ELEMENT is the Number value of the + Element Size value specified in Table 49 for TypedArray. + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. +includes: [propertyHelper.js] +features: [TypedArray] +---*/ + +assert.sameValue(Uint32Array.BYTES_PER_ELEMENT, 4); + +verifyNotEnumerable(Uint32Array, "BYTES_PER_ELEMENT"); +verifyNotWritable(Uint32Array, "BYTES_PER_ELEMENT"); +verifyNotConfigurable(Uint32Array, "BYTES_PER_ELEMENT"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/browser.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/constructor.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/constructor.js new file mode 100644 index 0000000000..d68134350b --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/constructor.js @@ -0,0 +1,13 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray-constructors +description: > + Uint32Array is a constructor function. +features: [TypedArray] +---*/ + +assert.sameValue(typeof Uint32Array, 'function', 'typeof Uint32Array is "function"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/is-a-constructor.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/is-a-constructor.js new file mode 100644 index 0000000000..9c082743aa --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/is-a-constructor.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + The Uint32Array constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct, TypedArray] +---*/ + +assert.sameValue(isConstructor(Uint32Array), true, 'isConstructor(Uint32Array) must return true'); +new Uint32Array(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/length.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/length.js new file mode 100644 index 0000000000..2f43b323eb --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray-constructors +description: Uint32Array.length property descriptor +info: | + The TypedArray Constructors + + The length property of the TypedArray constructor function is 3. + + 17 ECMAScript Standard Built-in Objects + + ... + + Unless otherwise specified, the length property of a built-in function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [TypedArray] +---*/ + +verifyProperty(Uint32Array, "length", { + value: 3, + writable: false, + enumerable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/name.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/name.js new file mode 100644 index 0000000000..231782fbf9 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/name.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-the-typedarray-constructors +description: > + Uint32Array.name is "Uint32Array". +info: | + Each TypedArray constructor has a name property whose value is the + String value of the constructor name specified for it in Table 49. + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [TypedArray] +---*/ + +assert.sameValue(Uint32Array.name, "Uint32Array"); + +verifyNotEnumerable(Uint32Array, "name"); +verifyNotWritable(Uint32Array, "name"); +verifyConfigurable(Uint32Array, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/proto.js new file mode 100644 index 0000000000..23afd396b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/proto.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-the-typedarray-constructors +description: > + The prototype of Uint32Array is %TypedArray%. +info: | + The value of the [[Prototype]] internal slot of each TypedArray constructor is the %TypedArray% intrinsic object (22.2.1). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +assert.sameValue(Object.getPrototypeOf(Uint32Array), TypedArray); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype.js new file mode 100644 index 0000000000..47a31f0c1f --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray.prototype +description: > + The initial value of Uint32Array.prototype is the Uint32Array prototype object. +info: | + The initial value of TypedArray.prototype is the corresponding TypedArray prototype intrinsic object (22.2.6). + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. +includes: [propertyHelper.js] +features: [TypedArray] +---*/ + +assert.sameValue(Uint32Array.prototype, Object.getPrototypeOf(new Uint32Array(0))); + +verifyNotEnumerable(Uint32Array, "prototype"); +verifyNotWritable(Uint32Array, "prototype"); +verifyNotConfigurable(Uint32Array, "prototype"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/BYTES_PER_ELEMENT.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/BYTES_PER_ELEMENT.js new file mode 100644 index 0000000000..f75d146066 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/BYTES_PER_ELEMENT.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray.prototype.bytes_per_element +description: > + The initial value of Uint32Array.prototype.BYTES_PER_ELEMENT is 4. +info: | + The value of TypedArray.prototype.BYTES_PER_ELEMENT is the Number value + of the Element Size value specified in Table 49 for TypedArray. + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. +includes: [propertyHelper.js] +features: [TypedArray] +---*/ + +assert.sameValue(Uint32Array.prototype.BYTES_PER_ELEMENT, 4); + +verifyNotEnumerable(Uint32Array.prototype, "BYTES_PER_ELEMENT"); +verifyNotWritable(Uint32Array.prototype, "BYTES_PER_ELEMENT"); +verifyNotConfigurable(Uint32Array.prototype, "BYTES_PER_ELEMENT"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/browser.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/constructor.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/constructor.js new file mode 100644 index 0000000000..04a94a3139 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/constructor.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray.prototype.constructor +description: > + The initial value of Uint32Array.prototype.constructor is the Uint32Array object. +info: | + The initial value of Uint32Array.prototype.constructor is the intrinsic + object %Uint32Array%. + + 17 ECMAScript Standard Built-in Objects: + Every other data property described in clauses 18 through 26 and in Annex B.2 has + the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } + unless otherwise specified. +includes: [propertyHelper.js] +features: [TypedArray] +---*/ + +assert.sameValue(Uint32Array.prototype.constructor, Uint32Array); + +verifyNotEnumerable(Uint32Array.prototype, "constructor"); +verifyWritable(Uint32Array.prototype, "constructor"); +verifyConfigurable(Uint32Array.prototype, "constructor"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/not-typedarray-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/not-typedarray-object.js new file mode 100644 index 0000000000..31c49abe88 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/not-typedarray-object.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-typedarray-prototype-objects +description: > + Uint32Array.prototype is not a TypedArray instance object. +info: | + A TypedArray prototype object is an ordinary object. It does not have + a [[ViewedArrayBuffer]] or any other of the internal slots that are + specific to TypedArray instance objects. +features: [TypedArray] +---*/ + +assert.throws(TypeError, function() { + Uint32Array.prototype.buffer; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/proto.js new file mode 100644 index 0000000000..db175cdf0f --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/proto.js @@ -0,0 +1,17 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-typedarray-prototype-objects +description: > + The prototype of Uint32Array.prototype is %TypedArrayPrototype%. +info: | + The value of the [[Prototype]] internal slot of a TypedArray prototype + object is the intrinsic object %TypedArrayPrototype% (22.2.3). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +assert.sameValue(Object.getPrototypeOf(Uint32Array.prototype), TypedArray.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/shell.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/shell.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/shell.js new file mode 100644 index 0000000000..5df045b291 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/shell.js @@ -0,0 +1,185 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} + +// file: testTypedArray.js +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - floatArrayConstructors + - nonClampedIntArrayConstructors + - intArrayConstructors + - typedArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - nonAtomicsFriendlyTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +var floatArrayConstructors = [ + Float64Array, + Float32Array +]; + +var nonClampedIntArrayConstructors = [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array +]; + +var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]); + +// Float16Array is a newer feature +// adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it +if (typeof Float16Array !== 'undefined') { + floatArrayConstructors.push(Float16Array); +} + +/** + * Array containing every non-bigint typed array constructor. + */ + +var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]); +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} + +/** + * Checks if the given argument is one of the float-based TypedArray constructors. + * + * @param {constructor} ctor - the value to check + * @returns {boolean} + */ +function isFloatTypedArrayConstructor(arg) { + return floatArrayConstructors.indexOf(arg) !== -1; +} + +/** + * Determines the precision of the given float-based TypedArray constructor. + * + * @param {constructor} ctor - the value to check + * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively. + */ +function floatTypedArrayConstructorPrecision(FA) { + if (typeof Float16Array !== "undefined" && FA === Float16Array) { + return "half"; + } else if (FA === Float32Array) { + return "single"; + } else if (FA === Float64Array) { + return "double"; + } else { + throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray"); + } +} -- cgit v1.2.3