From 0059b4783d67d26660290b39facb4d41b613d811 Mon Sep 17 00:00:00 2001 From: Amal Hussein Date: Mon, 19 Mar 2018 10:22:13 -0400 Subject: [PATCH] additional test coverage for atomics.wait + removing old tests which have been replaced + test cleanup and renaming test files for consistency --- test/built-ins/Atomics/wait/did-timeout.js | 2 +- test/built-ins/Atomics/wait/negative-timeout.js | 2 ++ .../wait/poisoned-object-for-timeout-throws.js | 13 +++++++------ .../Atomics/wait/symbol-for-timeout-throws.js | 8 +++++--- test/built-ins/Atomics/wait/true-for-timeout.js | 2 +- .../Atomics/wait/wait-index-value-not-equal.js | 3 +-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/test/built-ins/Atomics/wait/did-timeout.js b/test/built-ins/Atomics/wait/did-timeout.js index 337a45bbc9..908d0382d4 100644 --- a/test/built-ins/Atomics/wait/did-timeout.js +++ b/test/built-ins/Atomics/wait/did-timeout.js @@ -24,10 +24,10 @@ $262.agent.receiveBroadcast(function (sab, id) { var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)); $262.agent.broadcast(ia.buffer); + assert.sameValue(getReport(), "timed-out"); assert.sameValue((getReport() | 0) >= 500 - $ATOMICS_MAX_TIME_EPSILON, true); - function getReport() { var r; while ((r = $262.agent.getReport()) == null) diff --git a/test/built-ins/Atomics/wait/negative-timeout.js b/test/built-ins/Atomics/wait/negative-timeout.js index 84ce5ce190..6b91448211 100644 --- a/test/built-ins/Atomics/wait/negative-timeout.js +++ b/test/built-ins/Atomics/wait/negative-timeout.js @@ -28,3 +28,5 @@ function getReport() { $262.agent.sleep(100); return r; } + +assert.sameValue(Atomics.wake(ia, 0), 0); diff --git a/test/built-ins/Atomics/wait/poisoned-object-for-timeout-throws.js b/test/built-ins/Atomics/wait/poisoned-object-for-timeout-throws.js index 0ca369b12a..2145a37be0 100644 --- a/test/built-ins/Atomics/wait/poisoned-object-for-timeout-throws.js +++ b/test/built-ins/Atomics/wait/poisoned-object-for-timeout-throws.js @@ -31,21 +31,20 @@ function getReport() { $262.agent.start( ` $262.agent.receiveBroadcast(function (sab) { - - var int32Array = new Int32Array(sab); + + var int32Array = new Int32Array(sab); + var poisoned = { valueOf: false, toString: false }; - var err; try { Atomics.wait(int32Array, 0, 0, poisoned); } catch(e) { - err = e.name; + $262.agent.report(e.name); } - - $262.agent.report(err); + $262.agent.leaving(); }) `); @@ -55,6 +54,8 @@ var int32Array = new Int32Array(sab); $262.agent.broadcast(int32Array.buffer); +$262.agent.sleep(150); + assert.sameValue(getReport(), 'TypeError'); assert.sameValue(Atomics.wake(int32Array, 0), 0); diff --git a/test/built-ins/Atomics/wait/symbol-for-timeout-throws.js b/test/built-ins/Atomics/wait/symbol-for-timeout-throws.js index dd003bf5e7..9a46c15fb2 100644 --- a/test/built-ins/Atomics/wait/symbol-for-timeout-throws.js +++ b/test/built-ins/Atomics/wait/symbol-for-timeout-throws.js @@ -27,15 +27,13 @@ $262.agent.start( $262.agent.receiveBroadcast(function (sab) { var int32Array = new Int32Array(sab); - var err; try { Atomics.wait(int32Array, 0, 0, Symbol('foo')); } catch(e) { - err = e.name; + $262.agent.report(e.name); } - $262.agent.report(err); $262.agent.leaving(); }) `); @@ -45,4 +43,8 @@ var int32Array = new Int32Array(sab); $262.agent.broadcast(int32Array.buffer); +$262.agent.sleep(150); + assert.sameValue(getReport(), 'TypeError'); + +assert.sameValue(Atomics.wake(int32Array, 0), 0); diff --git a/test/built-ins/Atomics/wait/true-for-timeout.js b/test/built-ins/Atomics/wait/true-for-timeout.js index fd4f4e62ce..8fc9d331f3 100644 --- a/test/built-ins/Atomics/wait/true-for-timeout.js +++ b/test/built-ins/Atomics/wait/true-for-timeout.js @@ -38,7 +38,7 @@ var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEME $262.agent.broadcast(int32Array.buffer); -$262.agent.sleep(2); +$262.agent.sleep(150); var r1 = getReport(); var r2 = getReport(); diff --git a/test/built-ins/Atomics/wait/wait-index-value-not-equal.js b/test/built-ins/Atomics/wait/wait-index-value-not-equal.js index b40986abc9..23484d7970 100644 --- a/test/built-ins/Atomics/wait/wait-index-value-not-equal.js +++ b/test/built-ins/Atomics/wait/wait-index-value-not-equal.js @@ -17,9 +17,8 @@ features: [ Atomics, SharedArrayBuffer, TypedArray ] function getReport() { var r; - while ((r = $262.agent.getReport()) == null) { + while ((r = $262.agent.getReport()) == null) $262.agent.sleep(100); - } return r; }