mirror of
https://github.com/tc39/test262.git
synced 2025-07-19 20:14:56 +02:00
built-ins/Atomics/*: make all indentation consistent (depth & character) (#1442)
This commit is contained in:
parent
e1f4ced053
commit
dedd68020b
@ -18,9 +18,9 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
let view = new View(sab);
|
let view = new View(sab);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
assert.throws(RangeError, () => Atomics.add(view, Idx, 10));
|
assert.throws(RangeError, () => Atomics.add(view, Idx, 10));
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -14,42 +14,42 @@ var ab = new ArrayBuffer(16);
|
|||||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new View(sab, 32, 20);
|
var view = new View(sab, 32, 20);
|
||||||
var control = new View(ab, 0, 2);
|
var control = new View(ab, 0, 2);
|
||||||
|
|
||||||
// Add positive number
|
// Add positive number
|
||||||
view[8] = 0;
|
view[8] = 0;
|
||||||
assert.sameValue(Atomics.add(view, 8, 10), 0);
|
assert.sameValue(Atomics.add(view, 8, 10), 0);
|
||||||
assert.sameValue(view[8], 10);
|
assert.sameValue(view[8], 10);
|
||||||
|
|
||||||
// Add negative number
|
// Add negative number
|
||||||
assert.sameValue(Atomics.add(view, 8, -5), 10);
|
assert.sameValue(Atomics.add(view, 8, -5), 10);
|
||||||
assert.sameValue(view[8], 5);
|
assert.sameValue(view[8], 5);
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
||||||
"Result is negative and subject to coercion");
|
"Result is negative and subject to coercion");
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
// Atomics operations, not quite like view[Idx].
|
// Atomics operations, not quite like view[Idx].
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
assert.sameValue(Atomics.add(view, Idx, 0), 37);
|
assert.sameValue(Atomics.add(view, Idx, 0), 37);
|
||||||
});
|
});
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -10,5 +10,5 @@ features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, le
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, (() => Atomics.add(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.add(view, 0, 0)));
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(ab);
|
var view = new View(ab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.add(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.add(view, 0, 0)));
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -14,7 +14,7 @@ var sab = new SharedArrayBuffer(1024);
|
|||||||
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(sab);
|
var view = new View(sab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.add(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.add(view, 0, 0)));
|
||||||
}, other_views);
|
}, other_views);
|
||||||
|
@ -18,9 +18,9 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
let view = new View(sab);
|
let view = new View(sab);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
assert.throws(RangeError, () => Atomics.and(view, Idx, 10));
|
assert.throws(RangeError, () => Atomics.and(view, Idx, 10));
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -14,49 +14,49 @@ var ab = new ArrayBuffer(16);
|
|||||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new View(sab, 32, 20);
|
var view = new View(sab, 32, 20);
|
||||||
var control = new View(ab, 0, 2);
|
var control = new View(ab, 0, 2);
|
||||||
|
|
||||||
view[8] = 0x33333333;
|
view[8] = 0x33333333;
|
||||||
control[0] = 0x33333333;
|
control[0] = 0x33333333;
|
||||||
assert.sameValue(Atomics.and(view, 8, 0x55555555), control[0],
|
assert.sameValue(Atomics.and(view, 8, 0x55555555), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
|
|
||||||
control[0] = 0x11111111;
|
control[0] = 0x11111111;
|
||||||
assert.sameValue(view[8], control[0]);
|
assert.sameValue(view[8], control[0]);
|
||||||
assert.sameValue(Atomics.and(view, 8, 0xF0F0F0F0), control[0],
|
assert.sameValue(Atomics.and(view, 8, 0xF0F0F0F0), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
|
|
||||||
control[0] = 0x10101010;
|
control[0] = 0x10101010;
|
||||||
assert.sameValue(view[8], control[0]);
|
assert.sameValue(view[8], control[0]);
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
||||||
"Result is negative and subject to coercion");
|
"Result is negative and subject to coercion");
|
||||||
assert.sameValue(view[3], 0);
|
assert.sameValue(view[3], 0);
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
||||||
"Result is subjective to chopping");
|
"Result is subjective to chopping");
|
||||||
assert.sameValue(view[3], 0);
|
assert.sameValue(view[3], 0);
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
||||||
"Result is subjective to chopping");
|
"Result is subjective to chopping");
|
||||||
assert.sameValue(view[3], 0);
|
assert.sameValue(view[3], 0);
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
// Atomics operations, not quite like view[Idx].
|
// Atomics operations, not quite like view[Idx].
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
assert.sameValue(Atomics.and(view, Idx, 0), 37);
|
assert.sameValue(Atomics.and(view, Idx, 0), 37);
|
||||||
});
|
});
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -10,5 +10,5 @@ features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, le
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, (() => Atomics.and(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.and(view, 0, 0)));
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(ab);
|
var view = new View(ab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.and(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.and(view, 0, 0)));
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -14,7 +14,7 @@ var sab = new SharedArrayBuffer(1024);
|
|||||||
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(sab);
|
var view = new View(sab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.and(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.and(view, 0, 0)));
|
||||||
}, other_views);
|
}, other_views);
|
||||||
|
@ -18,9 +18,9 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
let view = new View(sab);
|
let view = new View(sab);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
assert.throws(RangeError, () => Atomics.compareExchange(view, Idx, 10, 0));
|
assert.throws(RangeError, () => Atomics.compareExchange(view, Idx, 10, 0));
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -21,54 +21,54 @@ var good_indices = [ (view) => 0/-1, // -0
|
|||||||
];
|
];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new View(sab, 32, 20);
|
var view = new View(sab, 32, 20);
|
||||||
var control = new View(ab, 0, 2);
|
var control = new View(ab, 0, 2);
|
||||||
|
|
||||||
// Performs the exchange
|
// Performs the exchange
|
||||||
view[8] = 0;
|
view[8] = 0;
|
||||||
assert.sameValue(Atomics.compareExchange(view, 8, 0, 10), 0);
|
assert.sameValue(Atomics.compareExchange(view, 8, 0, 10), 0);
|
||||||
assert.sameValue(view[8], 10);
|
assert.sameValue(view[8], 10);
|
||||||
|
|
||||||
view[8] = 0;
|
view[8] = 0;
|
||||||
assert.sameValue(Atomics.compareExchange(view, 8, 1, 10), 0,
|
assert.sameValue(Atomics.compareExchange(view, 8, 1, 10), 0,
|
||||||
"Does not perform the exchange");
|
"Does not perform the exchange");
|
||||||
assert.sameValue(view[8], 0);
|
assert.sameValue(view[8], 0);
|
||||||
|
|
||||||
view[8] = 0;
|
view[8] = 0;
|
||||||
assert.sameValue(Atomics.compareExchange(view, 8, 0, -5), 0,
|
assert.sameValue(Atomics.compareExchange(view, 8, 0, -5), 0,
|
||||||
"Performs the exchange, coercing the value being stored");
|
"Performs the exchange, coercing the value being stored");
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(view[8], control[0]);
|
assert.sameValue(view[8], control[0]);
|
||||||
|
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.compareExchange(view, 3, -5, 0), control[0],
|
assert.sameValue(Atomics.compareExchange(view, 3, -5, 0), control[0],
|
||||||
"Performs the exchange, coercing the value being tested");
|
"Performs the exchange, coercing the value being tested");
|
||||||
assert.sameValue(view[3], 0);
|
assert.sameValue(view[3], 0);
|
||||||
|
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.compareExchange(view, 3, 12345, 0), control[0],
|
assert.sameValue(Atomics.compareExchange(view, 3, 12345, 0), control[0],
|
||||||
"Performs the exchange, chopping the value being tested");
|
"Performs the exchange, chopping the value being tested");
|
||||||
assert.sameValue(view[3], 0);
|
assert.sameValue(view[3], 0);
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.compareExchange(view, 3, 123456789, 0), control[0],
|
assert.sameValue(Atomics.compareExchange(view, 3, 123456789, 0), control[0],
|
||||||
"Performs the exchange, chopping the value being tested");
|
"Performs the exchange, chopping the value being tested");
|
||||||
assert.sameValue(view[3], 0);
|
assert.sameValue(view[3], 0);
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
// Atomics operations, not quite like view[Idx].
|
// Atomics operations, not quite like view[Idx].
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
assert.sameValue(Atomics.compareExchange(view, Idx, 37, 0), 37);
|
assert.sameValue(Atomics.compareExchange(view, Idx, 37, 0), 37);
|
||||||
});
|
});
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -10,5 +10,5 @@ features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, le
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, (() => Atomics.compareExchange(view, 0, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.compareExchange(view, 0, 0, 0)));
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(ab);
|
var view = new View(ab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.compareExchange(view, 0, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.compareExchange(view, 0, 0, 0)));
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -14,7 +14,7 @@ var sab = new SharedArrayBuffer(1024);
|
|||||||
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(sab);
|
var view = new View(sab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.compareExchange(view, 0, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.compareExchange(view, 0, 0, 0)));
|
||||||
}, other_views);
|
}, other_views);
|
||||||
|
@ -18,9 +18,9 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
let view = new View(sab);
|
let view = new View(sab);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
assert.throws(RangeError, () => Atomics.exchange(view, Idx, 10, 0));
|
assert.throws(RangeError, () => Atomics.exchange(view, Idx, 10, 0));
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -14,43 +14,43 @@ var ab = new ArrayBuffer(16);
|
|||||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new View(sab, 32, 20);
|
var view = new View(sab, 32, 20);
|
||||||
var control = new View(ab, 0, 2);
|
var control = new View(ab, 0, 2);
|
||||||
|
|
||||||
view[8] = 0;
|
view[8] = 0;
|
||||||
assert.sameValue(Atomics.exchange(view, 8, 10), 0,
|
assert.sameValue(Atomics.exchange(view, 8, 10), 0,
|
||||||
"Exchange returns the value previously in the array");
|
"Exchange returns the value previously in the array");
|
||||||
assert.sameValue(view[8], 10);
|
assert.sameValue(view[8], 10);
|
||||||
|
|
||||||
assert.sameValue(Atomics.exchange(view, 8, -5), 10,
|
assert.sameValue(Atomics.exchange(view, 8, -5), 10,
|
||||||
"Exchange returns the value previously in the array");
|
"Exchange returns the value previously in the array");
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(view[8], control[0]);
|
assert.sameValue(view[8], control[0]);
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
||||||
"Result is subject to coercion");
|
"Result is subject to coercion");
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
// Atomics operations, not quite like view[Idx].
|
// Atomics operations, not quite like view[Idx].
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
assert.sameValue(Atomics.exchange(view, Idx, 0), 37);
|
assert.sameValue(Atomics.exchange(view, Idx, 0), 37);
|
||||||
});
|
});
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -10,5 +10,5 @@ features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, le
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, (() => Atomics.exchange(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.exchange(view, 0, 0)));
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(ab);
|
var view = new View(ab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.exchange(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.exchange(view, 0, 0)));
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -14,7 +14,7 @@ var sab = new SharedArrayBuffer(1024);
|
|||||||
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(sab);
|
var view = new View(sab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.exchange(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.exchange(view, 0, 0)));
|
||||||
}, other_views);
|
}, other_views);
|
||||||
|
@ -23,8 +23,7 @@ assert.sameValue(Atomics.isLockFree(1), Atomics.isLockFree({toString: () => '1'}
|
|||||||
assert.sameValue(Atomics.isLockFree(3), Atomics.isLockFree({toString: () => '3'}));
|
assert.sameValue(Atomics.isLockFree(3), Atomics.isLockFree({toString: () => '3'}));
|
||||||
|
|
||||||
function hide(k, x) {
|
function hide(k, x) {
|
||||||
if (k)
|
if (k)
|
||||||
return hide(k-3, x) + x;
|
return hide(k - 3, x) + x;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,35 +13,35 @@ var answers = [ {}, {}, false, true, false, false, false, false,
|
|||||||
false, false, false, false];
|
false, false, false, false];
|
||||||
|
|
||||||
function testIsLockFree() {
|
function testIsLockFree() {
|
||||||
var saved = {};
|
var saved = {};
|
||||||
|
|
||||||
// This should defeat most optimizations.
|
// This should defeat most optimizations.
|
||||||
|
|
||||||
for ( var i=0 ; i < sizes.length ; i++ ) {
|
for (var i = 0; i < sizes.length; i++) {
|
||||||
var v = Atomics.isLockFree(sizes[i]);
|
var v = Atomics.isLockFree(sizes[i]);
|
||||||
var a = answers[i];
|
var a = answers[i];
|
||||||
assert.sameValue(typeof v, 'boolean');
|
assert.sameValue(typeof v, 'boolean');
|
||||||
if (typeof a == 'boolean')
|
if (typeof a == 'boolean')
|
||||||
assert.sameValue(v, a);
|
assert.sameValue(v, a);
|
||||||
else
|
else
|
||||||
saved[sizes[i]] = v;
|
saved[sizes[i]] = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This ought to be optimizable. Make sure the answers are the same
|
// This ought to be optimizable. Make sure the answers are the same
|
||||||
// as for the unoptimized case.
|
// as for the unoptimized case.
|
||||||
|
|
||||||
assert.sameValue(Atomics.isLockFree(1), saved[1]);
|
assert.sameValue(Atomics.isLockFree(1), saved[1]);
|
||||||
assert.sameValue(Atomics.isLockFree(2), saved[2]);
|
assert.sameValue(Atomics.isLockFree(2), saved[2]);
|
||||||
assert.sameValue(Atomics.isLockFree(3), false);
|
assert.sameValue(Atomics.isLockFree(3), false);
|
||||||
assert.sameValue(Atomics.isLockFree(4), true);
|
assert.sameValue(Atomics.isLockFree(4), true);
|
||||||
assert.sameValue(Atomics.isLockFree(5), false);
|
assert.sameValue(Atomics.isLockFree(5), false);
|
||||||
assert.sameValue(Atomics.isLockFree(6), false);
|
assert.sameValue(Atomics.isLockFree(6), false);
|
||||||
assert.sameValue(Atomics.isLockFree(7), false);
|
assert.sameValue(Atomics.isLockFree(7), false);
|
||||||
assert.sameValue(Atomics.isLockFree(8), false);
|
assert.sameValue(Atomics.isLockFree(8), false);
|
||||||
assert.sameValue(Atomics.isLockFree(9), false);
|
assert.sameValue(Atomics.isLockFree(9), false);
|
||||||
assert.sameValue(Atomics.isLockFree(10), false);
|
assert.sameValue(Atomics.isLockFree(10), false);
|
||||||
assert.sameValue(Atomics.isLockFree(11), false);
|
assert.sameValue(Atomics.isLockFree(11), false);
|
||||||
assert.sameValue(Atomics.isLockFree(12), false);
|
assert.sameValue(Atomics.isLockFree(12), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
testIsLockFree();
|
testIsLockFree();
|
||||||
|
@ -18,9 +18,9 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
let view = new View(sab);
|
let view = new View(sab);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
assert.throws(RangeError, () => Atomics.load(view, Idx));
|
assert.throws(RangeError, () => Atomics.load(view, Idx));
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -14,33 +14,33 @@ var ab = new ArrayBuffer(16);
|
|||||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new View(sab, 32, 20);
|
var view = new View(sab, 32, 20);
|
||||||
var control = new View(ab, 0, 2);
|
var control = new View(ab, 0, 2);
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.load(view, 3), control[0],
|
assert.sameValue(Atomics.load(view, 3), control[0],
|
||||||
"Result is subject to coercion");
|
"Result is subject to coercion");
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.load(view, 3), control[0],
|
assert.sameValue(Atomics.load(view, 3), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.load(view, 3), control[0],
|
assert.sameValue(Atomics.load(view, 3), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
// Atomics operations, not quite like view[Idx].
|
// Atomics operations, not quite like view[Idx].
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
assert.sameValue(Atomics.load(view, Idx), 37);
|
assert.sameValue(Atomics.load(view, Idx), 37);
|
||||||
});
|
});
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -10,5 +10,5 @@ features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, le
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, (() => Atomics.load(view, 0)));
|
assert.throws(TypeError, (() => Atomics.load(view, 0)));
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(ab);
|
var view = new View(ab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.load(view, 0)));
|
assert.throws(TypeError, (() => Atomics.load(view, 0)));
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -14,7 +14,7 @@ var sab = new SharedArrayBuffer(1024);
|
|||||||
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(sab);
|
var view = new View(sab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.load(view, 0)));
|
assert.throws(TypeError, (() => Atomics.load(view, 0)));
|
||||||
}, other_views);
|
}, other_views);
|
||||||
|
@ -18,9 +18,9 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
let view = new View(sab);
|
let view = new View(sab);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
assert.throws(RangeError, () => Atomics.or(view, Idx, 10));
|
assert.throws(RangeError, () => Atomics.or(view, Idx, 10));
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -13,49 +13,49 @@ var ab = new ArrayBuffer(16);
|
|||||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new View(sab, 32, 20);
|
var view = new View(sab, 32, 20);
|
||||||
var control = new View(ab, 0, 2);
|
var control = new View(ab, 0, 2);
|
||||||
|
|
||||||
view[8] = 0x33333333;
|
view[8] = 0x33333333;
|
||||||
control[0] = 0x33333333;
|
control[0] = 0x33333333;
|
||||||
assert.sameValue(Atomics.or(view, 8, 0x55555555), control[0],
|
assert.sameValue(Atomics.or(view, 8, 0x55555555), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
|
|
||||||
control[0] = 0x77777777;
|
control[0] = 0x77777777;
|
||||||
assert.sameValue(view[8], control[0]);
|
assert.sameValue(view[8], control[0]);
|
||||||
assert.sameValue(Atomics.or(view, 8, 0xF0F0F0F0), control[0],
|
assert.sameValue(Atomics.or(view, 8, 0xF0F0F0F0), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
|
|
||||||
control[0] = 0xF7F7F7F7;
|
control[0] = 0xF7F7F7F7;
|
||||||
assert.sameValue(view[8], control[0]);
|
assert.sameValue(view[8], control[0]);
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
||||||
"Result is negative and subject to coercion");
|
"Result is negative and subject to coercion");
|
||||||
assert.sameValue(view[3], control[0]);
|
assert.sameValue(view[3], control[0]);
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
assert.sameValue(view[3], control[0]);
|
assert.sameValue(view[3], control[0]);
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
assert.sameValue(view[3], control[0]);
|
assert.sameValue(view[3], control[0]);
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
// Atomics operations, not quite like view[Idx].
|
// Atomics operations, not quite like view[Idx].
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
assert.sameValue(Atomics.or(view, Idx, 0), 37);
|
assert.sameValue(Atomics.or(view, Idx, 0), 37);
|
||||||
});
|
});
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -10,5 +10,5 @@ features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, le
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, (() => Atomics.or(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.or(view, 0, 0)));
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(ab);
|
var view = new View(ab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.or(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.or(view, 0, 0)));
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -14,7 +14,7 @@ var sab = new SharedArrayBuffer(1024);
|
|||||||
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(sab);
|
var view = new View(sab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.or(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.or(view, 0, 0)));
|
||||||
}, other_views);
|
}, other_views);
|
||||||
|
@ -18,9 +18,9 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
let view = new View(sab);
|
let view = new View(sab);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
assert.throws(RangeError, () => Atomics.store(view, Idx, 10));
|
assert.throws(RangeError, () => Atomics.store(view, Idx, 10));
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -14,43 +14,45 @@ var ab = new ArrayBuffer(16);
|
|||||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new View(sab, 32, 20);
|
var view = new View(sab, 32, 20);
|
||||||
var control = new View(ab, 0, 2);
|
var control = new View(ab, 0, 2);
|
||||||
|
|
||||||
for ( let val of [10,
|
for (let val of [10, -5,
|
||||||
-5,
|
12345,
|
||||||
12345,
|
123456789,
|
||||||
123456789,
|
Math.PI,
|
||||||
Math.PI,
|
"33",
|
||||||
"33",
|
{
|
||||||
{ valueOf: () => 33 },
|
valueOf: () => 33
|
||||||
undefined] )
|
},
|
||||||
{
|
undefined
|
||||||
assert.sameValue(Atomics.store(view, 3, val), ToInteger(val),
|
])
|
||||||
"Atomics.store returns its third argument (" + val + ") converted to Integer, not the input value nor the value that was stored");
|
{
|
||||||
|
assert.sameValue(Atomics.store(view, 3, val), ToInteger(val),
|
||||||
|
"Atomics.store returns its third argument (" + val + ") converted to Integer, not the input value nor the value that was stored");
|
||||||
|
|
||||||
control[0] = val;
|
control[0] = val;
|
||||||
assert.sameValue(view[3], control[0]);
|
assert.sameValue(view[3], control[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0);
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
assert.sameValue(Atomics.load(view, Idx), 37);
|
assert.sameValue(Atomics.load(view, Idx), 37);
|
||||||
});
|
});
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
|
||||||
function ToInteger(v) {
|
function ToInteger(v) {
|
||||||
v = +v;
|
v = +v;
|
||||||
if (isNaN(v))
|
if (isNaN(v))
|
||||||
return 0;
|
return 0;
|
||||||
if (v == 0 || !isFinite(v))
|
if (v == 0 || !isFinite(v))
|
||||||
return v;
|
return v;
|
||||||
if (v < 0)
|
if (v < 0)
|
||||||
return -Math.floor(Math.abs(v));
|
return -Math.floor(Math.abs(v));
|
||||||
return Math.floor(v);
|
return Math.floor(v);
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,5 @@ features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, le
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, (() => Atomics.store(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.store(view, 0, 0)));
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(ab);
|
var view = new View(ab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.store(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.store(view, 0, 0)));
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -14,7 +14,7 @@ var sab = new SharedArrayBuffer(1024);
|
|||||||
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(sab);
|
var view = new View(sab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.store(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.store(view, 0, 0)));
|
||||||
}, other_views);
|
}, other_views);
|
||||||
|
@ -18,9 +18,9 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
let view = new View(sab);
|
let view = new View(sab);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
assert.throws(RangeError, () => Atomics.sub(view, Idx, 10));
|
assert.throws(RangeError, () => Atomics.sub(view, Idx, 10));
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -14,42 +14,42 @@ var ab = new ArrayBuffer(16);
|
|||||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new View(sab, 32, 20);
|
var view = new View(sab, 32, 20);
|
||||||
var control = new View(ab, 0, 2);
|
var control = new View(ab, 0, 2);
|
||||||
|
|
||||||
view[8] = 100;
|
view[8] = 100;
|
||||||
assert.sameValue(Atomics.sub(view, 8, 10), 100,
|
assert.sameValue(Atomics.sub(view, 8, 10), 100,
|
||||||
"Subtract positive number");
|
"Subtract positive number");
|
||||||
assert.sameValue(view[8], 90);
|
assert.sameValue(view[8], 90);
|
||||||
|
|
||||||
assert.sameValue(Atomics.sub(view, 8, -5), 90,
|
assert.sameValue(Atomics.sub(view, 8, -5), 90,
|
||||||
"Subtract negative number, though result remains positive");
|
"Subtract negative number, though result remains positive");
|
||||||
assert.sameValue(view[8], 95);
|
assert.sameValue(view[8], 95);
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
||||||
"Result is negative and subject to coercion");
|
"Result is negative and subject to coercion");
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
// Atomics operations, not quite like view[Idx].
|
// Atomics operations, not quite like view[Idx].
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
assert.sameValue(Atomics.sub(view, Idx, 0), 37);
|
assert.sameValue(Atomics.sub(view, Idx, 0), 37);
|
||||||
});
|
});
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -10,5 +10,5 @@ features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, le
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, (() => Atomics.sub(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.sub(view, 0, 0)));
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(ab);
|
var view = new View(ab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.sub(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.sub(view, 0, 0)));
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -14,7 +14,7 @@ var sab = new SharedArrayBuffer(1024);
|
|||||||
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(sab);
|
var view = new View(sab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.sub(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.sub(view, 0, 0)));
|
||||||
}, other_views);
|
}, other_views);
|
||||||
|
@ -24,11 +24,11 @@ var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
|||||||
|
|
||||||
$262.agent.broadcast(ia.buffer);
|
$262.agent.broadcast(ia.buffer);
|
||||||
assert.sameValue(getReport(), "timed-out");
|
assert.sameValue(getReport(), "timed-out");
|
||||||
assert.sameValue((getReport()|0) >= 500 - $ATOMICS_MAX_TIME_EPSILON, true);
|
assert.sameValue((getReport() | 0) >= 500 - $ATOMICS_MAX_TIME_EPSILON, true);
|
||||||
|
|
||||||
function getReport() {
|
function getReport() {
|
||||||
var r;
|
var r;
|
||||||
while ((r = $262.agent.getReport()) == null)
|
while ((r = $262.agent.getReport()) == null)
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -47,11 +47,11 @@ assert.sameValue(getReport(), "A timed-out");
|
|||||||
assert.sameValue(getReport(), "B not-equal"); // Even with zero timeout
|
assert.sameValue(getReport(), "B not-equal"); // Even with zero timeout
|
||||||
var r;
|
var r;
|
||||||
while ((r = getReport()) != "done")
|
while ((r = getReport()) != "done")
|
||||||
assert.sameValue(r, "C not-equal");
|
assert.sameValue(r, "C not-equal");
|
||||||
|
|
||||||
function getReport() {
|
function getReport() {
|
||||||
var r;
|
var r;
|
||||||
while ((r = $262.agent.getReport()) == null)
|
while ((r = $262.agent.getReport()) == null)
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,14 @@ $262.agent.receiveBroadcast(function (sab, id) {
|
|||||||
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||||
|
|
||||||
$262.agent.broadcast(ia.buffer);
|
$262.agent.broadcast(ia.buffer);
|
||||||
$262.agent.sleep(500); // Ample time
|
$262.agent.sleep(500); // Ample time
|
||||||
assert.sameValue($262.agent.getReport(), null);
|
assert.sameValue($262.agent.getReport(), null);
|
||||||
Atomics.wake(ia, 0);
|
Atomics.wake(ia, 0);
|
||||||
assert.sameValue(getReport(), "ok");
|
assert.sameValue(getReport(), "ok");
|
||||||
|
|
||||||
function getReport() {
|
function getReport() {
|
||||||
var r;
|
var r;
|
||||||
while ((r = $262.agent.getReport()) == null)
|
while ((r = $262.agent.getReport()) == null)
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@ $262.agent.broadcast(ia.buffer);
|
|||||||
assert.sameValue(getReport(), "timed-out");
|
assert.sameValue(getReport(), "timed-out");
|
||||||
|
|
||||||
function getReport() {
|
function getReport() {
|
||||||
var r;
|
var r;
|
||||||
while ((r = $262.agent.getReport()) == null)
|
while ((r = $262.agent.getReport()) == null)
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -24,15 +24,15 @@ $262.agent.receiveBroadcast(function (sab, id) {
|
|||||||
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||||
|
|
||||||
$262.agent.broadcast(ia.buffer);
|
$262.agent.broadcast(ia.buffer);
|
||||||
$262.agent.sleep(500); // Give the agent a chance to wait
|
$262.agent.sleep(500); // Give the agent a chance to wait
|
||||||
Atomics.store(ia, 0, 1); // Change the value, should not wake the agent
|
Atomics.store(ia, 0, 1); // Change the value, should not wake the agent
|
||||||
$262.agent.sleep(500); // Wait some more so that we can tell
|
$262.agent.sleep(500); // Wait some more so that we can tell
|
||||||
Atomics.wake(ia, 0); // Really wake it up
|
Atomics.wake(ia, 0); // Really wake it up
|
||||||
assert.sameValue((getReport()|0) >= 1000 - $ATOMICS_MAX_TIME_EPSILON, true);
|
assert.sameValue((getReport() | 0) >= 1000 - $ATOMICS_MAX_TIME_EPSILON, true);
|
||||||
|
|
||||||
function getReport() {
|
function getReport() {
|
||||||
var r;
|
var r;
|
||||||
while ((r = $262.agent.getReport()) == null)
|
while ((r = $262.agent.getReport()) == null)
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,5 @@ features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, le
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, (() => Atomics.wait(view, 0, 0, 0))); // Even with zero timeout
|
assert.throws(TypeError, (() => Atomics.wait(view, 0, 0, 0))); // Even with zero timeout
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(ab);
|
var view = new View(ab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.wait(view, 0, 0, 0))); // Should fail even if waiting 0ms
|
assert.throws(TypeError, (() => Atomics.wait(view, 0, 0, 0))); // Should fail even if waiting 0ms
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -15,8 +15,8 @@ var other_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array,
|
|||||||
Uint8ClampedArray, Float32Array, Float64Array];
|
Uint8ClampedArray, Float32Array, Float64Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(sab);
|
var view = new View(sab);
|
||||||
|
|
||||||
// Even with timout zero this should fail
|
// Even with timout zero this should fail
|
||||||
assert.throws(TypeError, (() => Atomics.wait(view, 0, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.wait(view, 0, 0, 0)));
|
||||||
}, other_views);
|
}, other_views);
|
||||||
|
@ -19,14 +19,13 @@ $262.agent.receiveBroadcast(function (sab, id) {
|
|||||||
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||||
|
|
||||||
$262.agent.broadcast(ia.buffer);
|
$262.agent.broadcast(ia.buffer);
|
||||||
$262.agent.sleep(500); // Give the agent a chance to wait
|
$262.agent.sleep(500); // Give the agent a chance to wait
|
||||||
Atomics.wake(ia, 0);
|
Atomics.wake(ia, 0);
|
||||||
assert.sameValue(getReport(), "ok");
|
assert.sameValue(getReport(), "ok");
|
||||||
|
|
||||||
function getReport() {
|
function getReport() {
|
||||||
var r;
|
var r;
|
||||||
while ((r = $262.agent.getReport()) == null)
|
while ((r = $262.agent.getReport()) == null)
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,10 +20,10 @@ assert.sameValue(Atomics.wake(view, 0, 1), 0);
|
|||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
// Atomics operations, not quite like view[Idx].
|
// Atomics operations, not quite like view[Idx].
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
assert.sameValue(Atomics.wake(view, Idx, 1), 0);
|
assert.sameValue(Atomics.wake(view, Idx, 1), 0);
|
||||||
});
|
});
|
||||||
|
@ -10,5 +10,5 @@ features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, le
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, (() => Atomics.wake(view, 0, 0))); // Even with count == 0
|
assert.throws(TypeError, (() => Atomics.wake(view, 0, 0))); // Even with count == 0
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(ab);
|
var view = new View(ab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.wake(view, 0, 0))); // Should fail even if waking zero waiters
|
assert.throws(TypeError, (() => Atomics.wake(view, 0, 0))); // Should fail even if waking zero waiters
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -15,8 +15,8 @@ var other_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array,
|
|||||||
Uint8ClampedArray, Float32Array, Float64Array];
|
Uint8ClampedArray, Float32Array, Float64Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(sab);
|
var view = new View(sab);
|
||||||
|
|
||||||
// Even with timout zero this should fail
|
// Even with timout zero this should fail
|
||||||
assert.throws(TypeError, (() => Atomics.wake(view, 0, 0))); // Even with 0 to wake this should fail
|
assert.throws(TypeError, (() => Atomics.wake(view, 0, 0))); // Even with 0 to wake this should fail
|
||||||
}, other_views);
|
}, other_views);
|
||||||
|
@ -42,7 +42,7 @@ var ia = new Int32Array(new SharedArrayBuffer(NUMELEM * Int32Array.BYTES_PER_ELE
|
|||||||
$262.agent.broadcast(ia.buffer);
|
$262.agent.broadcast(ia.buffer);
|
||||||
|
|
||||||
// Wait for agents to be running.
|
// Wait for agents to be running.
|
||||||
waitUntil(ia, RUNNING, NUMAGENT+1);
|
waitUntil(ia, RUNNING, NUMAGENT + 1);
|
||||||
|
|
||||||
// Then wait some more to give the agents a fair chance to wait. If we don't,
|
// Then wait some more to give the agents a fair chance to wait. If we don't,
|
||||||
// we risk sending the wakeup before agents are sleeping, and we hang.
|
// we risk sending the wakeup before agents are sleeping, and we hang.
|
||||||
@ -52,26 +52,26 @@ $262.agent.sleep(500);
|
|||||||
assert.sameValue(Atomics.wake(ia, WAKEUP), NUMAGENT);
|
assert.sameValue(Atomics.wake(ia, WAKEUP), NUMAGENT);
|
||||||
|
|
||||||
var rs = [];
|
var rs = [];
|
||||||
for (var i=0; i < NUMAGENT+1; i++)
|
for (var i = 0; i < NUMAGENT + 1; i++)
|
||||||
rs.push(getReport());
|
rs.push(getReport());
|
||||||
rs.sort();
|
rs.sort();
|
||||||
|
|
||||||
for (var i=0; i < NUMAGENT; i++)
|
for (var i = 0; i < NUMAGENT; i++)
|
||||||
assert.sameValue(rs[i], "A ok");
|
assert.sameValue(rs[i], "A ok");
|
||||||
assert.sameValue(rs[NUMAGENT], "B timed-out");
|
assert.sameValue(rs[NUMAGENT], "B timed-out");
|
||||||
|
|
||||||
function getReport() {
|
function getReport() {
|
||||||
var r;
|
var r;
|
||||||
while ((r = $262.agent.getReport()) == null)
|
while ((r = $262.agent.getReport()) == null)
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitUntil(ia, k, value) {
|
function waitUntil(ia, k, value) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while (Atomics.load(ia, k) !== value && i < 15) {
|
while (Atomics.load(ia, k) !== value && i < 15) {
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
assert.sameValue(Atomics.load(ia, k), value, "All agents are running");
|
assert.sameValue(Atomics.load(ia, k), value, "All agents are running");
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ var ia = new Int32Array(new SharedArrayBuffer(NUMELEM * Int32Array.BYTES_PER_ELE
|
|||||||
$262.agent.broadcast(ia.buffer);
|
$262.agent.broadcast(ia.buffer);
|
||||||
|
|
||||||
// Wait for agents to be running.
|
// Wait for agents to be running.
|
||||||
waitUntil(ia, RUNNING, NUMAGENT+1);
|
waitUntil(ia, RUNNING, NUMAGENT + 1);
|
||||||
|
|
||||||
// Then wait some more to give the agents a fair chance to wait. If we don't,
|
// Then wait some more to give the agents a fair chance to wait. If we don't,
|
||||||
// we risk sending the wakeup before agents are sleeping, and we hang.
|
// we risk sending the wakeup before agents are sleeping, and we hang.
|
||||||
@ -51,26 +51,26 @@ $262.agent.sleep(500);
|
|||||||
assert.sameValue(Atomics.wake(ia, WAKEUP), NUMAGENT);
|
assert.sameValue(Atomics.wake(ia, WAKEUP), NUMAGENT);
|
||||||
|
|
||||||
var rs = [];
|
var rs = [];
|
||||||
for (var i=0; i < NUMAGENT+1; i++)
|
for (var i = 0; i < NUMAGENT + 1; i++)
|
||||||
rs.push(getReport());
|
rs.push(getReport());
|
||||||
rs.sort();
|
rs.sort();
|
||||||
|
|
||||||
for (var i=0; i < NUMAGENT; i++)
|
for (var i = 0; i < NUMAGENT; i++)
|
||||||
assert.sameValue(rs[i], "A ok");
|
assert.sameValue(rs[i], "A ok");
|
||||||
assert.sameValue(rs[NUMAGENT], "B timed-out");
|
assert.sameValue(rs[NUMAGENT], "B timed-out");
|
||||||
|
|
||||||
function getReport() {
|
function getReport() {
|
||||||
var r;
|
var r;
|
||||||
while ((r = $262.agent.getReport()) == null)
|
while ((r = $262.agent.getReport()) == null)
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitUntil(ia, k, value) {
|
function waitUntil(ia, k, value) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while (Atomics.load(ia, k) !== value && i < 15) {
|
while (Atomics.load(ia, k) !== value && i < 15) {
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
assert.sameValue(Atomics.load(ia, k), value, "All agents are running");
|
assert.sameValue(Atomics.load(ia, k), value, "All agents are running");
|
||||||
}
|
}
|
||||||
|
@ -43,29 +43,29 @@ waitUntil(ia, RUNNING, NUMAGENT);
|
|||||||
$262.agent.sleep(500);
|
$262.agent.sleep(500);
|
||||||
|
|
||||||
// Make them sleep in order 0 1 2 on ia[0]
|
// Make them sleep in order 0 1 2 on ia[0]
|
||||||
for ( var i=0 ; i < NUMAGENT ; i++ ) {
|
for (var i = 0; i < NUMAGENT; i++) {
|
||||||
Atomics.store(ia, SPIN + i, 1);
|
Atomics.store(ia, SPIN + i, 1);
|
||||||
$262.agent.sleep(500);
|
$262.agent.sleep(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wake them up one at a time and check the order is 0 1 2
|
// Wake them up one at a time and check the order is 0 1 2
|
||||||
for ( var i=0 ; i < NUMAGENT ; i++ ) {
|
for (var i = 0; i < NUMAGENT; i++) {
|
||||||
assert.sameValue(Atomics.wake(ia, WAKEUP, 1), 1);
|
assert.sameValue(Atomics.wake(ia, WAKEUP, 1), 1);
|
||||||
assert.sameValue(getReport(), i + "ok");
|
assert.sameValue(getReport(), i + "ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
function getReport() {
|
function getReport() {
|
||||||
var r;
|
var r;
|
||||||
while ((r = $262.agent.getReport()) == null)
|
while ((r = $262.agent.getReport()) == null)
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitUntil(ia, k, value) {
|
function waitUntil(ia, k, value) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while (Atomics.load(ia, k) !== value && i < 15) {
|
while (Atomics.load(ia, k) !== value && i < 15) {
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
assert.sameValue(Atomics.load(ia, k), value, "All agents are running");
|
assert.sameValue(Atomics.load(ia, k), value, "All agents are running");
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,13 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||||||
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||||
|
|
||||||
$262.agent.broadcast(ia.buffer);
|
$262.agent.broadcast(ia.buffer);
|
||||||
$262.agent.sleep(500); // Give the agent a chance to wait
|
$262.agent.sleep(500); // Give the agent a chance to wait
|
||||||
assert.sameValue(Atomics.wake(ia, 0, NaN), 0); // Don't actually wake it
|
assert.sameValue(Atomics.wake(ia, 0, NaN), 0); // Don't actually wake it
|
||||||
assert.sameValue(getReport(), "timed-out");
|
assert.sameValue(getReport(), "timed-out");
|
||||||
|
|
||||||
function getReport() {
|
function getReport() {
|
||||||
var r;
|
var r;
|
||||||
while ((r = $262.agent.getReport()) == null)
|
while ((r = $262.agent.getReport()) == null)
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,13 @@ $262.agent.receiveBroadcast(function (sab) {
|
|||||||
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||||
|
|
||||||
$262.agent.broadcast(ia.buffer);
|
$262.agent.broadcast(ia.buffer);
|
||||||
$262.agent.sleep(500); // Give the agent a chance to wait
|
$262.agent.sleep(500); // Give the agent a chance to wait
|
||||||
assert.sameValue(Atomics.wake(ia, 0, -1), 0); // Don't actually wake it
|
assert.sameValue(Atomics.wake(ia, 0, -1), 0); // Don't actually wake it
|
||||||
assert.sameValue(getReport(), "timed-out");
|
assert.sameValue(getReport(), "timed-out");
|
||||||
|
|
||||||
function getReport() {
|
function getReport() {
|
||||||
var r;
|
var r;
|
||||||
while ((r = $262.agent.getReport()) == null)
|
while ((r = $262.agent.getReport()) == null)
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -45,27 +45,27 @@ assert.sameValue(Atomics.wake(ia, 0, WAKECOUNT), WAKECOUNT);
|
|||||||
|
|
||||||
// Collect and check results
|
// Collect and check results
|
||||||
var rs = [];
|
var rs = [];
|
||||||
for ( var i=0; i < NUMAGENT; i++ )
|
for (var i = 0; i < NUMAGENT; i++)
|
||||||
rs.push(getReport());
|
rs.push(getReport());
|
||||||
rs.sort();
|
rs.sort();
|
||||||
|
|
||||||
for ( var i=0; i < WAKECOUNT; i++ )
|
for (var i = 0; i < WAKECOUNT; i++)
|
||||||
assert.sameValue(rs[i], "ok");
|
assert.sameValue(rs[i], "ok");
|
||||||
for ( var i=WAKECOUNT; i < NUMAGENT; i++ )
|
for (var i = WAKECOUNT; i < NUMAGENT; i++)
|
||||||
assert.sameValue(rs[i], "timed-out");
|
assert.sameValue(rs[i], "timed-out");
|
||||||
|
|
||||||
function getReport() {
|
function getReport() {
|
||||||
var r;
|
var r;
|
||||||
while ((r = $262.agent.getReport()) == null)
|
while ((r = $262.agent.getReport()) == null)
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitUntil(ia, k, value) {
|
function waitUntil(ia, k, value) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while (Atomics.load(ia, k) !== value && i < 15) {
|
while (Atomics.load(ia, k) !== value && i < 15) {
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
assert.sameValue(Atomics.load(ia, k), value, "All agents are running");
|
assert.sameValue(Atomics.load(ia, k), value, "All agents are running");
|
||||||
}
|
}
|
||||||
|
@ -46,27 +46,27 @@ assert.sameValue(Atomics.wake(ia, 0, WAKECOUNT), WAKECOUNT);
|
|||||||
|
|
||||||
// Collect and check results
|
// Collect and check results
|
||||||
var rs = [];
|
var rs = [];
|
||||||
for ( var i=0; i < NUMAGENT; i++ )
|
for (var i = 0; i < NUMAGENT; i++)
|
||||||
rs.push(getReport());
|
rs.push(getReport());
|
||||||
rs.sort();
|
rs.sort();
|
||||||
|
|
||||||
for ( var i=0; i < WAKECOUNT; i++ )
|
for (var i = 0; i < WAKECOUNT; i++)
|
||||||
assert.sameValue(rs[i], "ok");
|
assert.sameValue(rs[i], "ok");
|
||||||
for ( var i=WAKECOUNT; i < NUMAGENT; i++ )
|
for (var i = WAKECOUNT; i < NUMAGENT; i++)
|
||||||
assert.sameValue(rs[i], "timed-out");
|
assert.sameValue(rs[i], "timed-out");
|
||||||
|
|
||||||
function getReport() {
|
function getReport() {
|
||||||
var r;
|
var r;
|
||||||
while ((r = $262.agent.getReport()) == null)
|
while ((r = $262.agent.getReport()) == null)
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitUntil(ia, k, value) {
|
function waitUntil(ia, k, value) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while (Atomics.load(ia, k) !== value && i < 15) {
|
while (Atomics.load(ia, k) !== value && i < 15) {
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
assert.sameValue(Atomics.load(ia, k), value, "All agents are running");
|
assert.sameValue(Atomics.load(ia, k), value, "All agents are running");
|
||||||
}
|
}
|
||||||
|
@ -46,27 +46,27 @@ assert.sameValue(Atomics.wake(ia, 0, WAKECOUNT), WAKECOUNT);
|
|||||||
|
|
||||||
// Collect and check results
|
// Collect and check results
|
||||||
var rs = [];
|
var rs = [];
|
||||||
for ( var i=0; i < NUMAGENT; i++ )
|
for (var i = 0; i < NUMAGENT; i++)
|
||||||
rs.push(getReport());
|
rs.push(getReport());
|
||||||
rs.sort();
|
rs.sort();
|
||||||
|
|
||||||
for ( var i=0; i < WAKECOUNT; i++ )
|
for (var i = 0; i < WAKECOUNT; i++)
|
||||||
assert.sameValue(rs[i], "ok");
|
assert.sameValue(rs[i], "ok");
|
||||||
for ( var i=WAKECOUNT; i < NUMAGENT; i++ )
|
for (var i = WAKECOUNT; i < NUMAGENT; i++)
|
||||||
assert.sameValue(rs[i], "timed-out");
|
assert.sameValue(rs[i], "timed-out");
|
||||||
|
|
||||||
function getReport() {
|
function getReport() {
|
||||||
var r;
|
var r;
|
||||||
while ((r = $262.agent.getReport()) == null)
|
while ((r = $262.agent.getReport()) == null)
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitUntil(ia, k, value) {
|
function waitUntil(ia, k, value) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while (Atomics.load(ia, k) !== value && i < 15) {
|
while (Atomics.load(ia, k) !== value && i < 15) {
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
assert.sameValue(Atomics.load(ia, k), value, "All agents are running");
|
assert.sameValue(Atomics.load(ia, k), value, "All agents are running");
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
let view = new View(sab);
|
let view = new View(sab);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
assert.throws(RangeError, () => Atomics.xor(view, Idx, 0));
|
assert.throws(RangeError, () => Atomics.xor(view, Idx, 0));
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -13,50 +13,50 @@ var ab = new ArrayBuffer(16);
|
|||||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new View(sab, 32, 20);
|
var view = new View(sab, 32, 20);
|
||||||
var control = new View(ab, 0, 2);
|
var control = new View(ab, 0, 2);
|
||||||
|
|
||||||
view[8] = 0x33333333;
|
view[8] = 0x33333333;
|
||||||
control[0] = 0x33333333;
|
control[0] = 0x33333333;
|
||||||
assert.sameValue(Atomics.xor(view, 8, 0x55555555), control[0],
|
assert.sameValue(Atomics.xor(view, 8, 0x55555555), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
|
|
||||||
control[0] = 0x66666666;
|
control[0] = 0x66666666;
|
||||||
assert.sameValue(view[8], control[0]);
|
assert.sameValue(view[8], control[0]);
|
||||||
assert.sameValue(Atomics.xor(view, 8, 0xF0F0F0F0), control[0],
|
assert.sameValue(Atomics.xor(view, 8, 0xF0F0F0F0), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
|
|
||||||
control[0] = 0x96969696;
|
control[0] = 0x96969696;
|
||||||
assert.sameValue(view[8], control[0]);
|
assert.sameValue(view[8], control[0]);
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.xor(view, 3, 0), control[0],
|
assert.sameValue(Atomics.xor(view, 3, 0), control[0],
|
||||||
"Result is negative and subject to coercion");
|
"Result is negative and subject to coercion");
|
||||||
assert.sameValue(view[3], control[0]);
|
assert.sameValue(view[3], control[0]);
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.xor(view, 3, 0), control[0],
|
assert.sameValue(Atomics.xor(view, 3, 0), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
assert.sameValue(view[3], control[0]);
|
assert.sameValue(view[3], control[0]);
|
||||||
|
|
||||||
// And again
|
// And again
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.xor(view, 3, 0), control[0],
|
assert.sameValue(Atomics.xor(view, 3, 0), control[0],
|
||||||
"Result is subject to chopping");
|
"Result is subject to chopping");
|
||||||
assert.sameValue(view[3], control[0]);
|
assert.sameValue(view[3], control[0]);
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
// Atomics operations, not quite like view[Idx].
|
// Atomics operations, not quite like view[Idx].
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
assert.sameValue(Atomics.xor(view, Idx, 0), 37);
|
assert.sameValue(Atomics.xor(view, Idx, 0), 37);
|
||||||
});
|
});
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -10,5 +10,5 @@ features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, le
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, (() => Atomics.xor(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.xor(view, 0, 0)));
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@ if (typeof BigInt !== "undefined") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(ab);
|
var view = new View(ab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.xor(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.xor(view, 0, 0)));
|
||||||
}, int_views);
|
}, int_views);
|
||||||
|
@ -14,7 +14,7 @@ var sab = new SharedArrayBuffer(1024);
|
|||||||
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(View) {
|
testWithTypedArrayConstructors(function(View) {
|
||||||
var view = new View(sab);
|
var view = new View(sab);
|
||||||
|
|
||||||
assert.throws(TypeError, (() => Atomics.xor(view, 0, 0)));
|
assert.throws(TypeError, (() => Atomics.xor(view, 0, 0)));
|
||||||
}, other_views);
|
}, other_views);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user