From acb1537712f9289b88aff8cba38f2699b3bd9335 Mon Sep 17 00:00:00 2001 From: mahaifeng Date: Mon, 15 Jul 2024 17:08:10 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"[array-buffer]=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B,=E5=B0=86Int=EF=BC=8CNumbe?= =?UTF-8?q?r=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 This reverts commit e736e88a24ba7e2b89d5f7b8d63897edada271aa. --- 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 b493b3c..25cbcdd 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,3.1415927); + view.setFloat32(1, Math.PI.toFloat()); 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: number, littleEndian: boolean): ArrayBuffer { - var buffer = new ArrayBuffer(1000 * 14); + makeBuffer(size: Int, littleEndian: boolean): ArrayBuffer { + var buffer = new ArrayBuffer(size * 14); var view = new DataView(buffer); - for (var i = 0; i < 1000; ++i) { + for (var i = 0; i < size; ++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 reader1 = new BigEndian(buffer); + var reader = new BigEndian(buffer); for (var i = 0; i < buffer.byteLength; i += 14) { - 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); + 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); } } } doFloatIterations(dataView: boolean) { - var buffer = this.makeFloatBuffer(); + var buffer = makeFloatBuffer(1000); var iterations = 10; if (dataView) { for (var i = 0; i < iterations; i++) @@ -205,10 +205,10 @@ export class TDataView { } } - makeFloatBuffer(): ArrayBuffer { - var buffer = new ArrayBuffer(1000 * 16); + makeFloatBuffer(size: Int): ArrayBuffer { + var buffer = new ArrayBuffer(size * 16); var view = new DataView(buffer); - for (var i = 0; i < 1000; i++) { + for (var i = 0; i < size; 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 f81bb36..0cc5b4c 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 0728e9a..d33b3bb 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 a21b35c..533f017 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 9548d40..beef28c 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 a06b40d..093378b 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 cdf3fdd..e66e827 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 c3f1789..5053b86 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 33339fa..56942d8 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 94de432..265765f 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