Debian Codegraph @

js/src/tests/test262/built-ins/Atomics/waitAsync/bigint/symbol-for-index-throws.js

raw
1 // |reftest| shell-option(--setpref=atomics_wait_async) skip-if(!this.hasOwnProperty('SharedArrayBuffer')||!this.hasOwnProperty('Atomics')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))||!xulRuntime.shell) -- SharedArrayBuffer,Atomics is not enabled unconditionally, ARM64 Simulator cannot emulate atomics, 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 /*---
6 esid: sec-atomics.waitasync
7 description: >
8 Throws a TypeError if index arg can not be converted to an Integer
9 info: |
10 Atomics.waitAsync( typedArray, index, value, timeout )
11
12 1. Return DoWait(async, typedArray, index, value, timeout).
13
14 DoWait ( mode, typedArray, index, value, timeout )
15
16 2. Let i be ? ValidateAtomicAccess(typedArray, index).
17
18 ValidateAtomicAccess( typedArray, requestIndex )
19
20 2. Let accessIndex be ? ToIndex(requestIndex).
21
22 ToIndex ( value )
23
24 2. Else,
25 a. Let integerIndex be ? ToInteger(value).
26
27 ToInteger(value)
28
29 1. Let number be ? ToNumber(argument).
30
31 Symbol --> Throw a TypeError exception.
32
33 features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics, BigInt]
34 ---*/
35 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
36 const i64a = new BigInt64Array(
37 new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
38 );
39
40 const poisonedValueOf = {
41 valueOf() {
42 throw new Test262Error('should not evaluate this code');
43 }
44 };
45
46 const poisonedToPrimitive = {
47 [Symbol.toPrimitive]() {
48 throw new Test262Error('should not evaluate this code');
49 }
50 };
51
52 assert.throws(Test262Error, function() {
53 Atomics.waitAsync(i64a, poisonedValueOf, poisonedValueOf, poisonedValueOf);
54 }, '`Atomics.waitAsync(i64a, poisonedValueOf, poisonedValueOf, poisonedValueOf)` throws a Test262Error exception');
55
56 assert.throws(Test262Error, function() {
57 Atomics.waitAsync(i64a, poisonedToPrimitive, poisonedToPrimitive, poisonedToPrimitive);
58 }, '`Atomics.waitAsync(i64a, poisonedToPrimitive, poisonedToPrimitive, poisonedToPrimitive)` throws a Test262Error exception');
59
60 assert.throws(TypeError, function() {
61 Atomics.waitAsync(i64a, Symbol('1'), poisonedValueOf, poisonedValueOf);
62 }, '`Atomics.waitAsync(i64a, Symbol("1"), poisonedValueOf, poisonedValueOf)` throws a TypeError exception');
63
64 assert.throws(TypeError, function() {
65 Atomics.waitAsync(i64a, Symbol('2'), poisonedToPrimitive, poisonedToPrimitive);
66 }, '`Atomics.waitAsync(i64a, Symbol("2"), poisonedToPrimitive, poisonedToPrimitive)` throws a TypeError exception');
67
68
69
70
71 reportCompare(0, 0);