Index: test/mjsunit/harmony/atomics.js |
diff --git a/test/mjsunit/harmony/atomics.js b/test/mjsunit/harmony/atomics.js |
index ff403b8bd1d47cc0b53d994220abc90025ec52f7..839f9015bc5b735fc255a1c6589dd40f1a4068fa 100644 |
--- a/test/mjsunit/harmony/atomics.js |
+++ b/test/mjsunit/harmony/atomics.js |
@@ -161,6 +161,12 @@ function testAtomicOp(op, ia, index, expectedIndex, name) { |
assertEquals(50, Atomics.compareExchange(sta, i, 0, 100), name); |
assertEquals(50, sta[i], name); |
} |
+ |
+ // Non-numbers should be coerced to numbers. |
+ [false, true, undefined].forEach(function(v) { |
Jarin
2015/07/13 05:05:55
Maybe you should also try an object with a toStrin
binji
2015/07/13 19:29:11
Done.
|
+ sta[0] = 50; |
+ assertEquals(50, Atomics.compareExchange(sta, 0, v, v), name); |
+ }); |
}); |
// * Exact float values should be OK |
@@ -212,6 +218,11 @@ function testAtomicOp(op, ia, index, expectedIndex, name) { |
assertEquals(100, Atomics.store(sta, i, 100), name); |
assertEquals(100, sta[i], name); |
} |
+ |
+ // Non-numbers should be coerced to numbers. |
+ [false, true, undefined].forEach(function(v) { |
+ assertEquals(+v, Atomics.store(sta, 0, v), name); |
+ }); |
}); |
[1.5, 4.25, -1e8, -Infinity, Infinity, NaN].forEach(function(v) { |
@@ -241,6 +252,13 @@ function testAtomicOp(op, ia, index, expectedIndex, name) { |
assertEquals(50, Atomics.add(sta, i, 70), name); |
assertEquals(120, sta[i], name); |
} |
+ |
+ // Non-numbers should be coerced to numbers. |
+ [false, true, undefined].forEach(function(v) { |
+ sta[0] = 120; |
+ assertEquals(120, Atomics.add(sta, 0, v), name); |
+ assertEquals(120 + (v|0), sta[0], name); |
+ }); |
}); |
})(); |
@@ -257,6 +275,13 @@ function testAtomicOp(op, ia, index, expectedIndex, name) { |
assertEquals(70, Atomics.sub(sta, i, 70), name); |
assertEquals(0, sta[i], name); |
} |
+ |
+ // Non-numbers should be coerced to numbers. |
+ [false, true, undefined].forEach(function(v) { |
+ sta[0] = 70; |
+ assertEquals(70, Atomics.sub(sta, 0, v), name); |
+ assertEquals(70 - (v|0), sta[0]); |
+ }); |
}); |
})(); |
@@ -273,6 +298,13 @@ function testAtomicOp(op, ia, index, expectedIndex, name) { |
assertEquals(0x30, Atomics.and(sta, i, 0x20), name); |
assertEquals(0x20, sta[i], name); |
} |
+ |
+ // Non-numbers should be coerced to numbers. |
+ [false, true, undefined].forEach(function(v) { |
+ sta[0] = 0x20; |
+ assertEquals(0x20, Atomics.and(sta, 0, v), name); |
+ assertEquals(0x20 & (v|0), sta[0]); |
+ }); |
}); |
})(); |
@@ -289,6 +321,13 @@ function testAtomicOp(op, ia, index, expectedIndex, name) { |
assertEquals(0x3c, Atomics.or(sta, i, 0x09), name); |
assertEquals(0x3d, sta[i], name); |
} |
+ |
+ // Non-numbers should be coerced to numbers. |
+ [false, true, undefined].forEach(function(v) { |
+ sta[0] = 0x3d; |
+ assertEquals(0x3d, Atomics.or(sta, 0, v), name); |
+ assertEquals(0x3d | (v|0), sta[0]); |
+ }); |
}); |
})(); |
@@ -305,6 +344,13 @@ function testAtomicOp(op, ia, index, expectedIndex, name) { |
assertEquals(0x2c, Atomics.xor(sta, i, 0x09), name); |
assertEquals(0x25, sta[i], name); |
} |
+ |
+ // Non-numbers should be coerced to numbers. |
+ [false, true, undefined].forEach(function(v) { |
+ sta[0] = 0x25; |
+ assertEquals(0x25, Atomics.xor(sta, 0, v), name); |
+ assertEquals(0x25 ^ (v|0), sta[0]); |
+ }); |
}); |
})(); |
@@ -321,6 +367,13 @@ function testAtomicOp(op, ia, index, expectedIndex, name) { |
assertEquals(0x1c, Atomics.exchange(sta, i, 0x09), name); |
assertEquals(0x09, sta[i], name); |
} |
+ |
+ // Non-numbers should be coerced to numbers. |
+ [false, true, undefined].forEach(function(v) { |
+ sta[0] = 0x09; |
+ assertEquals(0x09, Atomics.exchange(sta, 0, v), name); |
+ assertEquals(v|0, sta[0]); |
+ }); |
}); |
})(); |