Skip to content
Snippets Groups Projects
Commit 3ea46599 authored by Rick Waldron's avatar Rick Waldron
Browse files

fixup! Atomics: updates to various Atomics tests. gh-1527

parent 7c30ad5c
No related branches found
No related tags found
No related merge requests found
Showing
with 66 additions and 66 deletions
...@@ -29,10 +29,10 @@ var agent3 = '3'; ...@@ -29,10 +29,10 @@ var agent3 = '3';
$262.agent.start(` $262.agent.start(`
$262.agent.receiveBroadcast(function(sab) { $262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.report(${agent1}); $262.agent.report(${agent1});
Atomics.wait(int32Array, 0, 0); Atomics.wait(i32a, 0, 0);
$262.agent.report(${agent1}); $262.agent.report(${agent1});
$262.agent.leaving(); $262.agent.leaving();
...@@ -41,11 +41,11 @@ $262.agent.receiveBroadcast(function(sab) { ...@@ -41,11 +41,11 @@ $262.agent.receiveBroadcast(function(sab) {
$262.agent.start(` $262.agent.start(`
$262.agent.receiveBroadcast(function(sab) { $262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.report(${agent2}); $262.agent.report(${agent2});
Atomics.wait(int32Array, 0, 0); Atomics.wait(i32a, 0, 0);
$262.agent.report(${agent2}); $262.agent.report(${agent2});
$262.agent.leaving(); $262.agent.leaving();
...@@ -54,11 +54,11 @@ $262.agent.receiveBroadcast(function(sab) { ...@@ -54,11 +54,11 @@ $262.agent.receiveBroadcast(function(sab) {
$262.agent.start(` $262.agent.start(`
$262.agent.receiveBroadcast(function(sab) { $262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.report(${agent3}); $262.agent.report(${agent3});
Atomics.wait(int32Array, 0, 0); Atomics.wait(i32a, 0, 0);
$262.agent.report(${agent3}); $262.agent.report(${agent3});
$262.agent.leaving(); $262.agent.leaving();
...@@ -66,21 +66,21 @@ $262.agent.receiveBroadcast(function(sab) { ...@@ -66,21 +66,21 @@ $262.agent.receiveBroadcast(function(sab) {
`); `);
var int32Array = new Int32Array(new SharedArrayBuffer(4)); var i32a = new Int32Array(new SharedArrayBuffer(4));
$262.agent.broadcast(int32Array.buffer); $262.agent.broadcast(i32a.buffer);
var orderWhichAgentsWereStarted = getReport() + getReport() + getReport(); // can be started in any order var orderWhichAgentsWereStarted = getReport() + getReport() + getReport(); // can be started in any order
assert.sameValue(Atomics.wake(int32Array, 0, 1), 1); assert.sameValue(Atomics.wake(i32a, 0, 1), 1);
var orderAgentsWereWoken = getReport(); var orderAgentsWereWoken = getReport();
assert.sameValue(Atomics.wake(int32Array, 0, 1), 1); assert.sameValue(Atomics.wake(i32a, 0, 1), 1);
orderAgentsWereWoken += getReport(); orderAgentsWereWoken += getReport();
assert.sameValue(Atomics.wake(int32Array, 0, 1), 1); assert.sameValue(Atomics.wake(i32a, 0, 1), 1);
orderAgentsWereWoken += getReport(); orderAgentsWereWoken += getReport();
......
...@@ -35,20 +35,20 @@ function getReport() { ...@@ -35,20 +35,20 @@ function getReport() {
$262.agent.start(` $262.agent.start(`
$262.agent.receiveBroadcast(function(sab) { $262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.report(Atomics.wait(int32Array, 0, 0, ${timeout})); $262.agent.report(Atomics.wait(i32a, 0, 0, ${timeout}));
$262.agent.leaving(); $262.agent.leaving();
}); });
`); `);
var sab = new SharedArrayBuffer(4); var sab = new SharedArrayBuffer(4);
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.broadcast(int32Array.buffer); $262.agent.broadcast(i32a.buffer);
$262.agent.sleep(sleeping); $262.agent.sleep(sleeping);
assert.sameValue(Atomics.wake(int32Array, 0), 1); assert.sameValue(Atomics.wake(i32a, 0), 1);
assert.sameValue(getReport(), "ok"); assert.sameValue(getReport(), "ok");
assert(sleeping < timeout, "this test assumes it won't last for more than 20 seconds"); assert(sleeping < timeout, "this test assumes it won't last for more than 20 seconds");
......
...@@ -28,43 +28,43 @@ function getReport() { ...@@ -28,43 +28,43 @@ function getReport() {
$262.agent.start(` $262.agent.start(`
$262.agent.receiveBroadcast(function(sab) { $262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.report("A " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50)); $262.agent.report("A " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving(); $262.agent.leaving();
}); });
`); `);
$262.agent.start(` $262.agent.start(`
$262.agent.receiveBroadcast(function(sab) { $262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.report("B " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50)); $262.agent.report("B " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving(); $262.agent.leaving();
}); });
`); `);
$262.agent.start(` $262.agent.start(`
$262.agent.receiveBroadcast(function(sab) { $262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.report("C " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50)); $262.agent.report("C " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving(); $262.agent.leaving();
}); });
`); `);
$262.agent.start(` $262.agent.start(`
$262.agent.receiveBroadcast(function(sab) { $262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.report("D " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50)); $262.agent.report("D " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving(); $262.agent.leaving();
}); });
`); `);
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)); var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(int32Array.buffer); $262.agent.broadcast(i32a.buffer);
$262.agent.sleep(20); $262.agent.sleep(20);
assert.sameValue(Atomics.wake(int32Array, WAKEUP /*, count missing */), NUMAGENT); assert.sameValue(Atomics.wake(i32a, WAKEUP /*, count missing */), NUMAGENT);
var sortedReports = []; var sortedReports = [];
for (var i = 0; i < NUMAGENT; i++) { for (var i = 0; i < NUMAGENT; i++) {
......
...@@ -26,16 +26,16 @@ function getReport() { ...@@ -26,16 +26,16 @@ function getReport() {
$262.agent.start(` $262.agent.start(`
$262.agent.receiveBroadcast(function(sab) { $262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.report("A " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50)); $262.agent.report("A " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving(); $262.agent.leaving();
}); });
`); `);
$262.agent.start(` $262.agent.start(`
$262.agent.receiveBroadcast(function(sab) { $262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.report("B " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50)); $262.agent.report("B " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving(); $262.agent.leaving();
}); });
`); `);
...@@ -43,8 +43,8 @@ $262.agent.receiveBroadcast(function(sab) { ...@@ -43,8 +43,8 @@ $262.agent.receiveBroadcast(function(sab) {
$262.agent.start(` $262.agent.start(`
$262.agent.receiveBroadcast(function(sab) { $262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.report("C " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50)); $262.agent.report("C " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving(); $262.agent.leaving();
}); });
`); `);
...@@ -52,19 +52,19 @@ $262.agent.receiveBroadcast(function(sab) { ...@@ -52,19 +52,19 @@ $262.agent.receiveBroadcast(function(sab) {
$262.agent.start(` $262.agent.start(`
$262.agent.receiveBroadcast(function(sab) { $262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.report("D " + Atomics.wait(int32Array, ${WAKEUP}, 0, 50)); $262.agent.report("D " + Atomics.wait(i32a, ${WAKEUP}, 0, 50));
$262.agent.leaving(); $262.agent.leaving();
}); });
`); `);
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)); var i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(int32Array.buffer); $262.agent.broadcast(i32a.buffer);
$262.agent.sleep(20); // half of timeout $262.agent.sleep(20); // half of timeout
assert.sameValue(Atomics.wake(int32Array, WAKEUP, undefined), NUMAGENT); assert.sameValue(Atomics.wake(i32a, WAKEUP, undefined), NUMAGENT);
var sortedReports = []; var sortedReports = [];
for (var i = 0; i < NUMAGENT; i++) { for (var i = 0; i < NUMAGENT; i++) {
......
...@@ -17,14 +17,14 @@ features: [Atomics, SharedArrayBuffer, TypedArray] ...@@ -17,14 +17,14 @@ features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var sab = new SharedArrayBuffer(1024);
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
var poisoned = { var poisoned = {
valueOf: function() { valueOf: function() {
throw new Test262Error("should not evaluate this code"); throw new Test262Error("should not evaluate this code");
} }
}; };
assert.throws(RangeError, () => Atomics.wake(int32Array, -Infinity, poisoned)); assert.throws(RangeError, () => Atomics.wake(i32a, -Infinity, poisoned));
assert.throws(RangeError, () => Atomics.wake(int32Array, -7.999, poisoned)); assert.throws(RangeError, () => Atomics.wake(i32a, -7.999, poisoned));
assert.throws(RangeError, () => Atomics.wake(int32Array, -1, poisoned)); assert.throws(RangeError, () => Atomics.wake(i32a, -1, poisoned));
assert.throws(RangeError, () => Atomics.wake(int32Array, -300, poisoned)); assert.throws(RangeError, () => Atomics.wake(i32a, -300, poisoned));
...@@ -15,7 +15,7 @@ info: | ...@@ -15,7 +15,7 @@ info: |
features: [ArrayBuffer, Atomics, TypedArray] features: [ArrayBuffer, Atomics, TypedArray]
---*/ ---*/
var int32Array = new Int32Array(new ArrayBuffer(4)); var i32a = new Int32Array(new ArrayBuffer(4));
var poisoned = { var poisoned = {
valueOf: function() { valueOf: function() {
throw new Test262Error("should not evaluate this code"); throw new Test262Error("should not evaluate this code");
...@@ -23,9 +23,9 @@ var poisoned = { ...@@ -23,9 +23,9 @@ var poisoned = {
}; };
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.wake(int32Array, 0, 0) Atomics.wake(i32a, 0, 0);
}); });
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.wake(int32Array, poisoned, poisoned) Atomics.wake(i32a, poisoned, poisoned);
}); });
...@@ -16,15 +16,15 @@ includes: [detachArrayBuffer.js] ...@@ -16,15 +16,15 @@ includes: [detachArrayBuffer.js]
features: [ArrayBuffer, Atomics, TypedArray] features: [ArrayBuffer, Atomics, TypedArray]
---*/ ---*/
var int32Array = new Int32Array(new ArrayBuffer(1024)); var i32a = new Int32Array(new ArrayBuffer(1024));
var poisoned = { var poisoned = {
valueOf: function() { valueOf: function() {
throw new Test262Error("should not evaluate this code"); throw new Test262Error("should not evaluate this code");
} }
}; };
$DETACHBUFFER(int32Array.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null $DETACHBUFFER(i32a.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.wake(int32Array, poisoned, poisoned); Atomics.wake(i32a, poisoned, poisoned);
}); });
...@@ -16,7 +16,7 @@ description: > ...@@ -16,7 +16,7 @@ description: >
features: [Atomics, SharedArrayBuffer, TypedArray] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var int32Array = new Int32Array(new SharedArrayBuffer(4)); var i32a = new Int32Array(new SharedArrayBuffer(4));
var poisoned = { var poisoned = {
valueOf: function() { valueOf: function() {
throw new Test262Error("should not evaluate this code"); throw new Test262Error("should not evaluate this code");
...@@ -24,11 +24,11 @@ var poisoned = { ...@@ -24,11 +24,11 @@ var poisoned = {
}; };
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
Atomics.wake(int32Array, Infinity, poisoned); Atomics.wake(i32a, Infinity, poisoned);
}); });
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
Atomics.wake(int32Array, 2, poisoned); Atomics.wake(i32a, 2, poisoned);
}); });
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
Atomics.wake(int32Array, 200, poisoned); Atomics.wake(i32a, 200, poisoned);
}); });
...@@ -29,7 +29,7 @@ features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray] ...@@ -29,7 +29,7 @@ features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
---*/ ---*/
var buffer = new SharedArrayBuffer(1024); var buffer = new SharedArrayBuffer(1024);
var int32Array = new Int32Array(buffer); var i32a = new Int32Array(buffer);
var poisonedValueOf = { var poisonedValueOf = {
valueOf: function() { valueOf: function() {
...@@ -44,17 +44,17 @@ var poisonedToPrimitive = { ...@@ -44,17 +44,17 @@ var poisonedToPrimitive = {
}; };
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
Atomics.wake(int32Array, poisonedValueOf, poisonedValueOf); Atomics.wake(i32a, poisonedValueOf, poisonedValueOf);
}); });
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
Atomics.wake(int32Array, poisonedToPrimitive, poisonedToPrimitive); Atomics.wake(i32a, poisonedToPrimitive, poisonedToPrimitive);
}); });
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.wake(int32Array, Symbol("foo"), poisonedValueOf); Atomics.wake(i32a, Symbol("foo"), poisonedValueOf);
}); });
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.wake(int32Array, Symbol("foo"), poisonedToPrimitive); Atomics.wake(i32a, Symbol("foo"), poisonedToPrimitive);
}); });
...@@ -24,8 +24,8 @@ features: [Atomics, SharedArrayBuffer, TypedArray] ...@@ -24,8 +24,8 @@ features: [Atomics, SharedArrayBuffer, TypedArray]
$262.agent.start( $262.agent.start(
` `
$262.agent.receiveBroadcast(function(sab) { $262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.report(Atomics.wait(int32Array, 0, 0, 200)); $262.agent.report(Atomics.wait(i32a, 0, 0, 200));
$262.agent.leaving(); $262.agent.leaving();
}) })
...@@ -35,23 +35,23 @@ $262.agent.receiveBroadcast(function(sab) { ...@@ -35,23 +35,23 @@ $262.agent.receiveBroadcast(function(sab) {
;$262.agent.start( ;$262.agent.start(
` `
$262.agent.receiveBroadcast(function(sab) { $262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.report(Atomics.wait(int32Array, 0, 0, 200)); $262.agent.report(Atomics.wait(i32a, 0, 0, 200));
$262.agent.leaving(); $262.agent.leaving();
}) })
`); `);
var sab = new SharedArrayBuffer(4); var sab = new SharedArrayBuffer(4);
var int32Array = new Int32Array(sab); var i32a = new Int32Array(sab);
$262.agent.broadcast(int32Array.buffer); $262.agent.broadcast(i32a.buffer);
$262.agent.sleep(100); // halfway through timeout $262.agent.sleep(100); // halfway through timeout
assert.sameValue(Atomics.wake(int32Array, undefined, 1), 1); // wake at index 0 assert.sameValue(Atomics.wake(i32a, undefined, 1), 1); // wake at index 0
assert.sameValue(getReport(), "ok"); assert.sameValue(getReport(), "ok");
assert.sameValue(Atomics.wake(int32Array), 1); // wake again at index 0 assert.sameValue(Atomics.wake(i32a), 1); // wake again at index 0
assert.sameValue(getReport(), "ok"); assert.sameValue(getReport(), "ok");
function getReport() { function getReport() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment