예제 #1
0
        public static void SharedArrayBuffer_NonZeroLength(Function objectPrototype)
        {
            SharedArrayBuffer d = new SharedArrayBuffer(50);

            Assert.Equal("[object SharedArrayBuffer]", objectPrototype.Call(d));
            Assert.Equal(50, d.ByteLength);
        }
예제 #2
0
        public static void SharedArrayBufferSliceAndDice3_SubsetFromTheBack(SharedArrayBuffer buffer)
        {
            Int32Array sliced = new Int32Array(buffer.Slice(-4));

            Assert.Equal(1, sliced.Length);
            Assert.Equal(13, sliced[0]);
        }
예제 #3
0
        public static void SharedArrayBufferSliceAndDiceAndUseThroughSpan()
        {
            // create a SharedArrayBuffer with a size in bytes
            SharedArrayBuffer buffer    = new SharedArrayBuffer(16);
            Int32Array        int32View = new Int32Array(buffer); // create view

            // produces Int32Array [0, 0, 0, 0]

            int32View[1] = 42;

            Assert.Equal(4, int32View.Length);
            Assert.Equal(42, int32View[1]);

            Int32Array sliced = new Int32Array(buffer.Slice(4, 12));
            // expected output: Int32Array [42, 0]

            Span <int> nativeArray = sliced;

            int sum = 0;

            for (int i = 0; i < nativeArray.Length; i++)
            {
                sum += nativeArray[i];
            }

            Assert.Equal(42, sum);
        }
예제 #4
0
        public static EcmaValue SharedArrayBuffer([This] EcmaValue thisValue, EcmaValue length)
        {
            SharedArrayBuffer buffer = thisValue.GetUnderlyingObject <SharedArrayBuffer>();

            buffer.Init(length.ToIndex());
            return(thisValue);
        }
예제 #5
0
        public static void SharedArrayBufferSliceAndDice3_Subset(SharedArrayBuffer buffer)
        {
            Int32Array sliced = new Int32Array(buffer.Slice(4, 12));

            Assert.Equal(2, sliced.Length);
            Assert.Equal(42, sliced[0]);
            Assert.Equal(12, sliced[1]);
        }
예제 #6
0
        public static EcmaValue Slice([This] EcmaValue thisValue, EcmaValue start, EcmaValue end)
        {
            SharedArrayBuffer buffer = thisValue.GetUnderlyingObject <SharedArrayBuffer>();
            long startPos            = ArrayHelper.GetBoundIndex(start, buffer.ByteLength, 0);
            long endPos = ArrayHelper.GetBoundIndex(end, buffer.ByteLength, buffer.ByteLength);

            return(buffer.Slice(startPos, endPos));
        }
예제 #7
0
        public static void SharedArrayBufferSliceAndDice3_SubsetFromTheBackWithEnd(SharedArrayBuffer buffer)
        {
            Int32Array sliced = new Int32Array(buffer.Slice(-12, -4));

            Assert.Equal(2, sliced.Length);
            Assert.Equal(42, sliced[0]);
            Assert.Equal(12, sliced[1]);
        }
예제 #8
0
        public static TheoryData <SharedArrayBuffer> GetTestData(int length)
        {
            // create a SharedArrayBuffer with a size in bytes
            SharedArrayBuffer buffer    = new SharedArrayBuffer(length);
            Int32Array        int32View = new Int32Array(buffer); // create view

            for (int i = 0; i < int32View.Length; i++)
            {
                int32View[i] = i + 10;
            }

            int32View[1] = 42;
            return(new TheoryData <SharedArrayBuffer> {
                buffer
            });
        }
예제 #9
0
        public static void SharedArrayBufferSliceAndDice()
        {
            // create a SharedArrayBuffer with a size in bytes
            SharedArrayBuffer buffer    = new SharedArrayBuffer(16);
            Int32Array        int32View = new Int32Array(buffer); // create view

            // produces Int32Array [0, 0, 0, 0]

            int32View[1] = 42;

            Assert.Equal(4, int32View.Length);
            Assert.Equal(42, int32View[1]);

            Int32Array sliced = new Int32Array(buffer.Slice(4, 12));

            // expected output: Int32Array [42, 0]

            Assert.Equal(2, sliced.Length);
            Assert.Equal(42, sliced[0]);
            Assert.Equal(0, sliced[1]);
        }
예제 #10
0
        public static void SharedArrayBuffer_Slice_BeginEndSubset()
        {
            SharedArrayBuffer d = new SharedArrayBuffer(50);

            Assert.Equal(3, d.Slice(1, 4).ByteLength);
        }
예제 #11
0
        public static void SharedArrayBuffer_Slice_BeginZero()
        {
            SharedArrayBuffer d = new SharedArrayBuffer(50);

            Assert.Equal(50, d.Slice(0).ByteLength);
        }
예제 #12
0
        public static void SharedArrayBuffer_Slice_BeginNegative()
        {
            SharedArrayBuffer d = new SharedArrayBuffer(50);

            Assert.Equal(3, d.Slice(-3).ByteLength);
        }
예제 #13
0
        public static void SharedArrayBufferSlice()
        {
            SharedArrayBuffer d = new SharedArrayBuffer(50);

            Assert.Equal(50, d.Slice().ByteLength);
        }
예제 #14
0
        public static void SharedArrayBuffer_Slice_BeginEndForFullArray()
        {
            SharedArrayBuffer d = new SharedArrayBuffer(50);

            Assert.Equal(50, d.Slice(0, 50).ByteLength);
        }
예제 #15
0
 public static Float64Array Float64ArrayFromSharedArrayBuffer(SharedArrayBuffer sab)
 {
     return(new Float64Array(sab));
 }
예제 #16
0
 private static Int32Array Int32ArrayFromSharedArrayBuffer(SharedArrayBuffer sab)
 {
     return(new Int32Array(sab));
 }
예제 #17
0
 private static Float32Array Float32ArrayFromSharedArrayBuffer(SharedArrayBuffer sab)
 {
     return(new Float32Array(sab));
 }
예제 #18
0
        public static EcmaValue ByteLength([This] EcmaValue thisValue)
        {
            SharedArrayBuffer buffer = thisValue.GetUnderlyingObject <SharedArrayBuffer>();

            return(buffer.ByteLength);
        }
예제 #19
0
 public static Uint32Array Uint32ArrayFromSharedArrayBuffer(SharedArrayBuffer sab)
 {
     return(new Uint32Array(sab));
 }
예제 #20
0
 public void BufferSubData(UInt32 target, Int64 offset, SharedArrayBuffer data)
 {
     this.CallVoidMethod("bufferSubData", target, offset, data);
 }
예제 #21
0
 public void BufferData(UInt32 target, SharedArrayBuffer data, UInt32 usage)
 {
     this.CallVoidMethod("bufferData", target, data, usage);
 }
예제 #22
0
        public static void CoreTypes()
        {
            var arr = new Uint8ClampedArray(50);

            Assert.Equal(50, arr.Length);
            Assert.Equal(TypedArrayTypeCode.Uint8ClampedArray, arr.GetTypedArrayType());

            var arr1 = new Uint8Array(50);

            Assert.Equal(50, arr1.Length);
            Assert.Equal(TypedArrayTypeCode.Uint8Array, arr1.GetTypedArrayType());

            var arr2 = new Uint16Array(50);

            Assert.Equal(50, arr2.Length);
            Assert.Equal(TypedArrayTypeCode.Uint16Array, arr2.GetTypedArrayType());

            var arr3 = new Uint32Array(50);

            Assert.Equal(50, arr3.Length);
            Assert.Equal(TypedArrayTypeCode.Uint32Array, arr3.GetTypedArrayType());

            var arr4 = new Int8Array(50);

            Assert.Equal(50, arr4.Length);
            Assert.Equal(TypedArrayTypeCode.Int8Array, arr4.GetTypedArrayType());

            var arr5 = new Int16Array(50);

            Assert.Equal(50, arr5.Length);
            Assert.Equal(TypedArrayTypeCode.Int16Array, arr5.GetTypedArrayType());

            var arr6 = new Int32Array(50);

            Assert.Equal(50, arr6.Length);
            Assert.Equal(TypedArrayTypeCode.Int32Array, arr6.GetTypedArrayType());

            var arr7 = new Float32Array(50);

            Assert.Equal(50, arr7.Length);
            Assert.Equal(TypedArrayTypeCode.Float32Array, arr7.GetTypedArrayType());

            var arr8 = new Float64Array(50);

            Assert.Equal(50, arr8.Length);
            Assert.Equal(TypedArrayTypeCode.Float64Array, arr8.GetTypedArrayType());

            var sharedArr40 = new SharedArrayBuffer(40);
            var sharedArr50 = new SharedArrayBuffer(50);

            var arr9 = new Uint8ClampedArray(sharedArr50);

            Assert.Equal(50, arr9.Length);

            var arr10 = new Uint8Array(sharedArr50);

            Assert.Equal(50, arr10.Length);

            var arr11 = new Uint16Array(sharedArr50);

            Assert.Equal(25, arr11.Length);

            var arr12 = new Uint32Array(sharedArr40);

            Assert.Equal(10, arr12.Length);

            var arr13 = new Int8Array(sharedArr50);

            Assert.Equal(50, arr13.Length);

            var arr14 = new Int16Array(sharedArr40);

            Assert.Equal(20, arr14.Length);

            var arr15 = new Int32Array(sharedArr40);

            Assert.Equal(10, arr15.Length);

            var arr16 = new Float32Array(sharedArr40);

            Assert.Equal(10, arr16.Length);

            var arr17 = new Float64Array(sharedArr40);

            Assert.Equal(5, arr17.Length);
        }
예제 #23
0
 public static Int8Array Int8ArrayFromSharedArrayBuffer(SharedArrayBuffer sab)
 {
     return(new Int8Array(sab));
 }
예제 #24
0
 public void GetBufferSubData(UInt32 target, Int64 offset, SharedArrayBuffer returnedData)
 {
     this.CallVoidMethod("getBufferSubData", target, offset, returnedData);
 }
예제 #25
0
 private static Uint16Array Uint16ArrayFromSharedArrayBuffer(SharedArrayBuffer sab)
 {
     return(new Uint16Array(sab));
 }