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 --- .../prototype/byteLength/BigInt/browser.js | 0 .../prototype/byteLength/BigInt/detached-buffer.js | 23 +++++++++ .../BigInt/resizable-array-buffer-auto.js | 56 ++++++++++++++++++++++ .../BigInt/resizable-array-buffer-fixed.js | 49 +++++++++++++++++++ .../byteLength/BigInt/return-bytelength.js | 26 ++++++++++ .../prototype/byteLength/BigInt/shell.js | 42 ++++++++++++++++ 6 files changed, 196 insertions(+) create mode 100644 js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/browser.js create mode 100644 js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js create mode 100644 js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js create mode 100644 js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js create mode 100644 js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js create mode 100644 js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/shell.js (limited to 'js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt') diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js new file mode 100644 index 0000000000..e31373224f --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js @@ -0,0 +1,23 @@ +// 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-get-%typedarray%.prototype.bytelength +description: Returns 0 if the instance has a detached buffer +info: | + 22.2.3.2 get %TypedArray%.prototype.byteLength + + ... + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 5. If IsDetachedBuffer(buffer) is true, return 0. + ... +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.sameValue(sample.byteLength, 0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js new file mode 100644 index 0000000000..213890e122 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js @@ -0,0 +1,56 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the dynamically-sized TypedArray instance +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithBigIntTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE); + var expected = BPE * 3; + + assert.sameValue(array.byteLength, expected); + + try { + ab.resize(BPE * 5); + expected = BPE * 4; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following grow"); + + try { + ab.resize(BPE * 3); + expected = BPE * 2; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following shrink (within bounds)"); + + try { + ab.resize(BPE); + expected = 0; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following shrink (on boundary)"); + + try { + ab.resize(0); + expected = 0; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following shrink (out of bounds)"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js new file mode 100644 index 0000000000..dfbf3ba5b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js @@ -0,0 +1,49 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the fixed-sized TypedArray instance +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithBigIntTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + assert.sameValue(array.byteLength, BPE * 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + assert.sameValue(array.byteLength, BPE * 2, "following grow"); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + assert.sameValue(array.byteLength, BPE * 2, "following shrink (within bounds)"); + + var expected; + try { + ab.resize(BPE * 2); + expected = 0; + } catch (_) { + expected = BPE * 2; + } + + assert.sameValue(array.byteLength, expected, "following shrink (out of bounds)"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js new file mode 100644 index 0000000000..36e9352f98 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/return-bytelength.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-get-%typedarray%.prototype.bytelength +description: > + Return value from [[ByteLength]] internal slot +info: | + 22.2.3.2 get %TypedArray%.prototype.byteLength + + ... + 6. Let size be the value of O's [[ByteLength]] internal slot. + 7. Return size. +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var bytesPerElement = TA.BYTES_PER_ELEMENT; + var ta1 = new TA(); + assert.sameValue(ta1.byteLength, 0); + + var ta2 = new TA(42); + assert.sameValue(ta2.byteLength, 42 * bytesPerElement); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/shell.js new file mode 100644 index 0000000000..90ee9c114d --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/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; + } + } +} -- cgit v1.2.3