Debian Codegraph @

js/src/tests/test262/built-ins/Atomics/waitAsync/non-shared-bufferdata-throws.js

raw
1 // |reftest| shell-option(--setpref=atomics_wait_async) skip-if(!this.hasOwnProperty('Atomics')||!xulRuntime.shell) -- Atomics is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2020 Rick Waldron. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-atomics.waitasync
6 description: >
7 Throws a TypeError if typedArray.buffer is not a SharedArrayBuffer
8 info: |
9 Atomics.waitAsync( typedArray, index, value, timeout )
10
11 1. Return DoWait(async, typedArray, index, value, timeout).
12
13 DoWait ( mode, typedArray, index, value, timeout )
14
15 1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
16
17 ValidateSharedIntegerTypedArray ( typedArray [ , waitable ] )
18
19 5. If waitable is true, then
20 a. If typeName is not "Int32Array" or "BigInt64Array", throw a TypeError exception.
21
22 features: [Atomics.waitAsync, ArrayBuffer, Atomics, TypedArray, arrow-function]
23 ---*/
24 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
25 const i32a = new Int32Array(
26 new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
27 );
28
29 const poisoned = {
30 valueOf() {
31 throw new Test262Error('should not evaluate this code');
32 }
33 };
34
35 assert.throws(TypeError, () => {
36 Atomics.waitAsync(i32a, 0, 0, 0);
37 }, '`Atomics.waitAsync(i32a, 0, 0, 0)` throws a TypeError exception');
38
39 assert.throws(TypeError, () => {
40 Atomics.waitAsync(i32a, poisoned, poisoned, poisoned);
41 }, '`Atomics.waitAsync(i32a, poisoned, poisoned, poisoned)` throws a TypeError exception');
42
43 reportCompare(0, 0);