Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Unified Diff: test/mjsunit/harmony/atomics.js

Issue 1232243002: In Atomics API, convert operands to numbers before calling runtime. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: feedback Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/harmony-atomics.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/atomics.js
diff --git a/test/mjsunit/harmony/atomics.js b/test/mjsunit/harmony/atomics.js
index ff403b8bd1d47cc0b53d994220abc90025ec52f7..09344a1bf78354400b3d9f17672b99905773629d 100644
--- a/test/mjsunit/harmony/atomics.js
+++ b/test/mjsunit/harmony/atomics.js
@@ -344,6 +344,58 @@ function testAtomicOp(op, ia, index, expectedIndex, name) {
}
})();
+(function TestToNumber() {
+ IntegerTypedArrayConstructors.forEach(function(t) {
+ var sab = new SharedArrayBuffer(1 * t.constr.BYTES_PER_ELEMENT);
+ var sta = new t.constr(sab);
+
+ var valueOf = {valueOf: function(){ return 3;}};
+ var toString = {toString: function(){ return '3';}};
+
+ [false, true, undefined, valueOf, toString].forEach(function(v) {
+ var name = Object.prototype.toString.call(sta) + ' - ' + v;
+
+ // CompareExchange
+ sta[0] = 50;
+ assertEquals(50, Atomics.compareExchange(sta, 0, v, v), name);
+
+ // Store
+ assertEquals(+v, Atomics.store(sta, 0, v), name);
+ assertEquals(v|0, sta[0], name);
+
+ // Add
+ sta[0] = 120;
+ assertEquals(120, Atomics.add(sta, 0, v), name);
+ assertEquals(120 + (v|0), sta[0], name);
+
+ // Sub
+ sta[0] = 70;
+ assertEquals(70, Atomics.sub(sta, 0, v), name);
+ assertEquals(70 - (v|0), sta[0]);
+
+ // And
+ sta[0] = 0x20;
+ assertEquals(0x20, Atomics.and(sta, 0, v), name);
+ assertEquals(0x20 & (v|0), sta[0]);
+
+ // Or
+ sta[0] = 0x3d;
+ assertEquals(0x3d, Atomics.or(sta, 0, v), name);
+ assertEquals(0x3d | (v|0), sta[0]);
+
+ // Xor
+ sta[0] = 0x25;
+ assertEquals(0x25, Atomics.xor(sta, 0, v), name);
+ assertEquals(0x25 ^ (v|0), sta[0]);
+
+ // Exchange
+ sta[0] = 0x09;
+ assertEquals(0x09, Atomics.exchange(sta, 0, v), name);
+ assertEquals(v|0, sta[0]);
+ });
+ });
+})();
+
(function TestWrapping() {
IntegerTypedArrayConstructors.forEach(function(t) {
var sab = new SharedArrayBuffer(10 * t.constr.BYTES_PER_ELEMENT);
« no previous file with comments | « src/harmony-atomics.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698