Debian Codegraph @

js/src/tests/test262/built-ins/Atomics/wait/bigint/null-bufferdata-throws.js

raw
1 // |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
2 // Copyright (C) 2018 Amal Hussein. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-atomics.wait
6 description: >
7 A null value for bufferData throws a TypeError
8 info: |
9 Atomics.wait( typedArray, index, value, timeout )
10
11 1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
12 ...
13
14 ValidateSharedIntegerTypedArray(typedArray [ , onlyInt32 ] )
15
16 ...
17 9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
18
19
20 IsSharedArrayBuffer( obj )
21
22 ...
23 3.If bufferData is null, return false.
24
25 includes: [detachArrayBuffer.js]
26 features: [ArrayBuffer, Atomics, BigInt, TypedArray]
27 ---*/
28
29 const i64a = new BigInt64Array(
30 new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
31 );
32 const poisoned = {
33 valueOf: function() {
34 throw new Test262Error('should not evaluate this code');
35 }
36 };
37
38 try {
39 $DETACHBUFFER(i64a.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null
40 } catch (error) {
41 throw new Test262Error(`An unexpected error occurred when detaching ArrayBuffer: ${error.message}`);
42 }
43
44 assert.throws(TypeError, function() {
45 Atomics.wait(i64a, poisoned, poisoned, poisoned);
46 });
47
48 reportCompare(0, 0);