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 --- .../of/BigInt/argument-is-symbol-throws.js | 35 ++++++++++++++++ .../of/BigInt/argument-number-value-throws.js | 43 ++++++++++++++++++++ .../TypedArrayConstructors/of/BigInt/browser.js | 0 .../custom-ctor-does-not-instantiate-ta-throws.js | 31 ++++++++++++++ .../BigInt/custom-ctor-returns-other-instance.js | 34 ++++++++++++++++ .../custom-ctor-returns-smaller-instance-throws.js | 29 +++++++++++++ .../of/BigInt/custom-ctor.js | 37 +++++++++++++++++ .../TypedArrayConstructors/of/BigInt/inherited.js | 27 +++++++++++++ .../of/BigInt/invoked-as-func.js | 26 ++++++++++++ .../of/BigInt/new-instance-empty.js | 18 +++++++++ .../of/BigInt/new-instance-using-custom-ctor.js | 30 ++++++++++++++ .../of/BigInt/new-instance.js | 47 ++++++++++++++++++++++ .../TypedArrayConstructors/of/BigInt/shell.js | 42 +++++++++++++++++++ .../of/BigInt/this-is-not-constructor.js | 26 ++++++++++++ 14 files changed, 425 insertions(+) create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/argument-is-symbol-throws.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/argument-number-value-throws.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/browser.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-does-not-instantiate-ta-throws.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-returns-other-instance.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-returns-smaller-instance-throws.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/inherited.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/invoked-as-func.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/new-instance-empty.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/new-instance-using-custom-ctor.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/new-instance.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/shell.js create mode 100644 js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/this-is-not-constructor.js (limited to 'js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt') diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/argument-is-symbol-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/argument-is-symbol-throws.js new file mode 100644 index 0000000000..86ebdca0c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/argument-is-symbol-throws.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.of +description: > + Throws a TypeError if argument is a Symbol +info: | + IntegerIndexedElementSet ( O, index, value ) + + Assert: O is an Integer-Indexed exotic object. + If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). + Otherwise, let numValue be ? ToNumber(value). + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then + Let offset be O.[[ByteOffset]]. + Let arrayTypeName be the String value of O.[[TypedArrayName]]. + Let elementSize be the Element Size value specified in Table 62 for arrayTypeName. + Let indexedPosition be (ℝ(index) × elementSize) + offset. + Let elementType be the Element Type value in Table 62 for arrayTypeName. + Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered). + Return NormalCompletion(undefined). + +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithBigIntTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + TA.of(s); + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/argument-number-value-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/argument-number-value-throws.js new file mode 100644 index 0000000000..c04362855e --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/argument-number-value-throws.js @@ -0,0 +1,43 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.of +description: > + Return abrupt from object value +info: | + 22.2.2.2 %TypedArray%.of ( ...items ) + + ... + 7. Repeat, while k < len + ... + c. Perform ? Set(newObj, Pk, kValue, true). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var lastValue = false; + + var obj1 = { + valueOf() { + lastValue = "obj1"; + return 42n; + } + }; + var obj2 = { + valueOf() { + lastValue = "obj2"; + throw new Test262Error(); + } + }; + + assert.throws(Test262Error, function() { + TA.of(obj1, obj2, obj1); + }); + + assert.sameValue(lastValue, "obj2"); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-does-not-instantiate-ta-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-does-not-instantiate-ta-throws.js new file mode 100644 index 0000000000..faa4a0dbc1 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-does-not-instantiate-ta-throws.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.of +description: > + Custom constructor needs to instantiate a TypedArray +info: | + 22.2.2.2 %TypedArray%.of ( ...items ) + + ... + 5. Let newObj be ? TypedArrayCreate(C, «len»). + ... + + 22.2.4.6 TypedArrayCreate ( constructor, argumentList ) + + 1. Let newTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateTypedArray(newTypedArray). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var ctor = function() {}; + + assert.throws(TypeError, function() { + TA.of.call(ctor, 42n); + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-returns-other-instance.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-returns-other-instance.js new file mode 100644 index 0000000000..9651789f07 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-returns-other-instance.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.of +description: > + Custom constructor can return any TypedArray instance with higher or same + length +info: | + %TypedArray%.of ( ...items ) + + 1. Let len be the actual number of arguments passed to this function. + ... + 5. Let newObj be ? TypedArrayCreate(C, « len »). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var result; + var custom = new TA(3); + var ctor = function() { + return custom; + }; + + result = TypedArray.of.call(ctor, 1n, 2n, 3n); + assert.sameValue(result, custom, "using iterator, same length"); + + result = TypedArray.of.call(ctor, 1n, 2n); + assert.sameValue(result, custom, "using iterator, higher length"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-returns-smaller-instance-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-returns-smaller-instance-throws.js new file mode 100644 index 0000000000..22d23ca509 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor-returns-smaller-instance-throws.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.of +description: > + Throws a TypeError if a custom `this` returns a smaller instance +info: | + %TypedArray%.of ( ...items ) + + 1. Let len be the actual number of arguments passed to this function. + ... + 5. Let newObj be ? TypedArrayCreate(C, « len »). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var ctor = function() { + return new TA(1); + }; + + assert.throws(TypeError, function() { + TypedArray.of.call(ctor, 1n, 2n); + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor.js new file mode 100644 index 0000000000..1feb266994 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/custom-ctor.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.of +description: > + Calls and return abrupt from custom constructor +info: | + 22.2.2.2 %TypedArray%.of ( ...items ) + + ... + 5. Let newObj be ? TypedArrayCreate(C, «len»). + ... + + 22.2.4.6 TypedArrayCreate ( constructor, argumentList ) + + 1. Let newTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateTypedArray(newTypedArray). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var called = 0; + var ctor = function() { + called++; + throw new Test262Error(); + }; + + assert.throws(Test262Error, function() { + TA.of.call(ctor, 42n); + }); + + assert.sameValue(called, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/inherited.js new file mode 100644 index 0000000000..f10783f101 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/inherited.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.of +description: > + `of` is %TypedArray%.of +info: | + 22.2.1 The %TypedArray% Intrinsic Object + + The %TypedArray% intrinsic object is a constructor function object that all of + the TypedArray constructor object inherit from. +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + assert.sameValue( + TA.of, TypedArray.of, + "method is inherited %TypedArray%.of" + ); + assert.sameValue( + TA.hasOwnProperty("of"), false, + "constructor does not define an own property named 'of'" + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/invoked-as-func.js new file mode 100644 index 0000000000..406b3d56ed --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/invoked-as-func.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.of +description: > + "of" cannot be invoked as a function +info: | + 22.2.2.2 %TypedArray%.of ( ...items ) + + ... + 3. Let C be the this value. + 4. If IsConstructor(C) is false, throw a TypeError exception. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var of = TA.of; + + assert.throws(TypeError, function() { + of(); + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/new-instance-empty.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/new-instance-empty.js new file mode 100644 index 0000000000..6a9669ee89 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/new-instance-empty.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.of +description: > + Return a new empty TypedArray +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var result = TA.of(); + assert.sameValue(result.length, 0); + assert.sameValue(result.constructor, TA); + assert.sameValue(Object.getPrototypeOf(result), TA.prototype); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/new-instance-using-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/new-instance-using-custom-ctor.js new file mode 100644 index 0000000000..2d933c8b06 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/new-instance-using-custom-ctor.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.of +description: > + Return a new TypedArray using a custom Constructor +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var called = 0; + + var ctor = function(len) { + assert.sameValue(arguments.length, 1); + called++; + return new TA(len); + }; + + + var result = TA.of.call(ctor, 42n, 43n, 42n); + assert.sameValue(result.length, 3); + assert.sameValue(result[0], 42n); + assert.sameValue(result[1], 43n); + assert.sameValue(result[2], 42n); + assert.sameValue(result.constructor, TA); + assert.sameValue(called, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/new-instance.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/new-instance.js new file mode 100644 index 0000000000..85dca677b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/new-instance.js @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.of +description: > + Return a new TypedArray +info: | + 9.4.5.5 [[Set]] ( P, V, Receiver) + + ... + 2. If Type(P) is String and if SameValue(O, Receiver) is true, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Perform ? IntegerIndexedElementSet(O, numericIndex, V). + ii. Return true. + ... + + IntegerIndexedElementSet ( O, index, value ) + + Assert: O is an Integer-Indexed exotic object. + If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). + Otherwise, let numValue be ? ToNumber(value). + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then + Let offset be O.[[ByteOffset]]. + Let arrayTypeName be the String value of O.[[TypedArrayName]]. + Let elementSize be the Element Size value specified in Table 62 for arrayTypeName. + Let indexedPosition be (ℝ(index) × elementSize) + offset. + Let elementType be the Element Type value in Table 62 for arrayTypeName. + Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered). + Return NormalCompletion(undefined). + +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var result = TA.of(42n, 43n, 0n); + assert.sameValue(result.length, 3); + assert.sameValue(result[0], 42n); + assert.sameValue(result[1], 43n); + assert.sameValue(result[2], 0n); + assert.sameValue(result.constructor, TA); + assert.sameValue(Object.getPrototypeOf(result), TA.prototype); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/shell.js new file mode 100644 index 0000000000..90ee9c114d --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/shell.js @@ -0,0 +1,42 @@ +// GENERATED, DO NOT EDIT +// file: testBigIntTypedArray.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 BigInt TypedArray objects. +defines: + - TypedArray + - testWithBigIntTypedArrayConstructors +---*/ + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * 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 testWithBigIntTypedArrayConstructors(f, selected) { + /** + * Array containing every BigInt typed array constructor. + */ + var constructors = selected || [ + BigInt64Array, + BigUint64Array + ]; + + 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; + } + } +} diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/this-is-not-constructor.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/this-is-not-constructor.js new file mode 100644 index 0000000000..b62da04aae --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/BigInt/this-is-not-constructor.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.of +description: > + Throws a TypeError exception if this is not a constructor +info: | + 22.2.2.2 %TypedArray%.of ( ...items ) + + ... + 3. Let C be the this value. + 4. If IsConstructor(C) is false, throw a TypeError exception. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var m = { m() {} }.m; + +testWithBigIntTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + TA.of.call(m, 0n); + }); +}); + +reportCompare(0, 0); -- cgit v1.2.3