From eaff6294e3ed9bc624cf14a883e3ec2bfaeb4d4c Mon Sep 17 00:00:00 2001 From: mahaifeng Date: Tue, 2 Jul 2024 12:54:22 +0800 Subject: [PATCH] =?UTF-8?q?[arraybuffer]=E4=BF=AE=E6=94=B9=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/TFloat32Array.js | 8 ++++---- uni_modules/uts-tests/utssdk/TFloat64Array.js | 8 ++++---- uni_modules/uts-tests/utssdk/TInt16Array.js | 8 ++++---- uni_modules/uts-tests/utssdk/TInt8Array.js | 9 +++++---- uni_modules/uts-tests/utssdk/TUInt8Array.js | 14 +++++++------- .../uts-tests/utssdk/TUInt8ClampedArray.js | 14 +++++++------- uni_modules/uts-tests/utssdk/TUint16Array.js | 18 +++++++++--------- 7 files changed, 40 insertions(+), 39 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/TFloat32Array.js b/uni_modules/uts-tests/utssdk/TFloat32Array.js index f53690a..e12839c 100644 --- a/uni_modules/uts-tests/utssdk/TFloat32Array.js +++ b/uni_modules/uts-tests/utssdk/TFloat32Array.js @@ -203,24 +203,24 @@ export class TFloat32Array { let total = new Float32Array([0, 1, 2, 3]); let res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Float32Array): number => accumulator + currentValue); - expect(res).toEqual(6.0); + expect(res).toEqual(6); total = new Float32Array([0, 1, 2, 3]); res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Float32Array): number => accumulator + currentValue, 8); - expect(res).toEqual(14.0); + expect(res).toEqual(14); } reduceRight() { let total = new Float32Array([0, 1, 2, 3]); let res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Float32Array): number => accumulator + currentValue); - expect(res).toEqual(6.0); + expect(res).toEqual(6); total = new Float32Array([0, 1, 2, 3]); res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Float32Array): number => accumulator + currentValue, 8); - expect(res).toEqual(14.0); + expect(res).toEqual(14); } reverse() { diff --git a/uni_modules/uts-tests/utssdk/TFloat64Array.js b/uni_modules/uts-tests/utssdk/TFloat64Array.js index 170a0e6..fda866d 100644 --- a/uni_modules/uts-tests/utssdk/TFloat64Array.js +++ b/uni_modules/uts-tests/utssdk/TFloat64Array.js @@ -198,24 +198,24 @@ export class TFloat64Array { let total = new Float64Array([0, 1, 2, 3]); let res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Float64Array): number => accumulator + currentValue); - expect(res).toEqual(6.0); + expect(res).toEqual(6); total = new Float64Array([0, 1, 2, 3]); res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Float64Array): number => accumulator + currentValue, 8); - expect(res).toEqual(14.0); + expect(res).toEqual(14); } reduceRight() { let total = new Float64Array([0, 1, 2, 3]); let res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Float64Array): number => accumulator + currentValue); - expect(res).toEqual(6.0); + expect(res).toEqual(6); total = new Float64Array([0, 1, 2, 3]); res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Float64Array): number => accumulator + currentValue, 8); - expect(res).toEqual(14.0); + expect(res).toEqual(14); } reverse() { diff --git a/uni_modules/uts-tests/utssdk/TInt16Array.js b/uni_modules/uts-tests/utssdk/TInt16Array.js index 90c2f31..422c6a4 100644 --- a/uni_modules/uts-tests/utssdk/TInt16Array.js +++ b/uni_modules/uts-tests/utssdk/TInt16Array.js @@ -177,21 +177,21 @@ export class TInt16Array { reduce() { let total = new Int16Array([0, 1, 2, 3]); let res = total.reduce((accumulator : number, currentValue : number, currentIndex : number, array : Int16Array): number => accumulator + currentValue); - expect(res).toEqual(6.0); + expect(res).toEqual(6); total = new Int16Array([0, 1, 2, 3]); res = total.reduce((accumulator : number, currentValue : number, currentIndex : number, array : Int16Array): number => accumulator + currentValue, 8); - expect(res).toEqual(14.0); + expect(res).toEqual(14); } reduceRight() { let total = new Int16Array([0, 1, 2, 3]); let res = total.reduceRight((accumulator: number, currentValue : number, currentIndex : number, array : Int16Array): number => accumulator + currentValue); - expect(res).toEqual(6.0); + expect(res).toEqual(6); total = new Int16Array([0, 1, 2, 3]); res = total.reduceRight((accumulator: number, currentValue : number, currentIndex : number, array : Int16Array): number => accumulator + currentValue, 8); - expect(res).toEqual(14.0); + expect(res).toEqual(14); } reverse() { diff --git a/uni_modules/uts-tests/utssdk/TInt8Array.js b/uni_modules/uts-tests/utssdk/TInt8Array.js index 3bc37bb..91a84fa 100644 --- a/uni_modules/uts-tests/utssdk/TInt8Array.js +++ b/uni_modules/uts-tests/utssdk/TInt8Array.js @@ -2,6 +2,7 @@ import { describe, test, expect, + expectNumber, Result } from './tests.uts' @@ -181,25 +182,25 @@ export class TInt8Array { let total = new Int8Array([0, 1, 2, 3]); let res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Int8Array): number => accumulator + currentValue); - expect(res).toEqual(6.0); + expect(res).toEqual(6); total = new Int8Array([0, 1, 2, 3]); res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Int8Array): number => accumulator + currentValue, 8); - expect(res).toEqual(14.0); + expect(res).toEqual(14); } reduceRight() { let total = new Int8Array([0, 1, 2, 3]); let res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Int8Array): number => accumulator + currentValue); - expect(res).toEqual(6.0); + expect(res).toEqual(6); total = new Int8Array([0, 1, 2, 3]); res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Int8Array): number => accumulator + currentValue, 8); - expect(res).toEqual(14.0); + expect(res).toEqual(14); } reverse() { diff --git a/uni_modules/uts-tests/utssdk/TUInt8Array.js b/uni_modules/uts-tests/utssdk/TUInt8Array.js index 65c0ebf..018471a 100644 --- a/uni_modules/uts-tests/utssdk/TUInt8Array.js +++ b/uni_modules/uts-tests/utssdk/TUInt8Array.js @@ -123,13 +123,13 @@ export class TUint8Array { includes() { let float32 = new Uint8Array([1, 2, 3]); - let res = float32.includes(2.0); + let res = float32.includes(2); expect(res).toEqual(true); - res = float32.includes(4.0); + res = float32.includes(4); expect(res).toEqual(false); - res = float32.includes(3.0, 3); + res = float32.includes(3, 3); expect(res).toEqual(false); } @@ -179,21 +179,21 @@ export class TUint8Array { reduce() { let total = new Uint8Array([0, 1, 2, 3]); let res = total.reduce((accumulator : number, currentValue : number, currentIndex : number, array : Uint8Array): number => accumulator + currentValue); - expect(res).toEqual(6.0); + expect(res).toEqual(6); total = new Uint8Array([0, 1, 2, 3]); res = total.reduce((accumulator : number, currentValue : number, currentIndex : number, array : Uint8Array): number => accumulator + currentValue, 8); - expect(res).toEqual(14.0); + expect(res).toEqual(14); } reduceRight() { let total = new Uint8Array([0, 1, 2, 3]); let res = total.reduceRight((accumulator: number, currentValue : number, currentIndex : number, array : Uint8Array): number => accumulator + currentValue); - expect(res).toEqual(6.0); + expect(res).toEqual(6); total = new Uint8Array([0, 1, 2, 3]); res = total.reduceRight((accumulator: number, currentValue : number, currentIndex : number, array : Uint8Array): number => accumulator + currentValue, 8); - expect(res).toEqual(14.0); + expect(res).toEqual(14); } reverse() { diff --git a/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.js b/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.js index 6739cdc..a51e5b4 100644 --- a/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.js +++ b/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.js @@ -125,13 +125,13 @@ export class TUint8ClampedArray { includes() { let float32 = new Uint8ClampedArray([1, 2, 3]); - let res = float32.includes(2.0); + let res = float32.includes(2); expect(res).toEqual(true); - res = float32.includes(4.0); + res = float32.includes(4); expect(res).toEqual(false); - res = float32.includes(3.0, 3); + res = float32.includes(3, 3); expect(res).toEqual(false); } @@ -182,24 +182,24 @@ export class TUint8ClampedArray { let total = new Uint8ClampedArray([0, 1, 2, 3]); let res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray): number => accumulator + currentValue); - expect(res).toEqual(6.0); + expect(res).toEqual(6); total = new Uint8ClampedArray([0, 1, 2, 3]); res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray): number => accumulator + currentValue, 8); - expect(res).toEqual(14.0); + expect(res).toEqual(14); } reduceRight() { let total = new Uint8ClampedArray([0, 1, 2, 3]); let res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray): number => accumulator + currentValue); - expect(res).toEqual(6.0); + expect(res).toEqual(6); total = new Uint8ClampedArray([0, 1, 2, 3]); res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray): number => accumulator + currentValue, 8); - expect(res).toEqual(14.0); + expect(res).toEqual(14); } reverse() { diff --git a/uni_modules/uts-tests/utssdk/TUint16Array.js b/uni_modules/uts-tests/utssdk/TUint16Array.js index c15c635..b6294a9 100644 --- a/uni_modules/uts-tests/utssdk/TUint16Array.js +++ b/uni_modules/uts-tests/utssdk/TUint16Array.js @@ -139,13 +139,13 @@ export class TUint16Array { includes() { let float32 = new Uint16Array([1, 2, 3]); - let res = float32.includes(2.0); + let res = float32.includes(2); expect(res).toEqual(true); - res = float32.includes(4.0); + res = float32.includes(4); expect(res).toEqual(false); - res = float32.includes(3.0, 3); + res = float32.includes(3, 3); expect(res).toEqual(false); } @@ -196,24 +196,24 @@ export class TUint16Array { let total = new Uint16Array([0, 1, 2, 3]); let res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Uint16Array): number => accumulator + currentValue); - expect(res).toEqual(6.0); + expect(res).toEqual(6); total = new Uint16Array([0, 1, 2, 3]); res = total.reduce((accumulator: number, currentValue: number, currentIndex: number, array: Uint16Array): number => accumulator + currentValue, 8); - expect(res).toEqual(14.0); + expect(res).toEqual(14); } reduceRight() { let total = new Uint16Array([0, 1, 2, 3]); let res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Uint16Array): number => accumulator + currentValue); - expect(res).toEqual(6.0); + expect(res).toEqual(6); total = new Uint16Array([0, 1, 2, 3]); res = total.reduceRight((accumulator: number, currentValue: number, currentIndex: number, array: Uint16Array): number => accumulator + currentValue, 8); - expect(res).toEqual(14.0); + expect(res).toEqual(14); } reverse() { @@ -266,8 +266,8 @@ export class TUint16Array { arrayBufferSlice() { let buffer = new ArrayBuffer(16); let float32 = new Uint16Array(buffer); - float32[3] = 42; - expect(float32.toString()).toEqual("0,0,0,42,0,0,0,0"); + float32[4] = 42; + expect(float32.toString()).toEqual("0,0,0,0,42,0,0,0"); let res = buffer.slice(8); let sliced = new Uint16Array(res); -- GitLab