Index: test/mjsunit/harmony/atomics.js |
diff --git a/test/mjsunit/harmony/atomics.js b/test/mjsunit/harmony/atomics.js |
index 8973921ad57900f1b19dfaf973e28615080be8ed..bf27eb46d54f3f3420e3a75f8eac3a81aebdb7ed 100644 |
--- a/test/mjsunit/harmony/atomics.js |
+++ b/test/mjsunit/harmony/atomics.js |
@@ -16,19 +16,26 @@ |
return value; |
} |
+function toRangeClamped(value) { |
+ if (value < this.min) return this.min; |
+ if (value > this.max) return this.max; |
+ return value; |
+} |
+ |
function makeConstructorObject(constr, min, max, toRange) { |
var o = {constr: constr, min: min, max: max}; |
- o.toRange = toRangeWrapped.bind(o); |
+ o.toRange = toRange.bind(o); |
return o; |
} |
var IntegerTypedArrayConstructors = [ |
- makeConstructorObject(Int8Array, -128, 127), |
- makeConstructorObject(Int16Array, -32768, 32767), |
- makeConstructorObject(Int32Array, -0x80000000, 0x7fffffff), |
- makeConstructorObject(Uint8Array, 0, 255), |
- makeConstructorObject(Uint16Array, 0, 65535), |
- makeConstructorObject(Uint32Array, 0, 0xffffffff), |
+ makeConstructorObject(Int8Array, -128, 127, toRangeWrapped), |
+ makeConstructorObject(Int16Array, -32768, 32767, toRangeWrapped), |
+ makeConstructorObject(Int32Array, -0x80000000, 0x7fffffff, toRangeWrapped), |
+ makeConstructorObject(Uint8Array, 0, 255, toRangeWrapped), |
+ makeConstructorObject(Uint8ClampedArray, 0, 255, toRangeClamped), |
+ makeConstructorObject(Uint16Array, 0, 65535, toRangeWrapped), |
+ makeConstructorObject(Uint32Array, 0, 0xffffffff, toRangeWrapped), |
]; |
(function TestBadArray() { |
@@ -37,13 +44,9 @@ |
var sab = new SharedArrayBuffer(128); |
var sf32a = new Float32Array(sab); |
var sf64a = new Float64Array(sab); |
- var u8ca = new Uint8ClampedArray(sab); |
// Atomic ops required integer shared typed arrays |
- var badArrayTypes = [ |
- undefined, 1, 'hi', 3.4, ab, u32a, sab, sf32a, sf64a, u8ca |
- ]; |
- badArrayTypes.forEach(function(o) { |
+ [undefined, 1, 'hi', 3.4, ab, u32a, sab, sf32a, sf64a].forEach(function(o) { |
assertThrows(function() { Atomics.compareExchange(o, 0, 0, 0); }, |
TypeError); |
assertThrows(function() { Atomics.load(o, 0); }, TypeError); |
@@ -126,16 +129,15 @@ |
var testOp = function(op, ia, index, expectedIndex, name) { |
for (var i = 0; i < ia.length; ++i) |
- ia[i] = i * 2; |
+ ia[i] = 22; |
ia[expectedIndex] = 0; |
- var result = op(ia, index, 0, 0); |
- assertEquals(0, result, name); |
+ assertEquals(0, op(ia, index, 0, 0), name); |
assertEquals(0, ia[expectedIndex], name); |
for (var i = 0; i < ia.length; ++i) { |
if (i == expectedIndex) continue; |
- assertEquals(i * 2, ia[i], name); |
+ assertEquals(22, ia[i], name); |
} |
}; |
@@ -220,24 +222,6 @@ |
} |
}) |
}); |
- |
- // Test Smi range |
- (function () { |
- var sab = new SharedArrayBuffer(4); |
- var i32 = new Int32Array(sab); |
- var u32 = new Uint32Array(sab); |
- |
- function testLoad(signedValue, unsignedValue) { |
- u32[0] = unsignedValue; |
- assertEquals(unsignedValue, Atomics.load(u32, 0)); |
- assertEquals(signedValue, Atomics.load(i32, 0)); |
- } |
- |
- testLoad(0x3fffffff, 0x3fffffff); // 2**30-1 (always smi) |
- testLoad(0x40000000, 0x40000000); // 2**30 (smi if signed and 32-bits) |
- testLoad(0x80000000, -0x80000000); // 2**31 (smi if signed and 32-bits) |
- testLoad(0xffffffff, -1); // 2**31 (smi if signed) |
- }); |
})(); |
(function TestStore() { |