diff --git a/features.txt b/features.txt index e6e42425392..5721ffd2f89 100644 --- a/features.txt +++ b/features.txt @@ -106,6 +106,10 @@ source-phase-imports-module-source # https://github.com/tc39/proposal-arraybuffer-base64 uint8array-base64 +# Atomics.pause +# https://github.com/tc39/proposal-atomics-microwait +Atomics.pause + ## Standard language features # # Language features that have been included in a published version of the diff --git a/test/built-ins/Atomics/pause/descriptor.js b/test/built-ins/Atomics/pause/descriptor.js new file mode 100644 index 00000000000..89a7e104ca4 --- /dev/null +++ b/test/built-ins/Atomics/pause/descriptor.js @@ -0,0 +1,15 @@ +// Copyright 2024 the V8 project authors. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-atomics.pause +description: Testing descriptor property of Atomics.pause +includes: [propertyHelper.js] +features: [Atomics.pause] +---*/ + +verifyProperty(Atomics, 'pause', { + enumerable: false, + writable: true, + configurable: true, +}); diff --git a/test/built-ins/Atomics/pause/length.js b/test/built-ins/Atomics/pause/length.js new file mode 100644 index 00000000000..7c83f2a54cb --- /dev/null +++ b/test/built-ins/Atomics/pause/length.js @@ -0,0 +1,16 @@ +// Copyright 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atomics.pause +description: Atomics.pause.length is 0. +includes: [propertyHelper.js] +features: [Atomics.pause] +---*/ + +verifyProperty(Atomics.pause, 'length', { + value: 0, + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/built-ins/Atomics/pause/name.js b/test/built-ins/Atomics/pause/name.js new file mode 100644 index 00000000000..09f1964e07a --- /dev/null +++ b/test/built-ins/Atomics/pause/name.js @@ -0,0 +1,16 @@ +// Copyright 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atomics.pause +description: Atomics.pause.name is "pause". +includes: [propertyHelper.js] +features: [Atomics.pause] +---*/ + +verifyProperty(Atomics.pause, 'name', { + value: 'pause', + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/built-ins/Atomics/pause/negative-iterationnumber-throws.js b/test/built-ins/Atomics/pause/negative-iterationnumber-throws.js new file mode 100644 index 00000000000..ea0d29bb49f --- /dev/null +++ b/test/built-ins/Atomics/pause/negative-iterationnumber-throws.js @@ -0,0 +1,19 @@ +// Copyright 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atomics.pause +description: Atomics.pause throws on negative argument values +features: [Atomics.pause] +---*/ + +const values = [ + -1, + Number.MIN_SAFE_INTEGER, + Number.MIN_SAFE_INTEGER - 1 +]; + +for (const v of values) { + assert.throws(RangeError, () => { Atomics.pause(v); }, + `${v} is an illegal iterationNumber`); +} diff --git a/test/built-ins/Atomics/pause/non-integral-iterationnumber-throws.js b/test/built-ins/Atomics/pause/non-integral-iterationnumber-throws.js new file mode 100644 index 00000000000..394c2e3ce77 --- /dev/null +++ b/test/built-ins/Atomics/pause/non-integral-iterationnumber-throws.js @@ -0,0 +1,32 @@ +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atomics.pause +description: Atomics.pause throws on non-integral Number argument values +features: [Atomics.pause] +---*/ + +const values = [ + true, + false, + null, + 42.42, + -42.42, + NaN, + Infinity, + Symbol("foo"), + "bar", + "42", + /baz/, + 42n, + {}, + [], + function() {}, + { valueOf() { return 42; } } +]; + +for (const v of values) { + assert.throws(TypeError, () => { Atomics.pause(v); }, + `${v ? v.toString() : v} is an illegal iterationNumber`); +} diff --git a/test/built-ins/Atomics/pause/not-a-constructor.js b/test/built-ins/Atomics/pause/not-a-constructor.js new file mode 100644 index 00000000000..3639a7d8db8 --- /dev/null +++ b/test/built-ins/Atomics/pause/not-a-constructor.js @@ -0,0 +1,28 @@ +// Copyright 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: Atomics.pause does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, Atomics.pause] +---*/ + +assert.sameValue(isConstructor(Atomics.pause), false, 'isConstructor(Atomics.pause) must return false'); + +assert.throws(TypeError, () => { + new Atomics.pause(); +}); + diff --git a/test/built-ins/Atomics/pause/returns-undefined.js b/test/built-ins/Atomics/pause/returns-undefined.js new file mode 100644 index 00000000000..7bf35fdce41 --- /dev/null +++ b/test/built-ins/Atomics/pause/returns-undefined.js @@ -0,0 +1,24 @@ +// Copyright 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-atomics.pause +description: Atomics.pause returns undefined +features: [Atomics.pause] +---*/ + +assert.sameValue(Atomics.pause(), undefined, + 'Atomics.pause returns undefined'); + +const values = [ + undefined, + 42, + 0, + -0, + Number.MAX_SAFE_INTEGER +]; + +for (const v of values) { + assert.sameValue(Atomics.pause(v), undefined, + 'Atomics.pause returns undefined'); +}