From 43ab505d5e60c78c7f6128efed29084997aebc89 Mon Sep 17 00:00:00 2001 From: mahaifeng Date: Thu, 4 Jul 2024 12:05:53 +0800 Subject: [PATCH] =?UTF-8?q?[array-buffer]=E5=8E=BB=E6=8E=89tofloat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/TDataView.uts | 5 +++-- .../uts-tests/utssdk/TUInt8ClampedArray.uts | 20 +++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/TDataView.uts b/uni_modules/uts-tests/utssdk/TDataView.uts index b493b3c..3e03ce5 100644 --- a/uni_modules/uts-tests/utssdk/TDataView.uts +++ b/uni_modules/uts-tests/utssdk/TDataView.uts @@ -45,8 +45,9 @@ 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); - expect(this.numberEquals(3.1415927, view.getFloat32(1).toFloat())).toEqual(true); + view.setFloat32(1,3); + console.log('setFloat32',view.getFloat32(1)) + expect(this.numberEquals(3, view.getFloat32(1))).toEqual(true); } setFloat64() { diff --git a/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts b/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts index c3f1789..862e803 100644 --- a/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts +++ b/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts @@ -64,7 +64,7 @@ export class TUint8ClampedArray { testEvery() { // const isBelowThreshold = (currentValue: number, index: number, array:Uint8ClampedArray): boolean => currentValue < 40; - let result = new Uint8ClampedArray([12, 5, 8, 130, 44]).every((value: number, _: number, _: + let result = new Uint8ClampedArray([12, 5, 8, 130, 44]).every((value: number, _: number, _a: Uint8ClampedArray): boolean => value < 40); // expect(result).toEqual(false); } @@ -89,24 +89,24 @@ export class TUint8ClampedArray { testFilter() { // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; - let float32 = new Uint8ClampedArray([12, 5, 8, 44]).filter((value: number, _: number, _: + let float32 = new Uint8ClampedArray([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint8ClampedArray): boolean => value >= 10); expect(float32.toString()).toEqual("12,44"); } find() { let float32 = new Uint8ClampedArray([4, 5, 8, 12]); - let res = float32.find((value: number, _: number, _: Uint8ClampedArray): boolean => value > 5); + let res = float32.find((value: number, _: number, _a: Uint8ClampedArray): boolean => value > 5); expect(res).toEqual(8); } findIndex() { let float32 = new Uint8ClampedArray([4, 6, 8, 12]); - let res = float32.findIndex((value: number, _: number, _: Uint8ClampedArray): boolean => value > 100); + let res = float32.findIndex((value: number, _: number, _a: Uint8ClampedArray): boolean => value > 100); expect(res).toEqual(-1); let ufloat32 = new Uint8ClampedArray([4, 6, 7, 120]); - res = ufloat32.findIndex((value: number, _: number, _: Uint8ClampedArray): boolean => value > 100); + res = ufloat32.findIndex((value: number, _: number, _a: Uint8ClampedArray): boolean => value > 100); expect(res).toEqual(3); } @@ -173,31 +173,31 @@ export class TUint8ClampedArray { map() { let numbers = new Uint8ClampedArray([1, 4, 9]); - let doubles = numbers.map((value: number, _: number, _: Uint8ClampedArray): number => value * 2); + let doubles = numbers.map((value: number, _: number, _a: Uint8ClampedArray): number => value * 2); expect(numbers.toString()).toEqual("1,4,9"); expect(doubles.toString()).toEqual("2,8,18"); } reduce() { let total = new Uint8ClampedArray([0, 1, 2, 3]); - let res = total.reduce((accumulator: number, currentValue: number, _: number, _: + let res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint8ClampedArray): number => accumulator + currentValue); expect(res).toEqual(6); total = new Uint8ClampedArray([0, 1, 2, 3]); - res = total.reduce((accumulator: number, currentValue: number, _: number, _: Uint8ClampedArray): + res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Uint8ClampedArray): number => accumulator + currentValue, 8); expect(res).toEqual(14); } reduceRight() { let total = new Uint8ClampedArray([0, 1, 2, 3]); - let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: + let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Uint8ClampedArray): number => accumulator + currentValue); expect(res).toEqual(6); total = new Uint8ClampedArray([0, 1, 2, 3]); - res = total.reduceRight((accumulator: number, currentValue: number, _: number, _: + res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Uint8ClampedArray): number => accumulator + currentValue, 8); expect(res).toEqual(14); } -- GitLab