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