From 44623f1f28d796b304a2b4942aa4cf5c598d4700 Mon Sep 17 00:00:00 2001 From: mahaifeng Date: Mon, 12 Aug 2024 15:17:11 +0800 Subject: [PATCH] =?UTF-8?q?[arraybuffer]=E6=B7=BB=E5=8A=A0=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/TFloat32Array.uts | 10 ++++++++++ uni_modules/uts-tests/utssdk/TFloat64Array.uts | 14 ++++++++++++++ uni_modules/uts-tests/utssdk/TInt16Array.uts | 15 ++++++++++++++- uni_modules/uts-tests/utssdk/TInt32Array.uts | 15 ++++++++++++++- uni_modules/uts-tests/utssdk/TInt8Array.uts | 15 ++++++++++++++- uni_modules/uts-tests/utssdk/TUInt8Array.uts | 12 ++++++++++-- .../uts-tests/utssdk/TUInt8ClampedArray.uts | 15 ++++++++++++++- uni_modules/uts-tests/utssdk/TUint16Array.uts | 14 ++++++++++++++ uni_modules/uts-tests/utssdk/TUint32Array.uts | 14 ++++++++++++++ 9 files changed, 118 insertions(+), 6 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/TFloat32Array.uts b/uni_modules/uts-tests/utssdk/TFloat32Array.uts index 10044a1..d24a1e8 100644 --- a/uni_modules/uts-tests/utssdk/TFloat32Array.uts +++ b/uni_modules/uts-tests/utssdk/TFloat32Array.uts @@ -36,9 +36,19 @@ export class TFloat32Array { } // #ifdef APP-ANDROID || WEB from() { + // #TEST Float32Array.from var float32Array = Float32Array.from([1, 2, 3], (v : number, _ : number) : number => v + v); + console.log(float32Array.toString()); // '2,4,6' + // #END expect(float32Array.toString()).toEqual('2,4,6'); } + of() { + // #TEST Float32Array.of + var float32Array = Float32Array.of(1, 2, 3) + console.log(float32Array.toString()); // '1,2,3' + // #END + expect(float32Array.toString()).toEqual("1,2,3"); + } testfloat32() { let float32 = new Float32Array(2); diff --git a/uni_modules/uts-tests/utssdk/TFloat64Array.uts b/uni_modules/uts-tests/utssdk/TFloat64Array.uts index 72d0050..5803f79 100644 --- a/uni_modules/uts-tests/utssdk/TFloat64Array.uts +++ b/uni_modules/uts-tests/utssdk/TFloat64Array.uts @@ -35,6 +35,20 @@ export class TFloat64Array { // #endif } // #ifdef APP-ANDROID || WEB + from() { + // #TEST Float64Array.from + var float64Array = Float64Array.from([1, 2, 3], (v : number, _ : number) : number => v + v); + console.log(float64Array.toString()); // '2,4,6' + // #END + expect(float64Array.toString()).toEqual('2,4,6'); + } + of() { + // #TEST Float64Array.of + var float64Array = Float64Array.of(1, 2, 3) + console.log(float64Array.toString()); // '1,2,3' + // #END + expect(float64Array.toString()).toEqual("1,2,3"); + } testfloat64() { let float64 = new Float64Array(2); float64[0] = 42; diff --git a/uni_modules/uts-tests/utssdk/TInt16Array.uts b/uni_modules/uts-tests/utssdk/TInt16Array.uts index 94af5e7..7a8a9af 100644 --- a/uni_modules/uts-tests/utssdk/TInt16Array.uts +++ b/uni_modules/uts-tests/utssdk/TInt16Array.uts @@ -35,7 +35,20 @@ export class TInt16Array { } // #ifdef APP-ANDROID || WEB - + from() { + // #TEST Int16Array.from + var array = Int16Array.from([1, 2, 3], (v : number, _ : number) : number => v + v); + console.log(array.toString()); // '2,4,6' + // #END + expect(array.toString()).toEqual('2,4,6'); + } + of() { + // #TEST Int16Array.of + var array = Int16Array.of(1, 2, 3) + console.log(array.toString()); // '1,2,3' + // #END + expect(array.toString()).toEqual("1,2,3"); + } testConstructor() { let buffer = new ArrayBuffer(16); let int16 = new Int16Array(buffer); diff --git a/uni_modules/uts-tests/utssdk/TInt32Array.uts b/uni_modules/uts-tests/utssdk/TInt32Array.uts index 8309ac8..c870b5c 100644 --- a/uni_modules/uts-tests/utssdk/TInt32Array.uts +++ b/uni_modules/uts-tests/utssdk/TInt32Array.uts @@ -37,7 +37,20 @@ export class TInt32Array { } // #ifdef APP-ANDROID || WEB - + from() { + // #TEST Int32Array.from + var array = Int32Array.from([1, 2, 3], (v : number, _ : number) : number => v + v); + console.log(array.toString()); // '2,4,6' + // #END + expect(array.toString()).toEqual('2,4,6'); + } + of() { + // #TEST Int32Array.of + var array = Int32Array.of(1, 2, 3) + console.log(array.toString()); // '1,2,3' + // #END + expect(array.toString()).toEqual("1,2,3"); + } testInt32Array() { let int32 = new Int32Array(2); int32[0] = 42; diff --git a/uni_modules/uts-tests/utssdk/TInt8Array.uts b/uni_modules/uts-tests/utssdk/TInt8Array.uts index 7c1b82e..4e62805 100644 --- a/uni_modules/uts-tests/utssdk/TInt8Array.uts +++ b/uni_modules/uts-tests/utssdk/TInt8Array.uts @@ -37,7 +37,20 @@ export class TInt8Array { } // #ifdef APP-ANDROID || WEB - + from() { + // #TEST Int8Array.from + var array = Int8Array.from([1, 2, 3], (v : number, _ : number) : number => v + v); + console.log(array.toString()); // '2,4,6' + // #END + expect(array.toString()).toEqual('2,4,6'); + } + of() { + // #TEST Int8Array.of + var array = Int8Array.of(1, 2, 3) + console.log(array.toString()); // '1,2,3' + // #END + expect(array.toString()).toEqual("1,2,3"); + } testConstructor() { let buffer = new ArrayBuffer(16); let int8View = new Int8Array(buffer); diff --git a/uni_modules/uts-tests/utssdk/TUInt8Array.uts b/uni_modules/uts-tests/utssdk/TUInt8Array.uts index 4972cd8..5c6b90c 100644 --- a/uni_modules/uts-tests/utssdk/TUInt8Array.uts +++ b/uni_modules/uts-tests/utssdk/TUInt8Array.uts @@ -36,12 +36,20 @@ export class TUint8Array { // #endif } // #ifdef APP-ANDROID || WEB - + of() { + // #TEST Uint8Array.of + var array = Uint8Array.of(1, 2, 3) + console.log(array.toString()); // '1,2,3' + // #END + expect(array.toString()).toEqual("1,2,3"); + } from() { + // #TEST Uint8Array.from var s = new Set([1, 2, 3]); var unit8 = Uint8Array.from(s); + console.log(unit8.toString()); // '1,2,3' + // #END expect(unit8.toString()).toEqual('1,2,3'); - console.log(unit8.toString()) } testMAX() { let uint8 = new Uint8Array(16); diff --git a/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts b/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts index 48b2cd6..f0b6fc5 100644 --- a/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts +++ b/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts @@ -37,7 +37,20 @@ export class TUint8ClampedArray { } // #ifdef APP-ANDROID || WEB - + from() { + // #TEST Uint8ClampedArray.from + var array = Uint8ClampedArray.from([1, 2, 3], (v : number, _ : number) : number => v + v); + console.log(array.toString()); // '2,4,6' + // #END + expect(array.toString()).toEqual('2,4,6'); + } + of() { + // #TEST Uint8ClampedArray.of + var array = Uint8ClampedArray.of(1, 2, 3) + console.log(array.toString()); // '1,2,3' + // #END + expect(array.toString()).toEqual("1,2,3"); + } testMAX() { let uint8Clamped = new Uint8ClampedArray(16); uint8Clamped[0] = 255; diff --git a/uni_modules/uts-tests/utssdk/TUint16Array.uts b/uni_modules/uts-tests/utssdk/TUint16Array.uts index 7d0d9ab..3b313ce 100644 --- a/uni_modules/uts-tests/utssdk/TUint16Array.uts +++ b/uni_modules/uts-tests/utssdk/TUint16Array.uts @@ -36,6 +36,20 @@ export class TUint16Array { } // #ifdef APP-ANDROID || WEB + from() { + // #TEST Uint16Array.from + var array = Uint16Array.from([1, 2, 3], (v : number, _ : number) : number => v + v); + console.log(array.toString()); // '2,4,6' + // #END + expect(array.toString()).toEqual('2,4,6'); + } + of() { + // #TEST Uint16Array.of + var array = Uint16Array.of(1, 2, 3) + console.log(array.toString()); // '1,2,3' + // #END + expect(array.toString()).toEqual("1,2,3"); + } testuint16() { let uint16 = new Uint16Array(2); uint16[0] = 42; diff --git a/uni_modules/uts-tests/utssdk/TUint32Array.uts b/uni_modules/uts-tests/utssdk/TUint32Array.uts index e1c9f52..73147af 100644 --- a/uni_modules/uts-tests/utssdk/TUint32Array.uts +++ b/uni_modules/uts-tests/utssdk/TUint32Array.uts @@ -37,6 +37,20 @@ export class TUint32Array { } // #ifdef APP-ANDROID || WEB + from() { + // #TEST Uint32Array.from + var array = Uint32Array.from([1, 2, 3], (v : number, _ : number) : number => v + v); + console.log(array.toString()); // '2,4,6' + // #END + expect(array.toString()).toEqual('2,4,6'); + } + of() { + // #TEST Uint32Array.of + var array = Uint32Array.of(1, 2, 3) + console.log(array.toString()); // '1,2,3' + // #END + expect(array.toString()).toEqual("1,2,3"); + } testuint32() { let uint32 = new Uint32Array(2); uint32[0] = 42; -- GitLab