| Index: test/mjsunit/shared-typed-arrays.js
|
| diff --git a/test/mjsunit/harmony/typedarrays.js b/test/mjsunit/shared-typed-arrays.js
|
| similarity index 62%
|
| copy from test/mjsunit/harmony/typedarrays.js
|
| copy to test/mjsunit/shared-typed-arrays.js
|
| index 70bd17e3382db1cdb115d5aae6e48cf9141bc82a..36485a85a1e158b3cdbab4a802d817f36183c20e 100644
|
| --- a/test/mjsunit/harmony/typedarrays.js
|
| +++ b/test/mjsunit/shared-typed-arrays.js
|
| @@ -1,4 +1,4 @@
|
| -// Copyright 2013 the V8 project authors. All rights reserved.
|
| +// Copyright 2015 the V8 project authors. All rights reserved.
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| // met:
|
| @@ -25,13 +25,13 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -// Flags: --harmony-tostring
|
| +// Flags: --harmony_shared_typed_arrays
|
|
|
| -// ArrayBuffer
|
| +// SharedArrayBuffer
|
|
|
| function TestByteLength(param, expectedByteLength) {
|
| - var ab = new ArrayBuffer(param);
|
| - assertSame(expectedByteLength, ab.byteLength);
|
| + var sab = new SharedArrayBuffer(param);
|
| + assertSame(expectedByteLength, sab.byteLength);
|
| }
|
|
|
| function TestArrayBufferCreation() {
|
| @@ -43,94 +43,58 @@ function TestArrayBufferCreation() {
|
|
|
| TestByteLength(0, 0);
|
|
|
| - assertThrows(function() { new ArrayBuffer(-10); }, RangeError);
|
| - assertThrows(function() { new ArrayBuffer(-2.567); }, RangeError);
|
| + assertThrows(function() { new SharedArrayBuffer(-10); }, RangeError);
|
| + assertThrows(function() { new SharedArrayBuffer(-2.567); }, RangeError);
|
|
|
| /* TODO[dslomov]: Reenable the test
|
| assertThrows(function() {
|
| - var ab1 = new ArrayBuffer(0xFFFFFFFFFFFF)
|
| + var ab1 = new SharedArrayBuffer(0xFFFFFFFFFFFF)
|
| }, RangeError);
|
| */
|
|
|
| - var ab = new ArrayBuffer();
|
| - assertSame(0, ab.byteLength);
|
| - assertEquals("[object ArrayBuffer]",
|
| - Object.prototype.toString.call(ab));
|
| + var sab = new SharedArrayBuffer();
|
| + assertSame(0, sab.byteLength);
|
| + assertEquals("[object SharedArrayBuffer]",
|
| + Object.prototype.toString.call(sab));
|
| }
|
|
|
| TestArrayBufferCreation();
|
|
|
| function TestByteLengthNotWritable() {
|
| - var ab = new ArrayBuffer(1024);
|
| - assertSame(1024, ab.byteLength);
|
| + var sab = new SharedArrayBuffer(1024);
|
| + assertSame(1024, sab.byteLength);
|
|
|
| - assertThrows(function() { "use strict"; ab.byteLength = 42; }, TypeError);
|
| + assertThrows(function() { "use strict"; sab.byteLength = 42; }, TypeError);
|
| }
|
|
|
| TestByteLengthNotWritable();
|
|
|
| -function TestSlice(expectedResultLen, initialLen, start, end) {
|
| - var ab = new ArrayBuffer(initialLen);
|
| - var a1 = new Uint8Array(ab);
|
| - for (var i = 0; i < a1.length; i++) {
|
| - a1[i] = 0xCA;
|
| - }
|
| - var slice = ab.slice(start, end);
|
| - assertSame(expectedResultLen, slice.byteLength);
|
| - var a2 = new Uint8Array(slice);
|
| - for (var i = 0; i < a2.length; i++) {
|
| - assertSame(0xCA, a2[i]);
|
| - }
|
| +function TestArrayBufferNoSlice() {
|
| + var sab = new SharedArrayBuffer(10);
|
| + assertEquals(undefined, sab.slice);
|
| }
|
|
|
| -function TestArrayBufferSlice() {
|
| - var ab = new ArrayBuffer(1024);
|
| - var ab1 = ab.slice(512, 1024);
|
| - assertSame(512, ab1.byteLength);
|
| -
|
| - TestSlice(512, 1024, 512, 1024);
|
| - TestSlice(512, 1024, 512);
|
| -
|
| - TestSlice(0, 0, 1, 20);
|
| - TestSlice(100, 100, 0, 100);
|
| - TestSlice(100, 100, 0, 1000);
|
| -
|
| - TestSlice(0, 100, 5, 1);
|
| -
|
| - TestSlice(1, 100, -11, -10);
|
| - TestSlice(9, 100, -10, 99);
|
| - TestSlice(0, 100, -10, 80);
|
| - TestSlice(10, 100, 80, -10);
|
| +TestArrayBufferNoSlice();
|
|
|
| - TestSlice(10, 100, 90, "100");
|
| - TestSlice(10, 100, "90", "100");
|
| +// Shared Typed arrays
|
|
|
| - TestSlice(0, 100, 90, "abc");
|
| - TestSlice(10, 100, "abc", 10);
|
| -
|
| - TestSlice(10, 100, 0.96, 10.96);
|
| - TestSlice(10, 100, 0.96, 10.01);
|
| - TestSlice(10, 100, 0.01, 10.01);
|
| - TestSlice(10, 100, 0.01, 10.96);
|
| -
|
| - TestSlice(10, 100, 90);
|
| - TestSlice(10, 100, -10);
|
| -}
|
| -
|
| -TestArrayBufferSlice();
|
| +function TestTypedArray(constr, nonsharedConstr, elementSize, typicalElement) {
|
| + assertSame(elementSize, constr.BYTES_PER_ELEMENT);
|
|
|
| -// Typed arrays
|
| + var sab = new SharedArrayBuffer(256*elementSize);
|
|
|
| -function TestTypedArray(constr, elementSize, typicalElement) {
|
| - assertSame(elementSize, constr.BYTES_PER_ELEMENT);
|
| + // Constructing TypedArray from SharedArrayBuffer should throw
|
| + assertThrows(function() { new nonsharedConstr(sab); }, TypeError);
|
|
|
| + // Constructing SharedTypedArray from ArrayBuffer should throw
|
| var ab = new ArrayBuffer(256*elementSize);
|
| + assertThrows(function() { new constr(ab); }, TypeError);
|
|
|
| var a0 = new constr(30);
|
| assertEquals("[object " + constr.name + "]",
|
| Object.prototype.toString.call(a0));
|
|
|
| - assertTrue(ArrayBuffer.isView(a0));
|
| + assertTrue(SharedArrayBuffer.isView(a0));
|
| assertSame(elementSize, a0.BYTES_PER_ELEMENT);
|
| assertSame(30, a0.length);
|
| assertSame(30*elementSize, a0.byteLength);
|
| @@ -144,36 +108,36 @@ function TestTypedArray(constr, elementSize, typicalElement) {
|
| assertSame(0, aLen0.byteOffset);
|
| assertSame(0, aLen0.buffer.byteLength);
|
|
|
| - var aOverBufferLen0 = new constr(ab, 128*elementSize, 0);
|
| - assertSame(ab, aOverBufferLen0.buffer);
|
| + var aOverBufferLen0 = new constr(sab, 128*elementSize, 0);
|
| + assertSame(sab, aOverBufferLen0.buffer);
|
| assertSame(elementSize, aOverBufferLen0.BYTES_PER_ELEMENT);
|
| assertSame(0, aOverBufferLen0.length);
|
| assertSame(0, aOverBufferLen0.byteLength);
|
| assertSame(128*elementSize, aOverBufferLen0.byteOffset);
|
|
|
| - var a1 = new constr(ab, 128*elementSize, 128);
|
| - assertSame(ab, a1.buffer);
|
| + var a1 = new constr(sab, 128*elementSize, 128);
|
| + assertSame(sab, a1.buffer);
|
| assertSame(elementSize, a1.BYTES_PER_ELEMENT);
|
| assertSame(128, a1.length);
|
| assertSame(128*elementSize, a1.byteLength);
|
| assertSame(128*elementSize, a1.byteOffset);
|
|
|
|
|
| - var a2 = new constr(ab, 64*elementSize, 128);
|
| - assertSame(ab, a2.buffer);
|
| + var a2 = new constr(sab, 64*elementSize, 128);
|
| + assertSame(sab, a2.buffer);
|
| assertSame(elementSize, a2.BYTES_PER_ELEMENT);
|
| assertSame(128, a2.length);
|
| assertSame(128*elementSize, a2.byteLength);
|
| assertSame(64*elementSize, a2.byteOffset);
|
|
|
| - var a3 = new constr(ab, 192*elementSize);
|
| - assertSame(ab, a3.buffer);
|
| + var a3 = new constr(sab, 192*elementSize);
|
| + assertSame(sab, a3.buffer);
|
| assertSame(64, a3.length);
|
| assertSame(64*elementSize, a3.byteLength);
|
| assertSame(192*elementSize, a3.byteOffset);
|
|
|
| - var a4 = new constr(ab);
|
| - assertSame(ab, a4.buffer);
|
| + var a4 = new constr(sab);
|
| + assertSame(sab, a4.buffer);
|
| assertSame(256, a4.length);
|
| assertSame(256*elementSize, a4.byteLength);
|
| assertSame(0, a4.byteOffset);
|
| @@ -208,21 +172,21 @@ function TestTypedArray(constr, elementSize, typicalElement) {
|
| assertSame(typicalElement, a4[i]);
|
| }
|
|
|
| - var aAtTheEnd = new constr(ab, 256*elementSize);
|
| + var aAtTheEnd = new constr(sab, 256*elementSize);
|
| assertSame(elementSize, aAtTheEnd.BYTES_PER_ELEMENT);
|
| assertSame(0, aAtTheEnd.length);
|
| assertSame(0, aAtTheEnd.byteLength);
|
| assertSame(256*elementSize, aAtTheEnd.byteOffset);
|
|
|
| - assertThrows(function () { new constr(ab, 257*elementSize); }, RangeError);
|
| + assertThrows(function () { new constr(sab, 257*elementSize); }, RangeError);
|
| assertThrows(
|
| - function () { new constr(ab, 128*elementSize, 192); },
|
| + function () { new constr(sab, 128*elementSize, 192); },
|
| RangeError);
|
|
|
| if (elementSize !== 1) {
|
| - assertThrows(function() { new constr(ab, 128*elementSize - 1, 10); },
|
| + assertThrows(function() { new constr(sab, 128*elementSize - 1, 10); },
|
| RangeError);
|
| - var unalignedArrayBuffer = new ArrayBuffer(10*elementSize + 1);
|
| + var unalignedArrayBuffer = new SharedArrayBuffer(10*elementSize + 1);
|
| var goodArray = new constr(unalignedArrayBuffer, 0, 10);
|
| assertSame(10, goodArray.length);
|
| assertSame(10*elementSize, goodArray.byteLength);
|
| @@ -238,21 +202,12 @@ function TestTypedArray(constr, elementSize, typicalElement) {
|
| assertSame(0, aFromString.byteOffset);
|
| assertSame(30*elementSize, aFromString.buffer.byteLength);
|
|
|
| + // Difference from ArrayBuffer -- SharedArrayBuffer cannot be initialized
|
| + // from Array-like object.
|
| var jsArray = [];
|
| - for (i = 0; i < 30; i++) {
|
| - jsArray.push(typicalElement);
|
| - }
|
| - var aFromArray = new constr(jsArray);
|
| - assertSame(elementSize, aFromArray.BYTES_PER_ELEMENT);
|
| - assertSame(30, aFromArray.length);
|
| - assertSame(30*elementSize, aFromArray.byteLength);
|
| - assertSame(0, aFromArray.byteOffset);
|
| - assertSame(30*elementSize, aFromArray.buffer.byteLength);
|
| - for (i = 0; i < 30; i++) {
|
| - assertSame(typicalElement, aFromArray[i]);
|
| - }
|
| + assertThrows(function() { new constr(jsArray); }, TypeError);
|
|
|
| - var abLen0 = new ArrayBuffer(0);
|
| + var abLen0 = new SharedArrayBuffer(0);
|
| var aOverAbLen0 = new constr(abLen0);
|
| assertSame(abLen0, aOverAbLen0.buffer);
|
| assertSame(elementSize, aOverAbLen0.BYTES_PER_ELEMENT);
|
| @@ -266,7 +221,7 @@ function TestTypedArray(constr, elementSize, typicalElement) {
|
| assertSame(0, aNoParam.byteLength);
|
| assertSame(0, aNoParam.byteOffset);
|
|
|
| - var a = new constr(ab, 64*elementSize, 128);
|
| + var a = new constr(sab, 64*elementSize, 128);
|
| assertEquals("[object " + constr.name + "]",
|
| Object.prototype.toString.call(a));
|
| var desc = Object.getOwnPropertyDescriptor(
|
| @@ -278,18 +233,19 @@ function TestTypedArray(constr, elementSize, typicalElement) {
|
| assertEquals("function", typeof desc.get);
|
| }
|
|
|
| -TestTypedArray(Uint8Array, 1, 0xFF);
|
| -TestTypedArray(Int8Array, 1, -0x7F);
|
| -TestTypedArray(Uint16Array, 2, 0xFFFF);
|
| -TestTypedArray(Int16Array, 2, -0x7FFF);
|
| -TestTypedArray(Uint32Array, 4, 0xFFFFFFFF);
|
| -TestTypedArray(Int32Array, 4, -0x7FFFFFFF);
|
| -TestTypedArray(Float32Array, 4, 0.5);
|
| -TestTypedArray(Float64Array, 8, 0.5);
|
| -TestTypedArray(Uint8ClampedArray, 1, 0xFF);
|
| -
|
| -function SubarrayTestCase(constructor, item, expectedResultLen, expectedStartIndex,
|
| - initialLen, start, end) {
|
| +TestTypedArray(SharedUint8Array, Uint8Array, 1, 0xFF);
|
| +TestTypedArray(SharedInt8Array, Int8Array, 1, -0x7F);
|
| +TestTypedArray(SharedUint16Array, Uint16Array, 2, 0xFFFF);
|
| +TestTypedArray(SharedInt16Array, Int16Array, 2, -0x7FFF);
|
| +TestTypedArray(SharedUint32Array, Uint32Array, 4, 0xFFFFFFFF);
|
| +TestTypedArray(SharedInt32Array, Int32Array, 4, -0x7FFFFFFF);
|
| +TestTypedArray(SharedFloat32Array, Float32Array, 4, 0.5);
|
| +TestTypedArray(SharedFloat64Array, Float64Array, 8, 0.5);
|
| +TestTypedArray(SharedUint8ClampedArray, Uint8ClampedArray, 1, 0xFF);
|
| +
|
| +
|
| +function SubarrayTestCase(constructor, item, expectedResultLen,
|
| + expectedStartIndex, initialLen, start, end) {
|
| var a = new constructor(initialLen);
|
| var s = a.subarray(start, end);
|
| assertSame(constructor, s.constructor);
|
| @@ -335,15 +291,15 @@ function TestSubArray(constructor, item) {
|
| assertThrows(function() { method.call(o, 0, 100); }, TypeError);
|
| }
|
|
|
| -TestSubArray(Uint8Array, 0xFF);
|
| -TestSubArray(Int8Array, -0x7F);
|
| -TestSubArray(Uint16Array, 0xFFFF);
|
| -TestSubArray(Int16Array, -0x7FFF);
|
| -TestSubArray(Uint32Array, 0xFFFFFFFF);
|
| -TestSubArray(Int32Array, -0x7FFFFFFF);
|
| -TestSubArray(Float32Array, 0.5);
|
| -TestSubArray(Float64Array, 0.5);
|
| -TestSubArray(Uint8ClampedArray, 0xFF);
|
| +TestSubArray(SharedUint8Array, 0xFF);
|
| +TestSubArray(SharedInt8Array, -0x7F);
|
| +TestSubArray(SharedUint16Array, 0xFFFF);
|
| +TestSubArray(SharedInt16Array, -0x7FFF);
|
| +TestSubArray(SharedUint32Array, 0xFFFFFFFF);
|
| +TestSubArray(SharedInt32Array, -0x7FFFFFFF);
|
| +TestSubArray(SharedFloat32Array, 0.5);
|
| +TestSubArray(SharedFloat64Array, 0.5);
|
| +TestSubArray(SharedUint8ClampedArray, 0xFF);
|
|
|
| function TestTypedArrayOutOfRange(constructor, value, result) {
|
| var a = new constructor(1);
|
| @@ -351,32 +307,33 @@ function TestTypedArrayOutOfRange(constructor, value, result) {
|
| assertSame(result, a[0]);
|
| }
|
|
|
| -TestTypedArrayOutOfRange(Uint8Array, 0x1FA, 0xFA);
|
| -TestTypedArrayOutOfRange(Uint8Array, -1, 0xFF);
|
| +TestTypedArrayOutOfRange(SharedUint8Array, 0x1FA, 0xFA);
|
| +TestTypedArrayOutOfRange(SharedUint8Array, -1, 0xFF);
|
|
|
| -TestTypedArrayOutOfRange(Int8Array, 0x1FA, 0x7A - 0x80);
|
| +TestTypedArrayOutOfRange(SharedInt8Array, 0x1FA, 0x7A - 0x80);
|
|
|
| -TestTypedArrayOutOfRange(Uint16Array, 0x1FFFA, 0xFFFA);
|
| -TestTypedArrayOutOfRange(Uint16Array, -1, 0xFFFF);
|
| -TestTypedArrayOutOfRange(Int16Array, 0x1FFFA, 0x7FFA - 0x8000);
|
| +TestTypedArrayOutOfRange(SharedUint16Array, 0x1FFFA, 0xFFFA);
|
| +TestTypedArrayOutOfRange(SharedUint16Array, -1, 0xFFFF);
|
| +TestTypedArrayOutOfRange(SharedInt16Array, 0x1FFFA, 0x7FFA - 0x8000);
|
|
|
| -TestTypedArrayOutOfRange(Uint32Array, 0x1FFFFFFFA, 0xFFFFFFFA);
|
| -TestTypedArrayOutOfRange(Uint32Array, -1, 0xFFFFFFFF);
|
| -TestTypedArrayOutOfRange(Int32Array, 0x1FFFFFFFA, 0x7FFFFFFA - 0x80000000);
|
| +TestTypedArrayOutOfRange(SharedUint32Array, 0x1FFFFFFFA, 0xFFFFFFFA);
|
| +TestTypedArrayOutOfRange(SharedUint32Array, -1, 0xFFFFFFFF);
|
| +TestTypedArrayOutOfRange(SharedInt32Array, 0x1FFFFFFFA,
|
| + 0x7FFFFFFA - 0x80000000);
|
|
|
| -TestTypedArrayOutOfRange(Uint8ClampedArray, 0x1FA, 0xFF);
|
| -TestTypedArrayOutOfRange(Uint8ClampedArray, -1, 0);
|
| +TestTypedArrayOutOfRange(SharedUint8ClampedArray, 0x1FA, 0xFF);
|
| +TestTypedArrayOutOfRange(SharedUint8ClampedArray, -1, 0);
|
|
|
| var typedArrayConstructors = [
|
| - Uint8Array,
|
| - Int8Array,
|
| - Uint16Array,
|
| - Int16Array,
|
| - Uint32Array,
|
| - Int32Array,
|
| - Uint8ClampedArray,
|
| - Float32Array,
|
| - Float64Array];
|
| + SharedUint8Array,
|
| + SharedInt8Array,
|
| + SharedUint16Array,
|
| + SharedInt16Array,
|
| + SharedUint32Array,
|
| + SharedInt32Array,
|
| + SharedUint8ClampedArray,
|
| + SharedFloat32Array,
|
| + SharedFloat64Array];
|
|
|
| function TestPropertyTypeChecks(constructor) {
|
| function CheckProperty(name) {
|
| @@ -404,7 +361,6 @@ for(i = 0; i < typedArrayConstructors.length; i++) {
|
| TestPropertyTypeChecks(typedArrayConstructors[i]);
|
| }
|
|
|
| -
|
| function TestTypedArraySet() {
|
| // Test array.set in different combinations.
|
|
|
| @@ -414,34 +370,44 @@ function TestTypedArraySet() {
|
| }
|
| }
|
|
|
| - var a11 = new Int16Array([1, 2, 3, 4, 0, -1])
|
| - var a12 = new Uint16Array(15)
|
| + // SharedTypedArrays don't allow initialization via array-like
|
| + function initializeFromArray(constructor, array) {
|
| + var buffer = new constructor(array.length);
|
| + for (var i = 0; i < array.length; ++i) {
|
| + buffer[i] = array[i];
|
| + }
|
| + return buffer;
|
| + }
|
| +
|
| + var a11 = initializeFromArray(SharedInt16Array, [1, 2, 3, 4, 0, -1])
|
| + var a12 = new SharedUint16Array(15)
|
| a12.set(a11, 3)
|
| assertArrayPrefix([0, 0, 0, 1, 2, 3, 4, 0, 0xffff, 0, 0], a12)
|
| assertThrows(function(){ a11.set(a12) })
|
|
|
| var a21 = [1, undefined, 10, NaN, 0, -1, {valueOf: function() {return 3}}]
|
| - var a22 = new Int32Array(12)
|
| + var a22 = new SharedInt32Array(12)
|
| a22.set(a21, 2)
|
| assertArrayPrefix([0, 0, 1, 0, 10, 0, 0, -1, 3, 0], a22)
|
|
|
| - var a31 = new Float32Array([2, 4, 6, 8, 11, NaN, 1/0, -3])
|
| + var a31 = initializeFromArray(SharedFloat32Array,
|
| + [2, 4, 6, 8, 11, NaN, 1/0, -3])
|
| var a32 = a31.subarray(2, 6)
|
| a31.set(a32, 4)
|
| assertArrayPrefix([2, 4, 6, 8, 6, 8, 11, NaN], a31)
|
| assertArrayPrefix([6, 8, 6, 8], a32)
|
|
|
| - var a4 = new Uint8ClampedArray([3,2,5,6])
|
| + var a4 = initializeFromArray(SharedUint8ClampedArray, [3,2,5,6])
|
| a4.set(a4)
|
| assertArrayPrefix([3, 2, 5, 6], a4)
|
|
|
| // Cases with overlapping backing store but different element sizes.
|
| - var b = new ArrayBuffer(4)
|
| - var a5 = new Int16Array(b)
|
| - var a50 = new Int8Array(b)
|
| - var a51 = new Int8Array(b, 0, 2)
|
| - var a52 = new Int8Array(b, 1, 2)
|
| - var a53 = new Int8Array(b, 2, 2)
|
| + var b = new SharedArrayBuffer(4)
|
| + var a5 = new SharedInt16Array(b)
|
| + var a50 = new SharedInt8Array(b)
|
| + var a51 = new SharedInt8Array(b, 0, 2)
|
| + var a52 = new SharedInt8Array(b, 1, 2)
|
| + var a53 = new SharedInt8Array(b, 2, 2)
|
|
|
| a5.set([0x5050, 0x0a0a])
|
| assertArrayPrefix([0x50, 0x50, 0x0a, 0x0a], a50)
|
| @@ -474,15 +440,15 @@ function TestTypedArraySet() {
|
| assertArrayPrefix([0x000a, 0x000b], a5)
|
|
|
| // Mixed types of same size.
|
| - var a61 = new Float32Array([1.2, 12.3])
|
| - var a62 = new Int32Array(2)
|
| + var a61 = initializeFromArray(SharedFloat32Array, [1.2, 12.3])
|
| + var a62 = new SharedInt32Array(2)
|
| a62.set(a61)
|
| assertArrayPrefix([1, 12], a62)
|
| a61.set(a62)
|
| assertArrayPrefix([1, 12], a61)
|
|
|
| // Invalid source
|
| - var a = new Uint16Array(50);
|
| + var a = new SharedUint16Array(50);
|
| var expected = [];
|
| for (i = 0; i < 50; i++) {
|
| a[i] = i;
|
| @@ -495,12 +461,18 @@ function TestTypedArraySet() {
|
|
|
| assertThrows(function() { a.set(0); }, TypeError);
|
| assertThrows(function() { a.set(0, 1); }, TypeError);
|
| +
|
| + // Setting SharedTypedArrays from TypedArrays or vice versa.
|
| + var a71 = new SharedInt16Array(15);
|
| + var a72 = new Int16Array(15);
|
| + assertThrows(function(){ a71.set(a72) }, TypeError);
|
| + assertThrows(function(){ a72.set(a71) }, TypeError);
|
| }
|
|
|
| TestTypedArraySet();
|
|
|
| function TestTypedArraysWithIllegalIndices() {
|
| - var a = new Int32Array(100);
|
| + var a = new SharedInt32Array(100);
|
|
|
| a[-10] = 10;
|
| assertEquals(undefined, a[-10]);
|
| @@ -549,7 +521,7 @@ TestTypedArraysWithIllegalIndices();
|
|
|
| function TestTypedArraysWithIllegalIndicesStrict() {
|
| 'use strict';
|
| - var a = new Int32Array(100);
|
| + var a = new SharedInt32Array(100);
|
|
|
| a[-10] = 10;
|
| assertEquals(undefined, a[-10]);
|
| @@ -596,88 +568,6 @@ function TestTypedArraysWithIllegalIndicesStrict() {
|
|
|
| TestTypedArraysWithIllegalIndicesStrict();
|
|
|
| -// DataView
|
| -function TestDataViewConstructor() {
|
| - var ab = new ArrayBuffer(256);
|
| -
|
| - var d1 = new DataView(ab, 1, 255);
|
| - assertTrue(ArrayBuffer.isView(d1));
|
| - assertSame(ab, d1.buffer);
|
| - assertSame(1, d1.byteOffset);
|
| - assertSame(255, d1.byteLength);
|
| -
|
| - var d2 = new DataView(ab, 2);
|
| - assertSame(ab, d2.buffer);
|
| - assertSame(2, d2.byteOffset);
|
| - assertSame(254, d2.byteLength);
|
| -
|
| - var d3 = new DataView(ab);
|
| - assertSame(ab, d3.buffer);
|
| - assertSame(0, d3.byteOffset);
|
| - assertSame(256, d3.byteLength);
|
| -
|
| - var d3a = new DataView(ab, 1, 0);
|
| - assertSame(ab, d3a.buffer);
|
| - assertSame(1, d3a.byteOffset);
|
| - assertSame(0, d3a.byteLength);
|
| -
|
| - var d3b = new DataView(ab, 256, 0);
|
| - assertSame(ab, d3b.buffer);
|
| - assertSame(256, d3b.byteOffset);
|
| - assertSame(0, d3b.byteLength);
|
| -
|
| - var d3c = new DataView(ab, 256);
|
| - assertSame(ab, d3c.buffer);
|
| - assertSame(256, d3c.byteOffset);
|
| - assertSame(0, d3c.byteLength);
|
| -
|
| - var d4 = new DataView(ab, 1, 3.1415926);
|
| - assertSame(ab, d4.buffer);
|
| - assertSame(1, d4.byteOffset);
|
| - assertSame(3, d4.byteLength);
|
| -
|
| -
|
| - // error cases
|
| - assertThrows(function() { new DataView(ab, -1); }, RangeError);
|
| - assertThrows(function() { new DataView(ab, 1, -1); }, RangeError);
|
| - assertThrows(function() { new DataView(); }, TypeError);
|
| - assertThrows(function() { new DataView([]); }, TypeError);
|
| - assertThrows(function() { new DataView(ab, 257); }, RangeError);
|
| - assertThrows(function() { new DataView(ab, 1, 1024); }, RangeError);
|
| -}
|
| -
|
| -TestDataViewConstructor();
|
| -
|
| -function TestDataViewPropertyTypeChecks() {
|
| - var a = new DataView(new ArrayBuffer(10));
|
| - function CheckProperty(name) {
|
| - var d = Object.getOwnPropertyDescriptor(DataView.prototype, name);
|
| - var o = {}
|
| - assertThrows(function() {d.get.call(o);}, TypeError);
|
| - d.get.call(a); // shouldn't throw
|
| - }
|
| -
|
| - CheckProperty("buffer");
|
| - CheckProperty("byteOffset");
|
| - CheckProperty("byteLength");
|
| -}
|
| -
|
| -
|
| -TestDataViewPropertyTypeChecks();
|
| -
|
| -
|
| -function TestDataViewToStringTag() {
|
| - var a = new DataView(new ArrayBuffer(10));
|
| - assertEquals("[object DataView]", Object.prototype.toString.call(a));
|
| - var desc = Object.getOwnPropertyDescriptor(
|
| - DataView.prototype, Symbol.toStringTag);
|
| - assertTrue(desc.configurable);
|
| - assertFalse(desc.enumerable);
|
| - assertFalse(desc.writable);
|
| - assertEquals("DataView", desc.value);
|
| -}
|
| -
|
| -
|
| // General tests for properties
|
|
|
| // Test property attribute [[Enumerable]]
|
| @@ -692,11 +582,10 @@ function TestEnumerable(func, obj) {
|
| if (obj)
|
| assertArrayEquals([], props(obj));
|
| }
|
| -TestEnumerable(ArrayBuffer, new ArrayBuffer());
|
| +TestEnumerable(ArrayBuffer, new SharedArrayBuffer());
|
| for(i = 0; i < typedArrayConstructors.length; i++) {
|
| TestEnumerable(typedArrayConstructors[i]);
|
| }
|
| -TestEnumerable(DataView, new DataView(new ArrayBuffer()));
|
|
|
| // Test arbitrary properties on ArrayBuffer
|
| function TestArbitrary(m) {
|
| @@ -709,13 +598,14 @@ function TestArbitrary(m) {
|
| TestProperty(m, 'foo' + i, 'bar' + i);
|
| }
|
| }
|
| -TestArbitrary(new ArrayBuffer(256));
|
| +TestArbitrary(new SharedArrayBuffer(256));
|
| for(i = 0; i < typedArrayConstructors.length; i++) {
|
| TestArbitrary(new typedArrayConstructors[i](10));
|
| }
|
| -TestArbitrary(new DataView(new ArrayBuffer(256)));
|
| -
|
|
|
| // Test direct constructor call
|
| -assertThrows(function() { ArrayBuffer(); }, TypeError);
|
| -assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError);
|
| +assertThrows(function() { SharedArrayBuffer(); }, TypeError);
|
| +for(i = 0; i < typedArrayConstructors.length; i++) {
|
| + assertThrows(function(i) { typedArrayConstructors[i](); }.bind(this, i),
|
| + TypeError);
|
| +}
|
|
|