Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for Atomics.pause #4147

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add tests for Atomics.pause
  • Loading branch information
syg authored and ptomato committed Jul 11, 2024
commit e83a57d1fb2694152889f61d055465a3b3227071
4 changes: 4 additions & 0 deletions features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions test/built-ins/Atomics/pause/descriptor.js
Original file line number Diff line number Diff line change
@@ -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,
});
16 changes: 16 additions & 0 deletions test/built-ins/Atomics/pause/length.js
Original file line number Diff line number Diff line change
@@ -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,
});
16 changes: 16 additions & 0 deletions test/built-ins/Atomics/pause/name.js
Original file line number Diff line number Diff line change
@@ -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,
});
19 changes: 19 additions & 0 deletions test/built-ins/Atomics/pause/negative-iterationnumber-throws.js
Original file line number Diff line number Diff line change
@@ -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`);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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 = [
syg marked this conversation as resolved.
Show resolved Hide resolved
null,
NaN,
Infinity,
Symbol("foo"),
"bar",
/baz/,
42n,
{},
[],
function() {}
];

for (const v of values) {
assert.throws(TypeError, () => { Atomics.pause(v); },
`${v ? v.toString() : v} is an illegal iterationNumber`);
}
28 changes: 28 additions & 0 deletions test/built-ins/Atomics/pause/not-a-constructor.js
Original file line number Diff line number Diff line change
@@ -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();
});

24 changes: 24 additions & 0 deletions test/built-ins/Atomics/pause/returns-undefined.js
Original file line number Diff line number Diff line change
@@ -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/-1,
syg marked this conversation as resolved.
Show resolved Hide resolved
Number.MAX_SAFE_INTEGER
];

for (const v of values) {
assert.sameValue(Atomics.pause(v), undefined,
'Atomics.pause returns undefined');
}