diff --git a/uni_modules/uts-tests/utssdk/TFloat32Array.uts b/uni_modules/uts-tests/utssdk/TFloat32Array.uts index ffed4d872bab1e0a1653271f55b6784fd8750cfc..c28717f7a08fe2dd48b307c9cac078b4e105928f 100644 --- a/uni_modules/uts-tests/utssdk/TFloat32Array.uts +++ b/uni_modules/uts-tests/utssdk/TFloat32Array.uts @@ -7,7 +7,7 @@ import { export class TFloat32Array { test() { - // #ifdef APP-ANDROID + // #ifdef APP-ANDROID this.testfloat32(); this.testConstructor(); this.testSet(); @@ -35,9 +35,9 @@ export class TFloat32Array { // #endif } // #ifdef APP-ANDROID - from(){ - var float32Array= Float32Array.from([1, 2, 3], (v: number, _: number):number => v + v); - expect(float32Array.toString()).toEqual('2,4,6'); + from() { + var float32Array = Float32Array.from([1, 2, 3], (v : number, _ : number) : number => v + v); + expect(float32Array.toString()).toEqual('2,4,6'); } testfloat32() { @@ -88,7 +88,7 @@ export class TFloat32Array { testEvery() { // const isBelowThreshold = (currentValue: number, index: number, array:Float32Array): boolean => currentValue < 40; - let result = new Float32Array([12, 5, 8, 130, 44]).every((value: number, _: number, _a: Float32Array): + let result = new Float32Array([12, 5, 8, 130, 44]).every((value : number, _ : number, _a : Float32Array) : boolean => value < 40); // expect(result).toEqual(false); } @@ -113,29 +113,29 @@ export class TFloat32Array { testFilter() { // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; - let float32 = new Float32Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Float32Array): + let float32 = new Float32Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Float32Array) : boolean => value >= 10); expect(float32.toString()).toEqual("12,44"); } find() { let float32 = new Float32Array([4, 5, 8, 12]); - let res = float32.find((value: number, _: number, _a: Float32Array): boolean => value > 5); + let res = float32.find((value : number, _ : number, _a : Float32Array) : boolean => value > 5); expect(res).toEqual(8); } findIndex() { let float32 = new Float32Array([4, 6, 8, 12]); - let res = float32.findIndex((value: number, _: number, _a: Float32Array): boolean => value > 100); + let res = float32.findIndex((value : number, _ : number, _a : Float32Array) : boolean => value > 100); expect(res).toEqual(-1); let ufloat32 = new Float32Array([4, 6, 7, 120]); - res = ufloat32.findIndex((value: number, _: number, _a: Float32Array): boolean => value > 100); + res = ufloat32.findIndex((value : number, _ : number, _a : Float32Array) : boolean => value > 100); expect(res).toEqual(3); } foreach() { - new Float32Array([0, 1, 2, 3]).forEach((value: number,index: number, _: Float32Array) => { + new Float32Array([0, 1, 2, 3]).forEach((value : number, index : number, _ : Float32Array) => { console.log(`a[${index}] = ${value}`); }); } @@ -201,31 +201,31 @@ export class TFloat32Array { map() { let numbers = new Float32Array([1, 4, 9]); - let doubles = numbers.map((value: number, _: number, _a: Float32Array): number => value * 2); + let doubles = numbers.map((value : number, _ : number, _a : Float32Array) : number => value * 2); expect(numbers.toString()).toEqual("1,4,9"); expect(doubles.toString()).toEqual("2,8,18"); } reduce() { let total = new Float32Array([0, 1, 2, 3]); - let res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Float32Array): + let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Float32Array) : number => accumulator + currentValue); expect(res).toEqual(6); total = new Float32Array([0, 1, 2, 3]); - res = total.reduce((accumulator: number, currentValue: number, _: number, _a: Float32Array): + res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Float32Array) : number => accumulator + currentValue, 8); expect(res).toEqual(14); } reduceRight() { let total = new Float32Array([0, 1, 2, 3]); - let res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: - Float32Array): number => accumulator + currentValue); + let res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : + Float32Array) : number => accumulator + currentValue); expect(res).toEqual(6); total = new Float32Array([0, 1, 2, 3]); - res = total.reduceRight((accumulator: number, currentValue: number, _: number, _a: Float32Array): + res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Float32Array) : number => accumulator + currentValue, 8); expect(res).toEqual(14); } @@ -256,7 +256,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 92e7e230b9a9410433e6b2296b4e394ec2bae49d..79d31c63ec95f17e382bb522eabff6dcd8929c62 100644 --- a/uni_modules/uts-tests/utssdk/TFloat64Array.uts +++ b/uni_modules/uts-tests/utssdk/TFloat64Array.uts @@ -36,10 +36,10 @@ export class TFloat64Array { } // #ifdef APP-ANDROID testfloat64() { - let float32 = new Float64Array(2); - float32[0] = 42; - expect(float32[0]).toEqual(42); - expect(float32.length).toEqual(2); + let float64 = new Float64Array(2); + float64[0] = 42; + expect(float64[0]).toEqual(42); + expect(float64.length).toEqual(2); expect(Float64Array.BYTES_PER_ELEMENT).toEqual(8); let x = new Float64Array([21, 31, 3]); @@ -56,23 +56,23 @@ export class TFloat64Array { testConstructor() { let buffer = new ArrayBuffer(16); - let float32 = new Float64Array(buffer); - float32[1] = 42; - expect(float32.toString()).toEqual("0,42"); + let float64 = new Float64Array(buffer); + float64[1] = 42; + expect(float64.toString()).toEqual("0,42"); } testSet() { - let float32 = new Float64Array(8); + let float64 = new Float64Array(8); var array = [1, 2, 3] - float32.set(array, 1); - expect(float32.toString()).toEqual("0,1,2,3,0,0,0,0"); + float64.set(array, 1); + expect(float64.toString()).toEqual("0,1,2,3,0,0,0,0"); } testCopyWith() { - let float32 = new Float64Array(8); - float32.set([1, 2, 3], 1); - float32.copyWithin(3, 0, 3); - expect(float32.toString()).toEqual("0,1,2,0,1,2,0,0"); + let float64 = new Float64Array(8); + float64.set([1, 2, 3], 1); + float64.copyWithin(3, 0, 3); + expect(float64.toString()).toEqual("0,1,2,0,1,2,0,0"); } testEvery() { @@ -83,43 +83,43 @@ export class TFloat64Array { } testFill() { - let float32 = new Float64Array([1, 2, 3]).fill(4); - expect(float32.toString()).toEqual("4,4,4"); + let float64 = new Float64Array([1, 2, 3]).fill(4); + expect(float64.toString()).toEqual("4,4,4"); - float32 = new Float64Array([1, 2, 3]).fill(4, 1); - expect(float32.toString()).toEqual("1,4,4"); + float64 = new Float64Array([1, 2, 3]).fill(4, 1); + expect(float64.toString()).toEqual("1,4,4"); - float32 = new Float64Array([1, 2, 3]).fill(4, 1, 2); - expect(float32.toString()).toEqual("1,4,3"); + float64 = new Float64Array([1, 2, 3]).fill(4, 1, 2); + expect(float64.toString()).toEqual("1,4,3"); - float32 = new Float64Array([1, 2, 3]).fill(4, 1, 1); - expect(float32.toString()).toEqual("1,2,3"); + float64 = new Float64Array([1, 2, 3]).fill(4, 1, 1); + expect(float64.toString()).toEqual("1,2,3"); - float32 = new Float64Array([1, 2, 3]).fill(4, -3, -2); - expect(float32.toString()).toEqual("4,2,3"); + float64 = new Float64Array([1, 2, 3]).fill(4, -3, -2); + expect(float64.toString()).toEqual("4,2,3"); } testFilter() { // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; - let float32 = new Float64Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Float64Array): + let float64 = new Float64Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Float64Array): boolean => value >= 10); - expect(float32.toString()).toEqual("12,44"); + expect(float64.toString()).toEqual("12,44"); } find() { - let float32 = new Float64Array([4, 5, 8, 12]); - let res = float32.find((value: number, _: number, _a: Float64Array): boolean => value > 5); + let float64 = new Float64Array([4, 5, 8, 12]); + let res = float64.find((value: number, _: number, _a: Float64Array): boolean => value > 5); expect(res).toEqual(8); } findIndex() { - let float32 = new Float64Array([4, 6, 8, 12]); - let res = float32.findIndex((value: number, _: number, _a: Float64Array): boolean => value > 100); + let float64 = new Float64Array([4, 6, 8, 12]); + let res = float64.findIndex((value: number, _: number, _a: Float64Array): boolean => value > 100); expect(res).toEqual(-1); - let ufloat32 = new Float64Array([4, 6, 7, 120]); - res = ufloat32.findIndex((value: number, _: number, _a: Float64Array): boolean => value > 100); + let ufloat64 = new Float64Array([4, 6, 7, 120]); + res = ufloat64.findIndex((value: number, _: number, _a: Float64Array): boolean => value > 100); expect(res).toEqual(3); } @@ -137,44 +137,44 @@ export class TFloat64Array { } includes() { - let float32 = new Float64Array([1, 2, 3]); - let res = float32.includes(2); + let float64 = new Float64Array([1, 2, 3]); + let res = float64.includes(2); expect(res).toEqual(true); - res = float32.includes(4); + res = float64.includes(4); expect(res).toEqual(false); - res = float32.includes(3, 3); + res = float64.includes(3, 3); expect(res).toEqual(false); } indexOf() { - let float32 = new Float64Array([2, 5, 9]); - let res = float32.indexOf(2); + let float64 = new Float64Array([2, 5, 9]); + let res = float64.indexOf(2); expect(res).toEqual(0); - res = float32.indexOf(7); + res = float64.indexOf(7); expect(res).toEqual(-1); - res = float32.indexOf(9, 2); + res = float64.indexOf(9, 2); expect(res).toEqual(2); - res = float32.indexOf(2, -1); + res = float64.indexOf(2, -1); expect(res).toEqual(-1); - res = float32.indexOf(2, -3); + res = float64.indexOf(2, -3); expect(res).toEqual(0); } join() { - let float32 = new Float64Array([1, 2, 3]); - let res = float32.join(); + let float64 = new Float64Array([1, 2, 3]); + let res = float64.join(); expect(res).toEqual("1,2,3"); - res = float32.join(" / "); + res = float64.join(" / "); expect(res).toEqual("1 / 2 / 3"); - res = float32.join(""); + res = float64.join(""); expect(res).toEqual("123"); } @@ -221,23 +221,23 @@ export class TFloat64Array { } reverse() { - let float32 = new Float64Array([1, 2, 3]); - float32.reverse(); - expect(float32.toString()).toEqual("3,2,1"); + let float64 = new Float64Array([1, 2, 3]); + float64.reverse(); + expect(float64.toString()).toEqual("3,2,1"); } slice() { - let float32 = new Float64Array([1, 2, 3]); - let res = float32.slice(1); + let float64 = new Float64Array([1, 2, 3]); + let res = float64.slice(1); expect(res.toString()).toEqual("2,3"); - res = float32.slice(2); + res = float64.slice(2); expect(res.toString()).toEqual("3"); - res = float32.slice(-2); + res = float64.slice(-2); expect(res.toString()).toEqual("2,3"); - res = float32.slice(0, 1); + res = float64.slice(0, 1); expect(res.toString()).toEqual("1"); } @@ -252,11 +252,11 @@ export class TFloat64Array { subarray() { let buffer = new ArrayBuffer(32); - let float32 = new Float64Array(buffer); - float32.set([1, 2, 3]); - expect(float32.toString()).toEqual("1,2,3,0"); + let float64 = new Float64Array(buffer); + float64.set([1, 2, 3]); + expect(float64.toString()).toEqual("1,2,3,0"); - let sub = float32.subarray(0, 4); + let sub = float64.subarray(0, 4); expect(sub.toString()).toEqual("1,2,3,0"); } @@ -270,9 +270,9 @@ export class TFloat64Array { arrayBufferSlice() { let buffer = new ArrayBuffer(16); - let float32 = new Float64Array(buffer); - float32[1] = 42; - expect(float32.toString()).toEqual("0,42"); + let float64 = new Float64Array(buffer); + float64[1] = 42; + expect(float64.toString()).toEqual("0,42"); let res = buffer.slice(8); let sliced = new Float64Array(res); diff --git a/uni_modules/uts-tests/utssdk/TInt16Array.uts b/uni_modules/uts-tests/utssdk/TInt16Array.uts index d527a0dc2515ca9ad5bff2740df3d98c985464bc..4b5a7eecf1b4f7c2b217e432b0fc79695279c3d6 100644 --- a/uni_modules/uts-tests/utssdk/TInt16Array.uts +++ b/uni_modules/uts-tests/utssdk/TInt16Array.uts @@ -37,26 +37,26 @@ export class TInt16Array { // #ifdef APP-ANDROID testConstructor() { let buffer = new ArrayBuffer(16); - let float32 = new Int16Array(buffer); - float32[5] = 42; - expect(float32.toString()).toEqual("0,0,0,0,0,42,0,0"); + let int16 = new Int16Array(buffer); + int16[5] = 42; + expect(int16.toString()).toEqual("0,0,0,0,0,42,0,0"); } testSet() { - let float32 = new Int16Array(8); + let int16 = new Int16Array(8); var array = [1, 2, 3] - float32.set(array, 1); - expect(float32.toString()).toEqual("0,1,2,3,0,0,0,0"); + int16.set(array, 1); + expect(int16.toString()).toEqual("0,1,2,3,0,0,0,0"); } testCopyWith() { console.log("testCopyWith 1") - let float32 = new Int16Array(8); - float32.set([1, 2, 3], 1); + let int16 = new Int16Array(8); + int16.set([1, 2, 3], 1); console.log("testCopyWith 1") - float32.copyWithin(3, 0, 3); + int16.copyWithin(3, 0, 3); console.log("testCopyWith 1") - expect(float32.toString()).toEqual("0,1,2,0,1,2,0,0"); + expect(int16.toString()).toEqual("0,1,2,0,1,2,0,0"); } testEvery() { @@ -66,42 +66,42 @@ export class TInt16Array { } testFill() { - let float32 = new Int16Array([1, 2, 3]).fill(4); - expect(float32.toString()).toEqual("4,4,4"); + let int16 = new Int16Array([1, 2, 3]).fill(4); + expect(int16.toString()).toEqual("4,4,4"); - float32 = new Int16Array([1, 2, 3]).fill(4, 1); - expect(float32.toString()).toEqual("1,4,4"); + int16 = new Int16Array([1, 2, 3]).fill(4, 1); + expect(int16.toString()).toEqual("1,4,4"); - float32 = new Int16Array([1, 2, 3]).fill(4, 1, 2); - expect(float32.toString()).toEqual("1,4,3"); + int16 = new Int16Array([1, 2, 3]).fill(4, 1, 2); + expect(int16.toString()).toEqual("1,4,3"); - float32 = new Int16Array([1, 2, 3]).fill(4, 1, 1); - expect(float32.toString()).toEqual("1,2,3"); + int16 = new Int16Array([1, 2, 3]).fill(4, 1, 1); + expect(int16.toString()).toEqual("1,2,3"); - float32 = new Int16Array([1, 2, 3]).fill(4, -3, -2); - expect(float32.toString()).toEqual("4,2,3"); + int16 = new Int16Array([1, 2, 3]).fill(4, -3, -2); + expect(int16.toString()).toEqual("4,2,3"); } testFilter() { // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; - let float32 = new Int16Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Int16Array) : boolean => value >= 10); - expect(float32.toString()).toEqual("12,44"); + let int16 = new Int16Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Int16Array) : boolean => value >= 10); + expect(int16.toString()).toEqual("12,44"); } find() { - let float32 = new Int16Array([4, 5, 8, 12]); - let res = float32.find((value : number, _ : number, _a : Int16Array) : boolean => value > 5); + let int16 = new Int16Array([4, 5, 8, 12]); + let res = int16.find((value : number, _ : number, _a : Int16Array) : boolean => value > 5); expect(res).toEqual(8); } findIndex() { - let float32 = new Int16Array([4, 6, 8, 12]); - let res = float32.findIndex((value : number, _ : number, _a : Int16Array) : boolean => value > 100); + let int16 = new Int16Array([4, 6, 8, 12]); + let res = int16.findIndex((value : number, _ : number, _a : Int16Array) : boolean => value > 100); expect(res).toEqual(-1); - let ufloat32 = new Int16Array([4, 6, 7, 120]); - res = ufloat32.findIndex((value : number, _ : number, _a : Int16Array) : boolean => value > 100); + int16 = new Int16Array([4, 6, 7, 120]); + res = int16.findIndex((value : number, _ : number, _a : Int16Array) : boolean => value > 100); expect(res).toEqual(3); } @@ -118,44 +118,44 @@ export class TInt16Array { } includes() { - let float32 = new Int16Array([1, 2, 3]); - let res = float32.includes(2); + let int16 = new Int16Array([1, 2, 3]); + let res = int16.includes(2); expect(res).toEqual(true); - res = float32.includes(4); + res = int16.includes(4); expect(res).toEqual(false); - res = float32.includes(3, 3); + res = int16.includes(3, 3); expect(res).toEqual(false); } indexOf() { - let float32 = new Int16Array([2, 5, 9]); - let res = float32.indexOf(2); + let int16 = new Int16Array([2, 5, 9]); + let res = int16.indexOf(2); expect(res).toEqual(0); - res = float32.indexOf(7); + res = int16.indexOf(7); expect(res).toEqual(-1); - res = float32.indexOf(9, 2); + res = int16.indexOf(9, 2); expect(res).toEqual(2); - res = float32.indexOf(2, -1); + res = int16.indexOf(2, -1); expect(res).toEqual(-1); - res = float32.indexOf(2, -3); + res = int16.indexOf(2, -3); expect(res).toEqual(0); } join() { - let float32 = new Int16Array([1, 2, 3]); - let res = float32.join(); + let int16 = new Int16Array([1, 2, 3]); + let res = int16.join(); expect(res).toEqual("1,2,3"); - res = float32.join(" / "); + res = int16.join(" / "); expect(res).toEqual("1 / 2 / 3"); - res = float32.join(""); + res = int16.join(""); expect(res).toEqual("123"); } @@ -197,23 +197,23 @@ export class TInt16Array { } reverse() { - let float32 = new Int16Array([1, 2, 3]); - float32.reverse(); - expect(float32.toString()).toEqual("3,2,1"); + let int16 = new Int16Array([1, 2, 3]); + int16.reverse(); + expect(int16.toString()).toEqual("3,2,1"); } slice() { - let float32 = new Int16Array([1, 2, 3]); - let res = float32.slice(1); + let int16 = new Int16Array([1, 2, 3]); + let res = int16.slice(1); expect(res.toString()).toEqual("2,3"); - res = float32.slice(2); + res = int16.slice(2); expect(res.toString()).toEqual("3"); - res = float32.slice(-2); + res = int16.slice(-2); expect(res.toString()).toEqual("2,3"); - res = float32.slice(0, 1); + res = int16.slice(0, 1); expect(res.toString()).toEqual("1"); } @@ -228,11 +228,11 @@ export class TInt16Array { subarray() { let buffer = new ArrayBuffer(16); - let float32 = new Int16Array(buffer); - float32.set([1, 2, 3]); - expect(float32.toString()).toEqual("1,2,3,0,0,0,0,0"); + let int16 = new Int16Array(buffer); + int16.set([1, 2, 3]); + expect(int16.toString()).toEqual("1,2,3,0,0,0,0,0"); - let sub = float32.subarray(0, 4); + let sub = int16.subarray(0, 4); expect(sub.toString()).toEqual("1,2,3,0"); } @@ -244,9 +244,9 @@ export class TInt16Array { arrayBufferSlice() { let buffer = new ArrayBuffer(16); - let float32 = new Int16Array(buffer); - float32[4] = 42; - expect(float32.toString()).toEqual("0,0,0,0,42,0,0,0"); + let int16 = new Int16Array(buffer); + int16[4] = 42; + expect(int16.toString()).toEqual("0,0,0,0,42,0,0,0"); let res = buffer.slice(8, 12); let sliced = new Int16Array(res); diff --git a/uni_modules/uts-tests/utssdk/TInt32Array.uts b/uni_modules/uts-tests/utssdk/TInt32Array.uts index c837b5d4f951b54e8c034e7106f3ea48ded599c7..2ff4c3aa51b2e91922de8f60844c288b3089b1fa 100644 --- a/uni_modules/uts-tests/utssdk/TInt32Array.uts +++ b/uni_modules/uts-tests/utssdk/TInt32Array.uts @@ -8,7 +8,7 @@ import { export class TInt32Array { test() { // #ifdef APP-ANDROID - this.testfloat32(); + this.testInt32Array(); this.testConstructor(); this.testSet(); this.testCopyWith(); @@ -36,11 +36,11 @@ export class TInt32Array { } // #ifdef APP-ANDROID - testfloat32() { - let float32 = new Int32Array(2); - float32[0] = 42; - expect(float32[0]).toEqual(42); - expect(float32.length).toEqual(2); + testInt32Array() { + let int32 = new Int32Array(2); + int32[0] = 42; + expect(int32[0]).toEqual(42); + expect(int32.length).toEqual(2); expect(Int32Array.BYTES_PER_ELEMENT).toEqual(4); let x = new Int32Array([21, 31, 3]); @@ -57,26 +57,26 @@ export class TInt32Array { testConstructor() { let buffer = new ArrayBuffer(16); - let float32 = new Int32Array(buffer); - float32[1] = 42; - expect(float32.toString()).toEqual("0,42,0,0"); + let int32 = new Int32Array(buffer); + int32[1] = 42; + expect(int32.toString()).toEqual("0,42,0,0"); } testSet() { - let float32 = new Int32Array(8); + let int32 = new Int32Array(8); var array =[1, 2, 3] - float32.set(array, 1); - expect(float32.toString()).toEqual("0,1,2,3,0,0,0,0"); + int32.set(array, 1); + expect(int32.toString()).toEqual("0,1,2,3,0,0,0,0"); } testCopyWith() { console.log("testCopyWith 1") - let float32 = new Int32Array(8); - float32.set([1, 2, 3], 1); + let int32 = new Int32Array(8); + int32.set([1, 2, 3], 1); console.log("testCopyWith 1") - float32.copyWithin(3, 0, 3); + int32.copyWithin(3, 0, 3); console.log("testCopyWith 1") - expect(float32.toString()).toEqual("0,1,2,0,1,2,0,0"); + expect(int32.toString()).toEqual("0,1,2,0,1,2,0,0"); } testEvery() { @@ -86,42 +86,42 @@ export class TInt32Array { } testFill() { - let float32 = new Int32Array([1, 2, 3]).fill(4); - expect(float32.toString()).toEqual("4,4,4"); + let int32 = new Int32Array([1, 2, 3]).fill(4); + expect(int32.toString()).toEqual("4,4,4"); - float32 = new Int32Array([1, 2, 3]).fill(4, 1); - expect(float32.toString()).toEqual("1,4,4"); + int32 = new Int32Array([1, 2, 3]).fill(4, 1); + expect(int32.toString()).toEqual("1,4,4"); - float32 = new Int32Array([1, 2, 3]).fill(4, 1, 2); - expect(float32.toString()).toEqual("1,4,3"); + int32 = new Int32Array([1, 2, 3]).fill(4, 1, 2); + expect(int32.toString()).toEqual("1,4,3"); - float32 = new Int32Array([1, 2, 3]).fill(4, 1, 1); - expect(float32.toString()).toEqual("1,2,3"); + int32 = new Int32Array([1, 2, 3]).fill(4, 1, 1); + expect(int32.toString()).toEqual("1,2,3"); - float32 = new Int32Array([1, 2, 3]).fill(4, -3, -2); - expect(float32.toString()).toEqual("4,2,3"); + int32 = new Int32Array([1, 2, 3]).fill(4, -3, -2); + expect(int32.toString()).toEqual("4,2,3"); } testFilter() { // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; - let float32 = new Int32Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Int32Array): boolean => value>= 10); - expect(float32.toString()).toEqual("12,44"); + let int32 = new Int32Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Int32Array): boolean => value>= 10); + expect(int32.toString()).toEqual("12,44"); } find() { - let float32 = new Int32Array([4, 5, 8, 12]); - let res = float32.find((value : number, _ : number, _a : Int32Array): boolean => value > 5); + let int32 = new Int32Array([4, 5, 8, 12]); + let res = int32.find((value : number, _ : number, _a : Int32Array): boolean => value > 5); expect(res).toEqual(8); } findIndex() { - let float32 = new Int32Array([4, 6, 8, 12]); - let res = float32.findIndex((value : number, _ : number, _a : Int32Array): boolean => value > 100); + let int32 = new Int32Array([4, 6, 8, 12]); + let res = int32.findIndex((value : number, _ : number, _a : Int32Array): boolean => value > 100); expect(res).toEqual(-1); - let ufloat32 = new Int32Array([4, 6, 7, 120]); - res = ufloat32.findIndex((value : number, _ : number, _a : Int32Array): boolean => value > 100); + int32 = new Int32Array([4, 6, 7, 120]); + res = int32.findIndex((value : number, _ : number, _a : Int32Array): boolean => value > 100); expect(res).toEqual(3); } @@ -139,44 +139,44 @@ export class TInt32Array { } includes() { - let float32 = new Int32Array([1, 2, 3]); - let res = float32.includes(2); + let int32 = new Int32Array([1, 2, 3]); + let res = int32.includes(2); expect(res).toEqual(true); - res = float32.includes(4); + res = int32.includes(4); expect(res).toEqual(false); - res = float32.includes(3, 3); + res = int32.includes(3, 3); expect(res).toEqual(false); } indexOf() { - let float32 = new Int32Array([2, 5, 9]); - let res = float32.indexOf(2); + let int32 = new Int32Array([2, 5, 9]); + let res = int32.indexOf(2); expect(res).toEqual(0); - res = float32.indexOf(7); + res = int32.indexOf(7); expect(res).toEqual(-1); - res = float32.indexOf(9, 2); + res = int32.indexOf(9, 2); expect(res).toEqual(2); - res = float32.indexOf(2, -1); + res = int32.indexOf(2, -1); expect(res).toEqual(-1); - res = float32.indexOf(2, -3); + res = int32.indexOf(2, -3); expect(res).toEqual(0); } join() { - let float32 = new Int32Array([1, 2, 3]); - let res = float32.join(); + let int32 = new Int32Array([1, 2, 3]); + let res = int32.join(); expect(res).toEqual("1,2,3"); - res = float32.join(" / "); + res = int32.join(" / "); expect(res).toEqual("1 / 2 / 3"); - res = float32.join(""); + res = int32.join(""); expect(res).toEqual("123"); } @@ -214,23 +214,23 @@ export class TInt32Array { } reverse() { - let float32 = new Int32Array([1, 2, 3]); - float32.reverse(); - expect(float32.toString()).toEqual("3,2,1"); + let int32 = new Int32Array([1, 2, 3]); + int32.reverse(); + expect(int32.toString()).toEqual("3,2,1"); } slice() { - let float32 = new Int32Array([1, 2, 3]); - let res = float32.slice(1); + let int32 = new Int32Array([1, 2, 3]); + let res = int32.slice(1); expect(res.toString()).toEqual("2,3"); - res = float32.slice(2); + res = int32.slice(2); expect(res.toString()).toEqual("3"); - res = float32.slice(-2); + res = int32.slice(-2); expect(res.toString()).toEqual("2,3"); - res = float32.slice(0, 1); + res = int32.slice(0, 1); expect(res.toString()).toEqual("1"); } @@ -245,11 +245,11 @@ export class TInt32Array { subarray() { let buffer = new ArrayBuffer(16); - let float32 = new Int32Array(buffer); - float32.set([1, 2, 3]); - expect(float32.toString()).toEqual("1,2,3,0"); + let int32 = new Int32Array(buffer); + int32.set([1, 2, 3]); + expect(int32.toString()).toEqual("1,2,3,0"); - let sub = float32.subarray(0, 4); + let sub = int32.subarray(0, 4); expect(sub.toString()).toEqual("1,2,3,0"); } @@ -261,9 +261,9 @@ export class TInt32Array { arrayBufferSlice() { let buffer = new ArrayBuffer(16); - let float32 = new Int32Array(buffer); - float32[3] = 42; - expect(float32.toString()).toEqual("0,0,0,42"); + let int32 = new Int32Array(buffer); + int32[3] = 42; + expect(int32.toString()).toEqual("0,0,0,42"); let res = buffer.slice(8); let sliced = new Int32Array(res); diff --git a/uni_modules/uts-tests/utssdk/TInt8Array.uts b/uni_modules/uts-tests/utssdk/TInt8Array.uts index 76f6c4472f07045a37f2c9ea5b29a3718741a74d..7e074fcaf0b8bd531ee99d832a8a7b395f901025 100644 --- a/uni_modules/uts-tests/utssdk/TInt8Array.uts +++ b/uni_modules/uts-tests/utssdk/TInt8Array.uts @@ -44,20 +44,20 @@ export class TInt8Array { } testSet() { - let float32 = new Int8Array(8); + let int8 = new Int8Array(8); var array = [1, 2, 3] - float32.set(array, 1); - expect(float32.toString()).toEqual("0,1,2,3,0,0,0,0"); + int8.set(array, 1); + expect(int8.toString()).toEqual("0,1,2,3,0,0,0,0"); } testCopyWith() { console.log("testCopyWith 1") - let float32 = new Int8Array(8); - float32.set([1, 2, 3], 1); + let int8 = new Int8Array(8); + int8.set([1, 2, 3], 1); console.log("testCopyWith 1") - float32.copyWithin(3, 0, 3); + int8.copyWithin(3, 0, 3); console.log("testCopyWith 1") - expect(float32.toString()).toEqual("0,1,2,0,1,2,0,0"); + expect(int8.toString()).toEqual("0,1,2,0,1,2,0,0"); } testEvery() { @@ -68,43 +68,43 @@ export class TInt8Array { } testFill() { - let float32 = new Int8Array([1, 2, 3]).fill(4); - expect(float32.toString()).toEqual("4,4,4"); + let int8 = new Int8Array([1, 2, 3]).fill(4); + expect(int8.toString()).toEqual("4,4,4"); - float32 = new Int8Array([1, 2, 3]).fill(4, 1); - expect(float32.toString()).toEqual("1,4,4"); + int8 = new Int8Array([1, 2, 3]).fill(4, 1); + expect(int8.toString()).toEqual("1,4,4"); - float32 = new Int8Array([1, 2, 3]).fill(4, 1, 2); - expect(float32.toString()).toEqual("1,4,3"); + int8 = new Int8Array([1, 2, 3]).fill(4, 1, 2); + expect(int8.toString()).toEqual("1,4,3"); - float32 = new Int8Array([1, 2, 3]).fill(4, 1, 1); - expect(float32.toString()).toEqual("1,2,3"); + int8 = new Int8Array([1, 2, 3]).fill(4, 1, 1); + expect(int8.toString()).toEqual("1,2,3"); - float32 = new Int8Array([1, 2, 3]).fill(4, -3, -2); - expect(float32.toString()).toEqual("4,2,3"); + int8 = new Int8Array([1, 2, 3]).fill(4, -3, -2); + expect(int8.toString()).toEqual("4,2,3"); } testFilter() { // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; - let float32 = new Int8Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Int8Array): boolean => + let int8 = new Int8Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Int8Array): boolean => value >= 10); - expect(float32.toString()).toEqual("12,44"); + expect(int8.toString()).toEqual("12,44"); } find() { - let float32 = new Int8Array([4, 5, 8, 12]); - let res = float32.find((value: number, _: number, _a: Int8Array): boolean => value > 5); + let int8 = new Int8Array([4, 5, 8, 12]); + let res = int8.find((value: number, _: number, _a: Int8Array): boolean => value > 5); expect(res).toEqual(8); } findIndex() { - let float32 = new Int8Array([4, 6, 8, 12]); - let res = float32.findIndex((value: number, _: number, _a: Int8Array): boolean => value > 100); + let int8 = new Int8Array([4, 6, 8, 12]); + let res = int8.findIndex((value: number, _: number, _a: Int8Array): boolean => value > 100); expect(res).toEqual(-1); - let ufloat32 = new Int8Array([4, 6, 7, 120]); - res = ufloat32.findIndex((value: number, _: number, _a: Int8Array): boolean => value > 100); + int8 = new Int8Array([4, 6, 7, 120]); + res = int8.findIndex((value: number, _: number, _a: Int8Array): boolean => value > 100); expect(res).toEqual(3); } @@ -122,44 +122,44 @@ export class TInt8Array { } includes() { - let float32 = new Int8Array([1, 2, 3]); - let res = float32.includes(2); + let int8 = new Int8Array([1, 2, 3]); + let res = int8.includes(2); expect(res).toEqual(true); - res = float32.includes(4); + res = int8.includes(4); expect(res).toEqual(false); - res = float32.includes(3, 3); + res = int8.includes(3, 3); expect(res).toEqual(false); } indexOf() { - let float32 = new Int8Array([2, 5, 9]); - let res = float32.indexOf(2); + let int8 = new Int8Array([2, 5, 9]); + let res = int8.indexOf(2); expect(res).toEqual(0); - res = float32.indexOf(7); + res = int8.indexOf(7); expect(res).toEqual(-1); - res = float32.indexOf(9, 2); + res = int8.indexOf(9, 2); expect(res).toEqual(2); - res = float32.indexOf(2, -1); + res = int8.indexOf(2, -1); expect(res).toEqual(-1); - res = float32.indexOf(2, -3); + res = int8.indexOf(2, -3); expect(res).toEqual(0); } join() { - let float32 = new Int8Array([1, 2, 3]); - let res = float32.join(); + let int8 = new Int8Array([1, 2, 3]); + let res = int8.join(); expect(res).toEqual("1,2,3"); - res = float32.join(" / "); + res = int8.join(" / "); expect(res).toEqual("1 / 2 / 3"); - res = float32.join(""); + res = int8.join(""); expect(res).toEqual("123"); } @@ -206,23 +206,23 @@ export class TInt8Array { } reverse() { - let float32 = new Int8Array([1, 2, 3]); - float32.reverse(); - expect(float32.toString()).toEqual("3,2,1"); + let int8 = new Int8Array([1, 2, 3]); + int8.reverse(); + expect(int8.toString()).toEqual("3,2,1"); } slice() { - let float32 = new Int8Array([1, 2, 3]); - let res = float32.slice(1); + let int8 = new Int8Array([1, 2, 3]); + let res = int8.slice(1); expect(res.toString()).toEqual("2,3"); - res = float32.slice(2); + res = int8.slice(2); expect(res.toString()).toEqual("3"); - res = float32.slice(-2); + res = int8.slice(-2); expect(res.toString()).toEqual("2,3"); - res = float32.slice(0, 1); + res = int8.slice(0, 1); expect(res.toString()).toEqual("1"); } @@ -237,11 +237,11 @@ export class TInt8Array { subarray() { let buffer = new ArrayBuffer(8); - let float32 = new Int8Array(buffer); - float32.set([1, 2, 3]); - expect(float32.toString()).toEqual("1,2,3,0,0,0,0,0"); + let int8 = new Int8Array(buffer); + int8.set([1, 2, 3]); + expect(int8.toString()).toEqual("1,2,3,0,0,0,0,0"); - let sub = float32.subarray(0, 4); + let sub = int8.subarray(0, 4); expect(sub.toString()).toEqual("1,2,3,0"); } @@ -255,9 +255,9 @@ export class TInt8Array { arrayBufferSlice() { let buffer = new ArrayBuffer(16); - let float32 = new Int8Array(buffer); - float32[4] = 42; - expect(float32.toString()).toEqual("0,0,0,0,42,0,0,0,0,0,0,0,0,0,0,0"); + let int8 = new Int8Array(buffer); + int8[4] = 42; + expect(int8.toString()).toEqual("0,0,0,0,42,0,0,0,0,0,0,0,0,0,0,0"); let res = buffer.slice(4, 12); let sliced = new Int8Array(res); diff --git a/uni_modules/uts-tests/utssdk/TUInt8Array.uts b/uni_modules/uts-tests/utssdk/TUInt8Array.uts index 41a24440daac569bcc74677461795c69fe514040..c989a5a2d8c33b59648e7647acbcd325989e10a4 100644 --- a/uni_modules/uts-tests/utssdk/TUInt8Array.uts +++ b/uni_modules/uts-tests/utssdk/TUInt8Array.uts @@ -42,32 +42,32 @@ export class TUint8Array { console.log(unit8.toString()) } testMAX() { - let float32 = new Uint8Array(16); - float32[0] = 255; - expect(float32[0]).toEqual(255); + let uint8 = new Uint8Array(16); + uint8[0] = 255; + expect(uint8[0]).toEqual(255); } testConstructor() { let buffer = new ArrayBuffer(16); - let float32 = new Uint8Array(buffer); - float32[5] = 42; - expect(float32.toString()).toEqual("0,0,0,0,0,42,0,0,0,0,0,0,0,0,0,0"); + let uint8 = new Uint8Array(buffer); + uint8[5] = 42; + expect(uint8.toString()).toEqual("0,0,0,0,0,42,0,0,0,0,0,0,0,0,0,0"); } testSet() { - let float32 = new Uint8Array(8); + let uint8 = new Uint8Array(8); var array = [1, 2, 3] - float32.set(array, 1); - expect(float32.toString()).toEqual("0,1,2,3,0,0,0,0"); + uint8.set(array, 1); + expect(uint8.toString()).toEqual("0,1,2,3,0,0,0,0"); } testCopyWith() { console.log("testCopyWith 1") - let float32 = new Uint8Array(8); - float32.set([1, 2, 3], 1); - float32.copyWithin(3, 0, 3); + let uint8 = new Uint8Array(8); + uint8.set([1, 2, 3], 1); + uint8.copyWithin(3, 0, 3); - expect(float32.toString()).toEqual("0,1,2,0,1,2,0,0"); + expect(uint8.toString()).toEqual("0,1,2,0,1,2,0,0"); } testEvery() { @@ -78,43 +78,43 @@ export class TUint8Array { } testFill() { - let float32 = new Uint8Array([1, 2, 3]).fill(4); - expect(float32.toString()).toEqual("4,4,4"); + let uint8 = new Uint8Array([1, 2, 3]).fill(4); + expect(uint8.toString()).toEqual("4,4,4"); - float32 = new Uint8Array([1, 2, 3]).fill(4, 1); - expect(float32.toString()).toEqual("1,4,4"); + uint8 = new Uint8Array([1, 2, 3]).fill(4, 1); + expect(uint8.toString()).toEqual("1,4,4"); - float32 = new Uint8Array([1, 2, 3]).fill(4, 1, 2); - expect(float32.toString()).toEqual("1,4,3"); + uint8 = new Uint8Array([1, 2, 3]).fill(4, 1, 2); + expect(uint8.toString()).toEqual("1,4,3"); - float32 = new Uint8Array([1, 2, 3]).fill(4, 1, 1); - expect(float32.toString()).toEqual("1,2,3"); + uint8 = new Uint8Array([1, 2, 3]).fill(4, 1, 1); + expect(uint8.toString()).toEqual("1,2,3"); - float32 = new Uint8Array([1, 2, 3]).fill(4, -3, -2); - expect(float32.toString()).toEqual("4,2,3"); + uint8 = new Uint8Array([1, 2, 3]).fill(4, -3, -2); + expect(uint8.toString()).toEqual("4,2,3"); } testFilter() { // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; - let float32 = new Uint8Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint8Array): boolean => value >= + let uint8 = new Uint8Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint8Array): boolean => value >= 10); - expect(float32.toString()).toEqual("12,44"); + expect(uint8.toString()).toEqual("12,44"); } find() { - let float32 = new Uint8Array([4, 5, 8, 12]); - let res = float32.find((value: number, _: number, _a: Uint8Array): boolean => value > 5); + let uint8 = new Uint8Array([4, 5, 8, 12]); + let res = uint8.find((value: number, _: number, _a: Uint8Array): boolean => value > 5); expect(res).toEqual(8); } findIndex() { - let float32 = new Uint8Array([4, 6, 8, 12]); - let res = float32.findIndex((value: number, _: number, _a: Uint8Array): boolean => value > 100); + let uint8 = new Uint8Array([4, 6, 8, 12]); + let res = uint8.findIndex((value: number, _: number, _a: Uint8Array): boolean => value > 100); expect(res).toEqual(-1); - let ufloat32 = new Uint8Array([4, 6, 7, 120]); - res = ufloat32.findIndex((value: number, _: number, _a: Uint8Array): boolean => value > 100); + let uuint8 = new Uint8Array([4, 6, 7, 120]); + res = uuint8.findIndex((value: number, _: number, _a: Uint8Array): boolean => value > 100); expect(res).toEqual(3); } @@ -132,44 +132,44 @@ export class TUint8Array { } includes() { - let float32 = new Uint8Array([1, 2, 3]); - let res = float32.includes(2); + let uint8 = new Uint8Array([1, 2, 3]); + let res = uint8.includes(2); expect(res).toEqual(true); - res = float32.includes(4); + res = uint8.includes(4); expect(res).toEqual(false); - res = float32.includes(3, 3); + res = uint8.includes(3, 3); expect(res).toEqual(false); } indexOf() { - let float32 = new Uint8Array([2, 5, 9]); - let res = float32.indexOf(2); + let uint8 = new Uint8Array([2, 5, 9]); + let res = uint8.indexOf(2); expect(res).toEqual(0); - res = float32.indexOf(7); + res = uint8.indexOf(7); expect(res).toEqual(-1); - res = float32.indexOf(9, 2); + res = uint8.indexOf(9, 2); expect(res).toEqual(2); - res = float32.indexOf(2, -1); + res = uint8.indexOf(2, -1); expect(res).toEqual(-1); - res = float32.indexOf(2, -3); + res = uint8.indexOf(2, -3); expect(res).toEqual(0); } join() { - let float32 = new Uint8Array([1, 2, 3]); - let res = float32.join(); + let uint8 = new Uint8Array([1, 2, 3]); + let res = uint8.join(); expect(res).toEqual("1,2,3"); - res = float32.join(" / "); + res = uint8.join(" / "); expect(res).toEqual("1 / 2 / 3"); - res = float32.join(""); + res = uint8.join(""); expect(res).toEqual("123"); } @@ -211,23 +211,23 @@ export class TUint8Array { } reverse() { - let float32 = new Uint8Array([1, 2, 3]); - float32.reverse(); - expect(float32.toString()).toEqual("3,2,1"); + let uint8 = new Uint8Array([1, 2, 3]); + uint8.reverse(); + expect(uint8.toString()).toEqual("3,2,1"); } slice() { - let float32 = new Uint8Array([1, 2, 3]); - let res = float32.slice(1); + let uint8 = new Uint8Array([1, 2, 3]); + let res = uint8.slice(1); expect(res.toString()).toEqual("2,3"); - res = float32.slice(2); + res = uint8.slice(2); expect(res.toString()).toEqual("3"); - res = float32.slice(-2); + res = uint8.slice(-2); expect(res.toString()).toEqual("2,3"); - res = float32.slice(0, 1); + res = uint8.slice(0, 1); expect(res.toString()).toEqual("1"); } @@ -242,11 +242,11 @@ export class TUint8Array { subarray() { let buffer = new ArrayBuffer(16); - let float32 = new Uint8Array(buffer); - float32.set([1, 2, 3]); - expect(float32.toString()).toEqual("1,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0"); + let uint8 = new Uint8Array(buffer); + uint8.set([1, 2, 3]); + expect(uint8.toString()).toEqual("1,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0"); - let sub = float32.subarray(0, 4); + let sub = uint8.subarray(0, 4); expect(sub.toString()).toEqual("1,2,3,0"); } @@ -259,9 +259,9 @@ export class TUint8Array { arrayBufferSlice() { let buffer = new ArrayBuffer(16); - let float32 = new Uint8Array(buffer); - float32[4] = 42; - expect(float32.toString()).toEqual("0,0,0,0,42,0,0,0,0,0,0,0,0,0,0,0"); + let uint8 = new Uint8Array(buffer); + uint8[4] = 42; + expect(uint8.toString()).toEqual("0,0,0,0,42,0,0,0,0,0,0,0,0,0,0,0"); let res = buffer.slice(4, 12); let sliced = new Uint8Array(res); diff --git a/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts b/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts index 6eb8fcac66f34322525515ac5a8c16f59a720057..eab65bf8760cd8b6b87ba9f6d8f5d24839036b27 100644 --- a/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts +++ b/uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts @@ -37,32 +37,32 @@ export class TUint8ClampedArray { // #ifdef APP-ANDROID testMAX() { - let float32 = new Uint8ClampedArray(16); - float32[0] = 255; - expect(float32[0]).toEqual(255); + let uint8Clamped = new Uint8ClampedArray(16); + uint8Clamped[0] = 255; + expect(uint8Clamped[0]).toEqual(255); } testConstructor() { let buffer = new ArrayBuffer(16); - let float32 = new Uint8ClampedArray(buffer); - float32[5] = 42; - expect(float32.toString()).toEqual("0,0,0,0,0,42,0,0,0,0,0,0,0,0,0,0"); + let uint8Clamped = new Uint8ClampedArray(buffer); + uint8Clamped[5] = 42; + expect(uint8Clamped.toString()).toEqual("0,0,0,0,0,42,0,0,0,0,0,0,0,0,0,0"); } testSet() { - let float32 = new Uint8ClampedArray(8); + let uint8Clamped = new Uint8ClampedArray(8); var array = [1, 2, 3] - float32.set(array, 1); - expect(float32.toString()).toEqual("0,1,2,3,0,0,0,0"); + uint8Clamped.set(array, 1); + expect(uint8Clamped.toString()).toEqual("0,1,2,3,0,0,0,0"); } testCopyWith() { console.log("testCopyWith 1") - let float32 = new Uint8ClampedArray(8); - float32.set([1, 2, 3], 1); - float32.copyWithin(3, 0, 3); + let uint8Clamped = new Uint8ClampedArray(8); + uint8Clamped.set([1, 2, 3], 1); + uint8Clamped.copyWithin(3, 0, 3); - expect(float32.toString()).toEqual("0,1,2,0,1,2,0,0"); + expect(uint8Clamped.toString()).toEqual("0,1,2,0,1,2,0,0"); } testEvery() { @@ -73,43 +73,43 @@ export class TUint8ClampedArray { } testFill() { - let float32 = new Uint8ClampedArray([1, 2, 3]).fill(4); - expect(float32.toString()).toEqual("4,4,4"); + let uint8Clamped = new Uint8ClampedArray([1, 2, 3]).fill(4); + expect(uint8Clamped.toString()).toEqual("4,4,4"); - float32 = new Uint8ClampedArray([1, 2, 3]).fill(4, 1); - expect(float32.toString()).toEqual("1,4,4"); + uint8Clamped = new Uint8ClampedArray([1, 2, 3]).fill(4, 1); + expect(uint8Clamped.toString()).toEqual("1,4,4"); - float32 = new Uint8ClampedArray([1, 2, 3]).fill(4, 1, 2); - expect(float32.toString()).toEqual("1,4,3"); + uint8Clamped = new Uint8ClampedArray([1, 2, 3]).fill(4, 1, 2); + expect(uint8Clamped.toString()).toEqual("1,4,3"); - float32 = new Uint8ClampedArray([1, 2, 3]).fill(4, 1, 1); - expect(float32.toString()).toEqual("1,2,3"); + uint8Clamped = new Uint8ClampedArray([1, 2, 3]).fill(4, 1, 1); + expect(uint8Clamped.toString()).toEqual("1,2,3"); - float32 = new Uint8ClampedArray([1, 2, 3]).fill(4, -3, -2); - expect(float32.toString()).toEqual("4,2,3"); + uint8Clamped = new Uint8ClampedArray([1, 2, 3]).fill(4, -3, -2); + expect(uint8Clamped.toString()).toEqual("4,2,3"); } testFilter() { // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; - let float32 = new Uint8ClampedArray([12, 5, 8, 44]).filter((value: number, _: number, _a: + let uint8Clamped = new Uint8ClampedArray([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint8ClampedArray): boolean => value >= 10); - expect(float32.toString()).toEqual("12,44"); + expect(uint8Clamped.toString()).toEqual("12,44"); } find() { - let float32 = new Uint8ClampedArray([4, 5, 8, 12]); - let res = float32.find((value: number, _: number, _a: Uint8ClampedArray): boolean => value > 5); + let uint8Clamped = new Uint8ClampedArray([4, 5, 8, 12]); + let res = uint8Clamped.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, _a: Uint8ClampedArray): boolean => value > 100); + let uint8Clamped = new Uint8ClampedArray([4, 6, 8, 12]); + let res = uint8Clamped.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, _a: Uint8ClampedArray): boolean => value > 100); + let uuint8Clamped = new Uint8ClampedArray([4, 6, 7, 120]); + res = uuint8Clamped.findIndex((value: number, _: number, _a: Uint8ClampedArray): boolean => value > 100); expect(res).toEqual(3); } @@ -127,44 +127,44 @@ export class TUint8ClampedArray { } includes() { - let float32 = new Uint8ClampedArray([1, 2, 3]); - let res = float32.includes(2); + let uint8Clamped = new Uint8ClampedArray([1, 2, 3]); + let res = uint8Clamped.includes(2); expect(res).toEqual(true); - res = float32.includes(4); + res = uint8Clamped.includes(4); expect(res).toEqual(false); - res = float32.includes(3, 3); + res = uint8Clamped.includes(3, 3); expect(res).toEqual(false); } indexOf() { - let float32 = new Uint8ClampedArray([2, 5, 9]); - let res = float32.indexOf(2); + let uint8Clamped = new Uint8ClampedArray([2, 5, 9]); + let res = uint8Clamped.indexOf(2); expect(res).toEqual(0); - res = float32.indexOf(7); + res = uint8Clamped.indexOf(7); expect(res).toEqual(-1); - res = float32.indexOf(9, 2); + res = uint8Clamped.indexOf(9, 2); expect(res).toEqual(2); - res = float32.indexOf(2, -1); + res = uint8Clamped.indexOf(2, -1); expect(res).toEqual(-1); - res = float32.indexOf(2, -3); + res = uint8Clamped.indexOf(2, -3); expect(res).toEqual(0); } join() { - let float32 = new Uint8ClampedArray([1, 2, 3]); - let res = float32.join(); + let uint8Clamped = new Uint8ClampedArray([1, 2, 3]); + let res = uint8Clamped.join(); expect(res).toEqual("1,2,3"); - res = float32.join(" / "); + res = uint8Clamped.join(" / "); expect(res).toEqual("1 / 2 / 3"); - res = float32.join(""); + res = uint8Clamped.join(""); expect(res).toEqual("123"); } @@ -206,23 +206,23 @@ export class TUint8ClampedArray { } reverse() { - let float32 = new Uint8ClampedArray([1, 2, 3]); - float32.reverse(); - expect(float32.toString()).toEqual("3,2,1"); + let uint8Clamped = new Uint8ClampedArray([1, 2, 3]); + uint8Clamped.reverse(); + expect(uint8Clamped.toString()).toEqual("3,2,1"); } slice() { - let float32 = new Uint8ClampedArray([1, 2, 3]); - let res = float32.slice(1); + let uint8Clamped = new Uint8ClampedArray([1, 2, 3]); + let res = uint8Clamped.slice(1); expect(res.toString()).toEqual("2,3"); - res = float32.slice(2); + res = uint8Clamped.slice(2); expect(res.toString()).toEqual("3"); - res = float32.slice(-2); + res = uint8Clamped.slice(-2); expect(res.toString()).toEqual("2,3"); - res = float32.slice(0, 1); + res = uint8Clamped.slice(0, 1); expect(res.toString()).toEqual("1"); } @@ -237,11 +237,11 @@ export class TUint8ClampedArray { subarray() { let buffer = new ArrayBuffer(16); - let float32 = new Uint8ClampedArray(buffer); - float32.set([1, 2, 3]); - expect(float32.toString()).toEqual("1,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0"); + let uint8Clamped = new Uint8ClampedArray(buffer); + uint8Clamped.set([1, 2, 3]); + expect(uint8Clamped.toString()).toEqual("1,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0"); - let sub = float32.subarray(0, 4); + let sub = uint8Clamped.subarray(0, 4); expect(sub.toString()).toEqual("1,2,3,0"); } @@ -254,9 +254,9 @@ export class TUint8ClampedArray { arrayBufferSlice() { let buffer = new ArrayBuffer(16); - let float32 = new Uint8ClampedArray(buffer); - float32[4] = 42; - expect(float32.toString()).toEqual("0,0,0,0,42,0,0,0,0,0,0,0,0,0,0,0"); + let uint8Clamped = new Uint8ClampedArray(buffer); + uint8Clamped[4] = 42; + expect(uint8Clamped.toString()).toEqual("0,0,0,0,42,0,0,0,0,0,0,0,0,0,0,0"); let res = buffer.slice(4, 12); let sliced = new Uint8ClampedArray(res); diff --git a/uni_modules/uts-tests/utssdk/TUint16Array.uts b/uni_modules/uts-tests/utssdk/TUint16Array.uts index efd82537b30b8a16b13171f373c471aa6798abe6..7be38bba76f7a260c568db70c75eaa9aca71ab2c 100644 --- a/uni_modules/uts-tests/utssdk/TUint16Array.uts +++ b/uni_modules/uts-tests/utssdk/TUint16Array.uts @@ -8,7 +8,7 @@ import { export class TUint16Array { test() { // #ifdef APP-ANDROID - this.testfloat32(); + this.testuint16(); this.testConstructor(); this.testSet(); this.testCopyWith(); @@ -36,11 +36,11 @@ export class TUint16Array { } // #ifdef APP-ANDROID - testfloat32() { - let float32 = new Uint16Array(2); - float32[0] = 42; - expect(float32[0]).toEqual(42); - expect(float32.length).toEqual(2); + testuint16() { + let uint16 = new Uint16Array(2); + uint16[0] = 42; + expect(uint16[0]).toEqual(42); + expect(uint16.length).toEqual(2); expect(Uint16Array.BYTES_PER_ELEMENT).toEqual(4); let x = new Uint16Array([21, 31, 3]); @@ -57,26 +57,26 @@ export class TUint16Array { testConstructor() { let buffer = new ArrayBuffer(16); - let float32 = new Uint16Array(buffer); - float32[1] = 42; - expect(float32.toString()).toEqual("0,42,0,0,0,0,0,0"); + let uint16 = new Uint16Array(buffer); + uint16[1] = 42; + expect(uint16.toString()).toEqual("0,42,0,0,0,0,0,0"); } testSet() { - let float32 = new Uint16Array(8); + let uint16 = new Uint16Array(8); var array = [1, 2, 3] - float32.set(array, 1); - expect(float32.toString()).toEqual("0,1,2,3,0,0,0,0"); + uint16.set(array, 1); + expect(uint16.toString()).toEqual("0,1,2,3,0,0,0,0"); } testCopyWith() { console.log("testCopyWith 1") - let float32 = new Uint16Array(8); - float32.set([1, 2, 3], 1); + let uint16 = new Uint16Array(8); + uint16.set([1, 2, 3], 1); console.log("testCopyWith 1") - float32.copyWithin(3, 0, 3); + uint16.copyWithin(3, 0, 3); console.log("testCopyWith 1") - expect(float32.toString()).toEqual("0,1,2,0,1,2,0,0"); + expect(uint16.toString()).toEqual("0,1,2,0,1,2,0,0"); } testEvery() { @@ -87,43 +87,43 @@ export class TUint16Array { } testFill() { - let float32 = new Uint16Array([1, 2, 3]).fill(4); - expect(float32.toString()).toEqual("4,4,4"); + let uint16 = new Uint16Array([1, 2, 3]).fill(4); + expect(uint16.toString()).toEqual("4,4,4"); - float32 = new Uint16Array([1, 2, 3]).fill(4, 1); - expect(float32.toString()).toEqual("1,4,4"); + uint16 = new Uint16Array([1, 2, 3]).fill(4, 1); + expect(uint16.toString()).toEqual("1,4,4"); - float32 = new Uint16Array([1, 2, 3]).fill(4, 1, 2); - expect(float32.toString()).toEqual("1,4,3"); + uint16 = new Uint16Array([1, 2, 3]).fill(4, 1, 2); + expect(uint16.toString()).toEqual("1,4,3"); - float32 = new Uint16Array([1, 2, 3]).fill(4, 1, 1); - expect(float32.toString()).toEqual("1,2,3"); + uint16 = new Uint16Array([1, 2, 3]).fill(4, 1, 1); + expect(uint16.toString()).toEqual("1,2,3"); - float32 = new Uint16Array([1, 2, 3]).fill(4, -3, -2); - expect(float32.toString()).toEqual("4,2,3"); + uint16 = new Uint16Array([1, 2, 3]).fill(4, -3, -2); + expect(uint16.toString()).toEqual("4,2,3"); } testFilter() { // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; - let float32 = new Uint16Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint16Array): + let uint16 = new Uint16Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint16Array): boolean => value >= 10); - expect(float32.toString()).toEqual("12,44"); + expect(uint16.toString()).toEqual("12,44"); } find() { - let float32 = new Uint16Array([4, 5, 8, 12]); - let res = float32.find((value: number, _: number, _a: Uint16Array): boolean => value > 5); + let uint16 = new Uint16Array([4, 5, 8, 12]); + let res = uint16.find((value: number, _: number, _a: Uint16Array): boolean => value > 5); expect(res).toEqual(8); } findIndex() { - let float32 = new Uint16Array([4, 6, 8, 12]); - let res = float32.findIndex((value: number, _: number, _a: Uint16Array): boolean => value > 100); + let uint16 = new Uint16Array([4, 6, 8, 12]); + let res = uint16.findIndex((value: number, _: number, _a: Uint16Array): boolean => value > 100); expect(res).toEqual(-1); - let ufloat32 = new Uint16Array([4, 6, 7, 120]); - res = ufloat32.findIndex((value: number, _: number, _a: Uint16Array): boolean => value > 100); + let uuint16 = new Uint16Array([4, 6, 7, 120]); + res = uuint16.findIndex((value: number, _: number, _a: Uint16Array): boolean => value > 100); expect(res).toEqual(3); } @@ -141,44 +141,44 @@ export class TUint16Array { } includes() { - let float32 = new Uint16Array([1, 2, 3]); - let res = float32.includes(2); + let uint16 = new Uint16Array([1, 2, 3]); + let res = uint16.includes(2); expect(res).toEqual(true); - res = float32.includes(4); + res = uint16.includes(4); expect(res).toEqual(false); - res = float32.includes(3, 3); + res = uint16.includes(3, 3); expect(res).toEqual(false); } indexOf() { - let float32 = new Uint16Array([2, 5, 9]); - let res = float32.indexOf(2); + let uint16 = new Uint16Array([2, 5, 9]); + let res = uint16.indexOf(2); expect(res).toEqual(0); - res = float32.indexOf(7); + res = uint16.indexOf(7); expect(res).toEqual(-1); - res = float32.indexOf(9, 2); + res = uint16.indexOf(9, 2); expect(res).toEqual(2); - res = float32.indexOf(2, -1); + res = uint16.indexOf(2, -1); expect(res).toEqual(-1); - res = float32.indexOf(2, -3); + res = uint16.indexOf(2, -3); expect(res).toEqual(0); } join() { - let float32 = new Uint16Array([1, 2, 3]); - let res = float32.join(); + let uint16 = new Uint16Array([1, 2, 3]); + let res = uint16.join(); expect(res).toEqual("1,2,3"); - res = float32.join(" / "); + res = uint16.join(" / "); expect(res).toEqual("1 / 2 / 3"); - res = float32.join(""); + res = uint16.join(""); expect(res).toEqual("123"); } @@ -220,23 +220,23 @@ export class TUint16Array { } reverse() { - let float32 = new Uint16Array([1, 2, 3]); - float32.reverse(); - expect(float32.toString()).toEqual("3,2,1"); + let uint16 = new Uint16Array([1, 2, 3]); + uint16.reverse(); + expect(uint16.toString()).toEqual("3,2,1"); } slice() { - let float32 = new Uint16Array([1, 2, 3]); - let res = float32.slice(1); + let uint16 = new Uint16Array([1, 2, 3]); + let res = uint16.slice(1); expect(res.toString()).toEqual("2,3"); - res = float32.slice(2); + res = uint16.slice(2); expect(res.toString()).toEqual("3"); - res = float32.slice(-2); + res = uint16.slice(-2); expect(res.toString()).toEqual("2,3"); - res = float32.slice(0, 1); + res = uint16.slice(0, 1); expect(res.toString()).toEqual("1"); } @@ -251,11 +251,11 @@ export class TUint16Array { subarray() { let buffer = new ArrayBuffer(16); - let float32 = new Uint16Array(buffer); - float32.set([1, 2, 3]); - expect(float32.toString()).toEqual("1,2,3,0,0,0,0,0"); + let uint16 = new Uint16Array(buffer); + uint16.set([1, 2, 3]); + expect(uint16.toString()).toEqual("1,2,3,0,0,0,0,0"); - let sub = float32.subarray(0, 4); + let sub = uint16.subarray(0, 4); expect(sub.toString()).toEqual("1,2,3,0"); } @@ -268,9 +268,9 @@ export class TUint16Array { arrayBufferSlice() { let buffer = new ArrayBuffer(16); - let float32 = new Uint16Array(buffer); - float32[4] = 42; - expect(float32.toString()).toEqual("0,0,0,0,42,0,0,0"); + let uint16 = new Uint16Array(buffer); + uint16[4] = 42; + expect(uint16.toString()).toEqual("0,0,0,0,42,0,0,0"); let res = buffer.slice(8); let sliced = new Uint16Array(res); diff --git a/uni_modules/uts-tests/utssdk/TUint32Array.uts b/uni_modules/uts-tests/utssdk/TUint32Array.uts index a1716b3b6afccfc470e956b66836bac7947b71dd..752278036a0489fccaee33546b14712b5b7f136b 100644 --- a/uni_modules/uts-tests/utssdk/TUint32Array.uts +++ b/uni_modules/uts-tests/utssdk/TUint32Array.uts @@ -8,7 +8,7 @@ import { export class TUint32Array { test() { // #ifdef APP-ANDROID - this.testfloat32(); + this.testuint32(); this.testConstructor(); this.testSet(); this.testCopyWith(); @@ -36,11 +36,11 @@ export class TUint32Array { } // #ifdef APP-ANDROID - testfloat32() { - let float32 = new Uint32Array(2); - float32[0] = 42; - expect(float32[0]).toEqual(42); - expect(float32.length).toEqual(2); + testuint32() { + let uint32 = new Uint32Array(2); + uint32[0] = 42; + expect(uint32[0]).toEqual(42); + expect(uint32.length).toEqual(2); expect(Uint32Array.BYTES_PER_ELEMENT).toEqual(4); let x = new Uint32Array([21, 31, 3]); @@ -57,26 +57,26 @@ export class TUint32Array { testConstructor() { let buffer = new ArrayBuffer(16); - let float32 = new Uint32Array(buffer); - float32[1] = 42; - expect(float32.toString()).toEqual("0,42,0,0"); + let uint32 = new Uint32Array(buffer); + uint32[1] = 42; + expect(uint32.toString()).toEqual("0,42,0,0"); } testSet() { - let float32 = new Uint32Array(8); + let uint32 = new Uint32Array(8); var array = [1, 2, 3] - float32.set(array, 1); - expect(float32.toString()).toEqual("0,1,2,3,0,0,0,0"); + uint32.set(array, 1); + expect(uint32.toString()).toEqual("0,1,2,3,0,0,0,0"); } testCopyWith() { console.log("testCopyWith 1") - let float32 = new Uint32Array(8); - float32.set([1, 2, 3], 1); + let uint32 = new Uint32Array(8); + uint32.set([1, 2, 3], 1); console.log("testCopyWith 1") - float32.copyWithin(3, 0, 3); + uint32.copyWithin(3, 0, 3); console.log("testCopyWith 1") - expect(float32.toString()).toEqual("0,1,2,0,1,2,0,0"); + expect(uint32.toString()).toEqual("0,1,2,0,1,2,0,0"); } testEvery() { @@ -87,43 +87,43 @@ export class TUint32Array { } testFill() { - let float32 = new Uint32Array([1, 2, 3]).fill(4); - expect(float32.toString()).toEqual("4,4,4"); + let uint32 = new Uint32Array([1, 2, 3]).fill(4); + expect(uint32.toString()).toEqual("4,4,4"); - float32 = new Uint32Array([1, 2, 3]).fill(4, 1); - expect(float32.toString()).toEqual("1,4,4"); + uint32 = new Uint32Array([1, 2, 3]).fill(4, 1); + expect(uint32.toString()).toEqual("1,4,4"); - float32 = new Uint32Array([1, 2, 3]).fill(4, 1, 2); - expect(float32.toString()).toEqual("1,4,3"); + uint32 = new Uint32Array([1, 2, 3]).fill(4, 1, 2); + expect(uint32.toString()).toEqual("1,4,3"); - float32 = new Uint32Array([1, 2, 3]).fill(4, 1, 1); - expect(float32.toString()).toEqual("1,2,3"); + uint32 = new Uint32Array([1, 2, 3]).fill(4, 1, 1); + expect(uint32.toString()).toEqual("1,2,3"); - float32 = new Uint32Array([1, 2, 3]).fill(4, -3, -2); - expect(float32.toString()).toEqual("4,2,3"); + uint32 = new Uint32Array([1, 2, 3]).fill(4, -3, -2); + expect(uint32.toString()).toEqual("4,2,3"); } testFilter() { // const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10; - let float32 = new Uint32Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint32Array): + let uint32 = new Uint32Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint32Array): boolean => value >= 10); - expect(float32.toString()).toEqual("12,44"); + expect(uint32.toString()).toEqual("12,44"); } find() { - let float32 = new Uint32Array([4, 5, 8, 12]); - let res = float32.find((value: number, _: number, _a: Uint32Array): boolean => value > 5); + let uint32 = new Uint32Array([4, 5, 8, 12]); + let res = uint32.find((value: number, _: number, _a: Uint32Array): boolean => value > 5); expect(res).toEqual(8); } findIndex() { - let float32 = new Uint32Array([4, 6, 8, 12]); - let res = float32.findIndex((value: number, _: number, _a: Uint32Array): boolean => value > 100); + let uint32 = new Uint32Array([4, 6, 8, 12]); + let res = uint32.findIndex((value: number, _: number, _a: Uint32Array): boolean => value > 100); expect(res).toEqual(-1); - let ufloat32 = new Uint32Array([4, 6, 7, 120]); - res = ufloat32.findIndex((value: number, _: number, _a: Uint32Array): boolean => value > 100); + let uuint32 = new Uint32Array([4, 6, 7, 120]); + res = uuint32.findIndex((value: number, _: number, _a: Uint32Array): boolean => value > 100); expect(res).toEqual(3); } @@ -141,44 +141,44 @@ export class TUint32Array { } includes() { - let float32 = new Uint32Array([1, 2, 3]); - let res = float32.includes(2); + let uint32 = new Uint32Array([1, 2, 3]); + let res = uint32.includes(2); expect(res).toEqual(true); - res = float32.includes(4); + res = uint32.includes(4); expect(res).toEqual(false); - res = float32.includes(3, 3); + res = uint32.includes(3, 3); expect(res).toEqual(false); } indexOf() { - let float32 = new Uint32Array([2, 5, 9]); - let res = float32.indexOf(2); + let uint32 = new Uint32Array([2, 5, 9]); + let res = uint32.indexOf(2); expect(res).toEqual(0); - res = float32.indexOf(7); + res = uint32.indexOf(7); expect(res).toEqual(-1); - res = float32.indexOf(9, 2); + res = uint32.indexOf(9, 2); expect(res).toEqual(2); - res = float32.indexOf(2, -1); + res = uint32.indexOf(2, -1); expect(res).toEqual(-1); - res = float32.indexOf(2, -3); + res = uint32.indexOf(2, -3); expect(res).toEqual(0); } join() { - let float32 = new Uint32Array([1, 2, 3]); - let res = float32.join(); + let uint32 = new Uint32Array([1, 2, 3]); + let res = uint32.join(); expect(res).toEqual("1,2,3"); - res = float32.join(" / "); + res = uint32.join(" / "); expect(res).toEqual("1 / 2 / 3"); - res = float32.join(""); + res = uint32.join(""); expect(res).toEqual("123"); } @@ -220,23 +220,23 @@ export class TUint32Array { } reverse() { - let float32 = new Uint32Array([1, 2, 3]); - float32.reverse(); - expect(float32.toString()).toEqual("3,2,1"); + let uint32 = new Uint32Array([1, 2, 3]); + uint32.reverse(); + expect(uint32.toString()).toEqual("3,2,1"); } slice() { - let float32 = new Uint32Array([1, 2, 3]); - let res = float32.slice(1); + let uint32 = new Uint32Array([1, 2, 3]); + let res = uint32.slice(1); expect(res.toString()).toEqual("2,3"); - res = float32.slice(2); + res = uint32.slice(2); expect(res.toString()).toEqual("3"); - res = float32.slice(-2); + res = uint32.slice(-2); expect(res.toString()).toEqual("2,3"); - res = float32.slice(0, 1); + res = uint32.slice(0, 1); expect(res.toString()).toEqual("1"); } @@ -251,11 +251,11 @@ export class TUint32Array { subarray() { let buffer = new ArrayBuffer(16); - let float32 = new Uint32Array(buffer); - float32.set([1, 2, 3]); - expect(float32.toString()).toEqual("1,2,3,0"); + let uint32 = new Uint32Array(buffer); + uint32.set([1, 2, 3]); + expect(uint32.toString()).toEqual("1,2,3,0"); - let sub = float32.subarray(0, 4); + let sub = uint32.subarray(0, 4); expect(sub.toString()).toEqual("1,2,3,0"); } @@ -268,9 +268,9 @@ export class TUint32Array { arrayBufferSlice() { let buffer = new ArrayBuffer(16); - let float32 = new Uint32Array(buffer); - float32[3] = 42; - expect(float32.toString()).toEqual("0,0,0,42"); + let uint32 = new Uint32Array(buffer); + uint32[3] = 42; + expect(uint32.toString()).toEqual("0,0,0,42"); let res = buffer.slice(8); let sliced = new Uint32Array(res);