Bug 1246140 - test for Atomics.store return value. r=h4writer
authorLars T Hansen <lhansen@mozilla.com>
Fri, 04 Nov 2016 13:01:42 +0100
changeset 351425 f7fe9d1a41f3ae291e4926de88559411ea0f0cd1
parent 351424 00c0fdd359040cf9c5515522a620f06ea26cc6ba
child 351426 e66184c7eb45ae566a7e2bce62c9b109e945d405
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs1246140
milestone52.0a1
Bug 1246140 - test for Atomics.store return value. r=h4writer
js/src/jit-test/tests/atomics/store-does-not-truncate-returnval.js
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/atomics/store-does-not-truncate-returnval.js
@@ -0,0 +1,42 @@
+if (!this.SharedArrayBuffer)
+    quit(0);
+
+var ia = new Int32Array(new SharedArrayBuffer(4));
+
+// Atomics.store() returns the input value converted to integer as if
+// by ToInteger.
+//
+// JIT and interpreter have different paths here, so loop a little to
+// trigger the JIT properly.
+
+function f() {
+    assertEq(Atomics.store(ia, 0, 3.5), 3);
+    assertEq(ia[0], 3);
+
+    assertEq(Atomics.store(ia, 0, -0), -0);
+    assertEq(ia[0], 0);
+
+    assertEq(Atomics.store(ia, 0, '4.6'), 4);
+    assertEq(ia[0], 4);
+
+    assertEq(Atomics.store(ia, 0, '-4.6'), -4);
+    assertEq(ia[0], -4);
+
+    assertEq(Atomics.store(ia, 0, undefined), 0);
+    assertEq(ia[0], 0);
+
+    assertEq(Atomics.store(ia, 0, Infinity), Infinity);
+    assertEq(ia[0], 0);
+
+    assertEq(Atomics.store(ia, 0, -Infinity), -Infinity);
+    assertEq(ia[0], 0);
+
+    assertEq(Atomics.store(ia, 0, Math.pow(2, 32)+5), Math.pow(2, 32)+5);
+    assertEq(ia[0], 5);
+
+    assertEq(Atomics.store(ia, 0, { valueOf: () => 3.7 }), 3);
+    assertEq(ia[0], 3);
+}
+
+for ( var i=0 ; i < 10 ; i++ )
+    f();