From 7ec0cdba6c506d6d6a00d8152c73581f76167832 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Mon, 25 Jun 2018 14:46:50 -0400 Subject: [PATCH] Atomics: more fixes for review --- .../Atomics/and/expected-return-value.js | 14 ++++++----- .../waiterlist-block-indexedposition-wake.js | 25 +++++++++++-------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/test/built-ins/Atomics/and/expected-return-value.js b/test/built-ins/Atomics/and/expected-return-value.js index f45d2a400c..fa23873e6c 100644 --- a/test/built-ins/Atomics/and/expected-return-value.js +++ b/test/built-ins/Atomics/and/expected-return-value.js @@ -29,14 +29,16 @@ features: [Atomics, SharedArrayBuffer, TypedArray] var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT); var i32a = new Int32Array(buffer); -var value = 0b00000001000000001000000010000001; +var initial = 0b00000001000000001000000010000001; var other = 0b00000001111111111000000011111111; +var anded = 0b00000001000000001000000010000001; -i32a[0] = value; +i32a[0] = initial; assert.sameValue( - Atomics.and(i32a, 0, value), - value, - 'Atomics.and(i32a, 0, value) equals the value of value (0b00000001000000001000000010000001)' + Atomics.and(i32a, 0, other), + initial, + 'Atomics.and(i32a, 0, other) equals the value of `initial` (0b00000001000000001000000010000001)' ); -assert.sameValue(i32a[0], value & other, 'The value of i32a[0] is value & other'); + +assert.sameValue(i32a[0], anded, 'The value of i32a[0] equals the value of `anded` (0b00000001000000001000000010000001)'); diff --git a/test/built-ins/Atomics/wait/waiterlist-block-indexedposition-wake.js b/test/built-ins/Atomics/wait/waiterlist-block-indexedposition-wake.js index 20fc23f999..c25fb386cc 100644 --- a/test/built-ins/Atomics/wait/waiterlist-block-indexedposition-wake.js +++ b/test/built-ins/Atomics/wait/waiterlist-block-indexedposition-wake.js @@ -27,8 +27,7 @@ $262.agent.start(` const i32a = new Int32Array(sab); // Wait on index 0 - Atomics.wait(i32a, 0, 0, 200); - $262.agent.report(0); + $262.agent.report(Atomics.wait(i32a, 0, 0, Infinity)); $262.agent.leaving(); }); `); @@ -38,23 +37,27 @@ $262.agent.start(` const i32a = new Int32Array(sab); // Wait on index 2 - Atomics.wait(i32a, 2, 0, 200); - $262.agent.report(2); + $262.agent.report(Atomics.wait(i32a, 2, 0, Infinity)); $262.agent.leaving(); }); `); const i32a = new Int32Array( - new SharedArrayBuffer(4 * Int32Array.BYTES_PER_ELEMENT) + new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) ); $262.agent.broadcast(i32a.buffer); $262.agent.sleep(10); -// Wake index 2 -Atomics.wake(i32a, 2, 1); -assert.sameValue(getReport(), '2'); +// Wake index 1, wakes nothing +assert.sameValue(Atomics.wake(i32a, 1), 0, 'Atomics.wake(i32a, 1) returns 0'); +// Wake index 3, wakes nothing +assert.sameValue(Atomics.wake(i32a, 3), 0, 'Atomics.wake(i32a, 3) returns 0'); -// Wake index 0 -Atomics.wake(i32a, 0, 1); -assert.sameValue(getReport(), '0'); +// Wake index 2, wakes 1 +assert.sameValue(Atomics.wake(i32a, 2), 1, 'Atomics.wake(i32a, 2) returns 1'); +assert.sameValue(getReport(), 'ok', 'getReport() returns "ok"'); + +// Wake index 0, wakes 1 +assert.sameValue(Atomics.wake(i32a, 0), 1, 'Atomics.wake(i32a, 0) returns 1'); +assert.sameValue(getReport(), 'ok', 'getReport() returns "ok"');