Debian Codegraph @

js/src/tests/test262/built-ins/Atomics/waitAsync/symbol-for-timeout-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 6. Let q be ? ToNumber(timeout).
17
18 Symbol --> Throw a TypeError exception.
19
20 features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics]
21 ---*/
22 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
23 const i32a = new Int32Array(
24 new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
25 );
26
27 const poisonedValueOf = {
28 valueOf() {
29 throw new Test262Error('should not evaluate this code');
30 }
31 };
32
33 const poisonedToPrimitive = {
34 [Symbol.toPrimitive]() {
35 throw new Test262Error('passing a poisoned object using @@ToPrimitive');
36 }
37 };
38
39 assert.throws(Test262Error, function() {
40 Atomics.waitAsync(i32a, 0, 0, poisonedValueOf);
41 }, '`Atomics.waitAsync(i32a, 0, 0, poisonedValueOf)` throws a Test262Error exception');
42
43 assert.throws(Test262Error, function() {
44 Atomics.waitAsync(i32a, 0, 0, poisonedToPrimitive);
45 }, '`Atomics.waitAsync(i32a, 0, 0, poisonedToPrimitive)` throws a Test262Error exception');
46
47 assert.throws(TypeError, function() {
48 Atomics.waitAsync(i32a, 0, 0, Symbol("foo"));
49 }, '`Atomics.waitAsync(i32a, 0, 0, Symbol("foo"))` throws a TypeError exception');
50
51 assert.throws(TypeError, function() {
52 Atomics.waitAsync(i32a, 0, 0, Symbol("foo"));
53 }, '`Atomics.waitAsync(i32a, 0, 0, Symbol("foo"))` throws a TypeError exception');
54
55 reportCompare(0, 0);