From e736e88a24ba7e2b89d5f7b8d63897edada271aa Mon Sep 17 00:00:00 2001 From: mahaifeng Date: Wed, 3 Jul 2024 17:45:52 +0800 Subject: [PATCH] =?UTF-8?q?[array-buffer]=E4=BF=AE=E6=94=B9=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B,=E5=B0=86Int=EF=BC=8CNumber?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=8E=BB=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/TDataView.uts | 32 +++++++++---------- .../uts-tests/utssdk/TFloat32Array.uts | 2 +- .../uts-tests/utssdk/TFloat64Array.uts | 2 +- uni_modules/uts-tests/utssdk/TInt16Array.uts | 2 +- uni_modules/uts-tests/utssdk/TInt32Array.uts | 2 +- uni_modules/uts-tests/utssdk/TInt8Array.uts | 2 +- uni_modules/uts-tests/utssdk/TUInt8Array.uts | 2 +- .../uts-tests/utssdk/TUInt8ClampedArray.uts | 2 +- uni_modules/uts-tests/utssdk/TUint16Array.uts | 2 +- uni_modules/uts-tests/utssdk/TUint32Array.uts | 2 +- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/TDataView.uts b/uni_modules/uts-tests/utssdk/TDataView.uts index 25cbcdd..b493b3c 100644 --- a/uni_modules/uts-tests/utssdk/TDataView.uts +++ b/uni_modules/uts-tests/utssdk/TDataView.uts @@ -45,7 +45,7 @@ export class TDataView { // Create an ArrayBuffer with a size in bytes let buffer = new ArrayBuffer(16); let view = new DataView(buffer); - view.setFloat32(1, Math.PI.toFloat()); + view.setFloat32(1,3.1415927); expect(this.numberEquals(3.1415927, view.getFloat32(1).toFloat())).toEqual(true); } @@ -97,7 +97,7 @@ export class TDataView { expect(this.numberEquals(255, view.getUint8(1))).toEqual(true); } - numberEquals(a: Number, b: Number): Boolean { + numberEquals(a: number, b: number): Boolean { return a == b } @@ -138,10 +138,10 @@ export class TDataView { } } - makeBuffer(size: Int, littleEndian: boolean): ArrayBuffer { - var buffer = new ArrayBuffer(size * 14); + makeBuffer(size: number, littleEndian: boolean): ArrayBuffer { + var buffer = new ArrayBuffer(1000 * 14); var view = new DataView(buffer); - for (var i = 0; i < size; ++i) { + for (var i = 0; i < 1000; ++i) { view.setInt8(i * 14, i); view.setUint8(i * 14 + 1, i); view.setInt16(i * 14 + 2, i * i, littleEndian); @@ -180,21 +180,21 @@ export class TDataView { } expect(xor).toEqual(0); } else { - var reader = new BigEndian(buffer); + var reader1 = new BigEndian(buffer); for (var i = 0; i < buffer.byteLength; i += 14) { - xor ^= reader.getInt8(i); - xor ^= reader.getUint8(i + 1); - xor ^= reader.getInt16(i + 2); - xor ^= reader.getUint16(i + 4); - xor ^= reader.getInt32(i + 6); - xor ^= reader.getUint32(i + 10); + xor ^= reader1.getInt8(i); + xor ^= reader1.getUint8(i + 1); + xor ^= reader1.getInt16(i + 2); + xor ^= reader1.getUint16(i + 4); + xor ^= reader1.getInt32(i + 6); + xor ^= reader1.getUint32(i + 10); } } } doFloatIterations(dataView: boolean) { - var buffer = makeFloatBuffer(1000); + var buffer = this.makeFloatBuffer(); var iterations = 10; if (dataView) { for (var i = 0; i < iterations; i++) @@ -205,10 +205,10 @@ export class TDataView { } } - makeFloatBuffer(size: Int): ArrayBuffer { - var buffer = new ArrayBuffer(size * 16); + makeFloatBuffer(): ArrayBuffer { + var buffer = new ArrayBuffer(1000 * 16); var view = new DataView(buffer); - for (var i = 0; i < size; i++) { + for (var i = 0; i < 1000; i++) { view.setFloat64(i * 16, Math.log10(i + 1)); view.setFloat32(i * 16 + 8, Math.sqrt(i)); view.setFloat32(i * 16 + 12, Math.cos(i)); diff --git a/uni_modules/uts-tests/utssdk/TFloat32Array.uts b/uni_modules/uts-tests/utssdk/TFloat32Array.uts index 0cc5b4c..f81bb36 100644 --- a/uni_modules/uts-tests/utssdk/TFloat32Array.uts +++ b/uni_modules/uts-tests/utssdk/TFloat32Array.uts @@ -253,7 +253,7 @@ export class TFloat32Array { numbers.sort(); expect(numbers.toString()).toEqual("1,5,40"); - numbers.sort((a, b): Number => a - b); + numbers.sort((a, b): number => a - b); expect(numbers.toString()).toEqual("1,5,40"); } diff --git a/uni_modules/uts-tests/utssdk/TFloat64Array.uts b/uni_modules/uts-tests/utssdk/TFloat64Array.uts index d33b3bb..0728e9a 100644 --- a/uni_modules/uts-tests/utssdk/TFloat64Array.uts +++ b/uni_modules/uts-tests/utssdk/TFloat64Array.uts @@ -244,7 +244,7 @@ export class TFloat64Array { numbers.sort(); expect(numbers.toString()).toEqual("1,5,40"); - numbers.sort((a, b): Number => a - b); + numbers.sort((a, b): number => a - b); expect(numbers.toString()).toEqual("1,5,40"); } diff --git a/uni_modules/uts-tests/utssdk/TInt16Array.uts b/uni_modules/uts-tests/utssdk/TInt16Array.uts index 533f017..a21b35c 100644 --- a/uni_modules/uts-tests/utssdk/TInt16Array.uts +++ b/uni_modules/uts-tests/utssdk/TInt16Array.uts @@ -220,7 +220,7 @@ export class TInt16Array { numbers.sort(); expect(numbers.toString()).toEqual("1,5,40"); - numbers.sort((a, b):Number => a - b); + numbers.sort((a, b):number => a - b); expect(numbers.toString()).toEqual("1,5,40"); } diff --git a/uni_modules/uts-tests/utssdk/TInt32Array.uts b/uni_modules/uts-tests/utssdk/TInt32Array.uts index beef28c..9548d40 100644 --- a/uni_modules/uts-tests/utssdk/TInt32Array.uts +++ b/uni_modules/uts-tests/utssdk/TInt32Array.uts @@ -236,7 +236,7 @@ export class TInt32Array { numbers.sort(); expect(numbers.toString()).toEqual("1,5,40"); - numbers.sort((a, b):Number => a - b); + numbers.sort((a, b):number => a - b); expect(numbers.toString()).toEqual("1,5,40"); } diff --git a/uni_modules/uts-tests/utssdk/TInt8Array.uts b/uni_modules/uts-tests/utssdk/TInt8Array.uts index 093378b..a06b40d 100644 --- a/uni_modules/uts-tests/utssdk/TInt8Array.uts +++ b/uni_modules/uts-tests/utssdk/TInt8Array.uts @@ -229,7 +229,7 @@ export class TInt8Array { numbers.sort(); expect(numbers.toString()).toEqual("1,5,40"); - numbers.sort((a, b): Number => a - b); + numbers.sort((a, b): number => a - b); expect(numbers.toString()).toEqual("1,5,40"); } diff --git a/uni_modules/uts-tests/utssdk/TUInt8Array.uts b/uni_modules/uts-tests/utssdk/TUInt8Array.uts index e66e827..cdf3fdd 100644 --- a/uni_modules/uts-tests/utssdk/TUInt8Array.uts +++ b/uni_modules/uts-tests/utssdk/TUInt8Array.uts @@ -233,7 +233,7 @@ export class TUint8Array { numbers.sort(); expect(numbers.toString()).toEqual("1,5,40"); - numbers.sort((a, b): Number => a - b); + numbers.sort((a, b): number => a - b); expect(numbers.toString()).toEqual("1,5,40"); } diff --git a/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts b/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts index 5053b86..c3f1789 100644 --- a/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts +++ b/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts @@ -228,7 +228,7 @@ export class TUint8ClampedArray { numbers.sort(); expect(numbers.toString()).toEqual("1,5,40"); - numbers.sort((a, b): Number => a - b); + numbers.sort((a, b): number => a - b); expect(numbers.toString()).toEqual("1,5,40"); } diff --git a/uni_modules/uts-tests/utssdk/TUint16Array.uts b/uni_modules/uts-tests/utssdk/TUint16Array.uts index 56942d8..33339fa 100644 --- a/uni_modules/uts-tests/utssdk/TUint16Array.uts +++ b/uni_modules/uts-tests/utssdk/TUint16Array.uts @@ -242,7 +242,7 @@ export class TUint16Array { numbers.sort(); expect(numbers.toString()).toEqual("1,5,40"); - numbers.sort((a, b): Number => a - b); + numbers.sort((a, b): number => a - b); expect(numbers.toString()).toEqual("1,5,40"); } diff --git a/uni_modules/uts-tests/utssdk/TUint32Array.uts b/uni_modules/uts-tests/utssdk/TUint32Array.uts index 265765f..94de432 100644 --- a/uni_modules/uts-tests/utssdk/TUint32Array.uts +++ b/uni_modules/uts-tests/utssdk/TUint32Array.uts @@ -242,7 +242,7 @@ export class TUint32Array { numbers.sort(); expect(numbers.toString()).toEqual("1,5,40"); - numbers.sort((a, b): Number => a - b); + numbers.sort((a, b): number => a - b); expect(numbers.toString()).toEqual("1,5,40"); } -- GitLab