Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
cc739400
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1604
Star
27
Fork
9
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
Hello UTS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
cc739400
编写于
7月 11, 2024
作者:
M
mahaifeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[array-buffer]修改命名
上级
06b730fd
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
498 addition
and
498 deletion
+498
-498
uni_modules/uts-tests/utssdk/TFloat32Array.uts
uni_modules/uts-tests/utssdk/TFloat32Array.uts
+17
-17
uni_modules/uts-tests/utssdk/TFloat64Array.uts
uni_modules/uts-tests/utssdk/TFloat64Array.uts
+61
-61
uni_modules/uts-tests/utssdk/TInt16Array.uts
uni_modules/uts-tests/utssdk/TInt16Array.uts
+57
-57
uni_modules/uts-tests/utssdk/TInt32Array.uts
uni_modules/uts-tests/utssdk/TInt32Array.uts
+63
-63
uni_modules/uts-tests/utssdk/TInt8Array.uts
uni_modules/uts-tests/utssdk/TInt8Array.uts
+54
-54
uni_modules/uts-tests/utssdk/TUInt8Array.uts
uni_modules/uts-tests/utssdk/TUInt8Array.uts
+60
-60
uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts
uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts
+60
-60
uni_modules/uts-tests/utssdk/TUint16Array.uts
uni_modules/uts-tests/utssdk/TUint16Array.uts
+63
-63
uni_modules/uts-tests/utssdk/TUint32Array.uts
uni_modules/uts-tests/utssdk/TUint32Array.uts
+63
-63
未找到文件。
uni_modules/uts-tests/utssdk/TFloat32Array.uts
浏览文件 @
cc739400
...
...
@@ -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");
}
...
...
uni_modules/uts-tests/utssdk/TFloat64Array.uts
浏览文件 @
cc739400
...
...
@@ -36,10 +36,10 @@ export class TFloat64Array {
}
// #ifdef APP-ANDROID
testfloat64() {
let float
32
= new Float64Array(2);
float
32
[0] = 42;
expect(float
32
[0]).toEqual(42);
expect(float
32
.length).toEqual(2);
let float
64
= new Float64Array(2);
float
64
[0] = 42;
expect(float
64
[0]).toEqual(42);
expect(float
64
.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 float
32
= new Float64Array(buffer);
float
32
[1] = 42;
expect(float
32
.toString()).toEqual("0,42");
let float
64
= new Float64Array(buffer);
float
64
[1] = 42;
expect(float
64
.toString()).toEqual("0,42");
}
testSet() {
let float
32
= new Float64Array(8);
let float
64
= new Float64Array(8);
var array = [1, 2, 3]
float
32
.set(array, 1);
expect(float
32
.toString()).toEqual("0,1,2,3,0,0,0,0");
float
64
.set(array, 1);
expect(float
64
.toString()).toEqual("0,1,2,3,0,0,0,0");
}
testCopyWith() {
let float
32
= new Float64Array(8);
float
32
.set([1, 2, 3], 1);
float
32
.copyWithin(3, 0, 3);
expect(float
32
.toString()).toEqual("0,1,2,0,1,2,0,0");
let float
64
= new Float64Array(8);
float
64
.set([1, 2, 3], 1);
float
64
.copyWithin(3, 0, 3);
expect(float
64
.toString()).toEqual("0,1,2,0,1,2,0,0");
}
testEvery() {
...
...
@@ -83,43 +83,43 @@ export class TFloat64Array {
}
testFill() {
let float
32
= new Float64Array([1, 2, 3]).fill(4);
expect(float
32
.toString()).toEqual("4,4,4");
let float
64
= new Float64Array([1, 2, 3]).fill(4);
expect(float
64
.toString()).toEqual("4,4,4");
float
32
= new Float64Array([1, 2, 3]).fill(4, 1);
expect(float
32
.toString()).toEqual("1,4,4");
float
64
= new Float64Array([1, 2, 3]).fill(4, 1);
expect(float
64
.toString()).toEqual("1,4,4");
float
32
= new Float64Array([1, 2, 3]).fill(4, 1, 2);
expect(float
32
.toString()).toEqual("1,4,3");
float
64
= new Float64Array([1, 2, 3]).fill(4, 1, 2);
expect(float
64
.toString()).toEqual("1,4,3");
float
32
= new Float64Array([1, 2, 3]).fill(4, 1, 1);
expect(float
32
.toString()).toEqual("1,2,3");
float
64
= new Float64Array([1, 2, 3]).fill(4, 1, 1);
expect(float
64
.toString()).toEqual("1,2,3");
float
32
= new Float64Array([1, 2, 3]).fill(4, -3, -2);
expect(float
32
.toString()).toEqual("4,2,3");
float
64
= new Float64Array([1, 2, 3]).fill(4, -3, -2);
expect(float
64
.toString()).toEqual("4,2,3");
}
testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let float
32
= new Float64Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Float64Array):
let float
64
= new Float64Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Float64Array):
boolean => value >= 10);
expect(float
32
.toString()).toEqual("12,44");
expect(float
64
.toString()).toEqual("12,44");
}
find() {
let float
32
= new Float64Array([4, 5, 8, 12]);
let res = float
32
.find((value: number, _: number, _a: Float64Array): boolean => value > 5);
let float
64
= new Float64Array([4, 5, 8, 12]);
let res = float
64
.find((value: number, _: number, _a: Float64Array): boolean => value > 5);
expect(res).toEqual(8);
}
findIndex() {
let float
32
= new Float64Array([4, 6, 8, 12]);
let res = float
32
.findIndex((value: number, _: number, _a: Float64Array): boolean => value > 100);
let float
64
= new Float64Array([4, 6, 8, 12]);
let res = float
64
.findIndex((value: number, _: number, _a: Float64Array): boolean => value > 100);
expect(res).toEqual(-1);
let ufloat
32
= new Float64Array([4, 6, 7, 120]);
res = ufloat
32
.findIndex((value: number, _: number, _a: Float64Array): boolean => value > 100);
let ufloat
64
= new Float64Array([4, 6, 7, 120]);
res = ufloat
64
.findIndex((value: number, _: number, _a: Float64Array): boolean => value > 100);
expect(res).toEqual(3);
}
...
...
@@ -137,44 +137,44 @@ export class TFloat64Array {
}
includes() {
let float
32
= new Float64Array([1, 2, 3]);
let res = float
32
.includes(2);
let float
64
= new Float64Array([1, 2, 3]);
let res = float
64
.includes(2);
expect(res).toEqual(true);
res = float
32
.includes(4);
res = float
64
.includes(4);
expect(res).toEqual(false);
res = float
32
.includes(3, 3);
res = float
64
.includes(3, 3);
expect(res).toEqual(false);
}
indexOf() {
let float
32
= new Float64Array([2, 5, 9]);
let res = float
32
.indexOf(2);
let float
64
= new Float64Array([2, 5, 9]);
let res = float
64
.indexOf(2);
expect(res).toEqual(0);
res = float
32
.indexOf(7);
res = float
64
.indexOf(7);
expect(res).toEqual(-1);
res = float
32
.indexOf(9, 2);
res = float
64
.indexOf(9, 2);
expect(res).toEqual(2);
res = float
32
.indexOf(2, -1);
res = float
64
.indexOf(2, -1);
expect(res).toEqual(-1);
res = float
32
.indexOf(2, -3);
res = float
64
.indexOf(2, -3);
expect(res).toEqual(0);
}
join() {
let float
32
= new Float64Array([1, 2, 3]);
let res = float
32
.join();
let float
64
= new Float64Array([1, 2, 3]);
let res = float
64
.join();
expect(res).toEqual("1,2,3");
res = float
32
.join(" / ");
res = float
64
.join(" / ");
expect(res).toEqual("1 / 2 / 3");
res = float
32
.join("");
res = float
64
.join("");
expect(res).toEqual("123");
}
...
...
@@ -221,23 +221,23 @@ export class TFloat64Array {
}
reverse() {
let float
32
= new Float64Array([1, 2, 3]);
float
32
.reverse();
expect(float
32
.toString()).toEqual("3,2,1");
let float
64
= new Float64Array([1, 2, 3]);
float
64
.reverse();
expect(float
64
.toString()).toEqual("3,2,1");
}
slice() {
let float
32
= new Float64Array([1, 2, 3]);
let res = float
32
.slice(1);
let float
64
= new Float64Array([1, 2, 3]);
let res = float
64
.slice(1);
expect(res.toString()).toEqual("2,3");
res = float
32
.slice(2);
res = float
64
.slice(2);
expect(res.toString()).toEqual("3");
res = float
32
.slice(-2);
res = float
64
.slice(-2);
expect(res.toString()).toEqual("2,3");
res = float
32
.slice(0, 1);
res = float
64
.slice(0, 1);
expect(res.toString()).toEqual("1");
}
...
...
@@ -252,11 +252,11 @@ export class TFloat64Array {
subarray() {
let buffer = new ArrayBuffer(32);
let float
32
= new Float64Array(buffer);
float
32
.set([1, 2, 3]);
expect(float
32
.toString()).toEqual("1,2,3,0");
let float
64
= new Float64Array(buffer);
float
64
.set([1, 2, 3]);
expect(float
64
.toString()).toEqual("1,2,3,0");
let sub = float
32
.subarray(0, 4);
let sub = float
64
.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 float
32
= new Float64Array(buffer);
float
32
[1] = 42;
expect(float
32
.toString()).toEqual("0,42");
let float
64
= new Float64Array(buffer);
float
64
[1] = 42;
expect(float
64
.toString()).toEqual("0,42");
let res = buffer.slice(8);
let sliced = new Float64Array(res);
...
...
uni_modules/uts-tests/utssdk/TInt16Array.uts
浏览文件 @
cc739400
...
...
@@ -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);
...
...
uni_modules/uts-tests/utssdk/TInt32Array.uts
浏览文件 @
cc739400
...
...
@@ -8,7 +8,7 @@ import {
export class TInt32Array {
test() {
// #ifdef APP-ANDROID
this.test
float32
();
this.test
Int32Array
();
this.testConstructor();
this.testSet();
this.testCopyWith();
...
...
@@ -36,11 +36,11 @@ export class TInt32Array {
}
// #ifdef APP-ANDROID
test
float32
() {
let
floa
t32 = new Int32Array(2);
floa
t32[0] = 42;
expect(
floa
t32[0]).toEqual(42);
expect(
floa
t32.length).toEqual(2);
test
Int32Array
() {
let
in
t32 = new Int32Array(2);
in
t32[0] = 42;
expect(
in
t32[0]).toEqual(42);
expect(
in
t32.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
floa
t32 = new Int32Array(buffer);
floa
t32[1] = 42;
expect(
floa
t32.toString()).toEqual("0,42,0,0");
let
in
t32 = new Int32Array(buffer);
in
t32[1] = 42;
expect(
in
t32.toString()).toEqual("0,42,0,0");
}
testSet() {
let
floa
t32 = new Int32Array(8);
let
in
t32 = new Int32Array(8);
var array =[1, 2, 3]
floa
t32.set(array, 1);
expect(
floa
t32.toString()).toEqual("0,1,2,3,0,0,0,0");
in
t32.set(array, 1);
expect(
in
t32.toString()).toEqual("0,1,2,3,0,0,0,0");
}
testCopyWith() {
console.log("testCopyWith 1")
let
floa
t32 = new Int32Array(8);
floa
t32.set([1, 2, 3], 1);
let
in
t32 = new Int32Array(8);
in
t32.set([1, 2, 3], 1);
console.log("testCopyWith 1")
floa
t32.copyWithin(3, 0, 3);
in
t32.copyWithin(3, 0, 3);
console.log("testCopyWith 1")
expect(
floa
t32.toString()).toEqual("0,1,2,0,1,2,0,0");
expect(
in
t32.toString()).toEqual("0,1,2,0,1,2,0,0");
}
testEvery() {
...
...
@@ -86,42 +86,42 @@ export class TInt32Array {
}
testFill() {
let
floa
t32 = new Int32Array([1, 2, 3]).fill(4);
expect(
floa
t32.toString()).toEqual("4,4,4");
let
in
t32 = new Int32Array([1, 2, 3]).fill(4);
expect(
in
t32.toString()).toEqual("4,4,4");
floa
t32 = new Int32Array([1, 2, 3]).fill(4, 1);
expect(
floa
t32.toString()).toEqual("1,4,4");
in
t32 = new Int32Array([1, 2, 3]).fill(4, 1);
expect(
in
t32.toString()).toEqual("1,4,4");
floa
t32 = new Int32Array([1, 2, 3]).fill(4, 1, 2);
expect(
floa
t32.toString()).toEqual("1,4,3");
in
t32 = new Int32Array([1, 2, 3]).fill(4, 1, 2);
expect(
in
t32.toString()).toEqual("1,4,3");
floa
t32 = new Int32Array([1, 2, 3]).fill(4, 1, 1);
expect(
floa
t32.toString()).toEqual("1,2,3");
in
t32 = new Int32Array([1, 2, 3]).fill(4, 1, 1);
expect(
in
t32.toString()).toEqual("1,2,3");
floa
t32 = new Int32Array([1, 2, 3]).fill(4, -3, -2);
expect(
floa
t32.toString()).toEqual("4,2,3");
in
t32 = new Int32Array([1, 2, 3]).fill(4, -3, -2);
expect(
in
t32.toString()).toEqual("4,2,3");
}
testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let
floa
t32 = new Int32Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Int32Array): boolean => value>= 10);
expect(
floa
t32.toString()).toEqual("12,44");
let
in
t32 = new Int32Array([12, 5, 8, 44]).filter((value : number, _ : number, _a : Int32Array): boolean => value>= 10);
expect(
in
t32.toString()).toEqual("12,44");
}
find() {
let
floa
t32 = new Int32Array([4, 5, 8, 12]);
let res =
floa
t32.find((value : number, _ : number, _a : Int32Array): boolean => value > 5);
let
in
t32 = new Int32Array([4, 5, 8, 12]);
let res =
in
t32.find((value : number, _ : number, _a : Int32Array): boolean => value > 5);
expect(res).toEqual(8);
}
findIndex() {
let
floa
t32 = new Int32Array([4, 6, 8, 12]);
let res =
floa
t32.findIndex((value : number, _ : number, _a : Int32Array): boolean => value > 100);
let
in
t32 = new Int32Array([4, 6, 8, 12]);
let res =
in
t32.findIndex((value : number, _ : number, _a : Int32Array): boolean => value > 100);
expect(res).toEqual(-1);
let ufloa
t32 = new Int32Array([4, 6, 7, 120]);
res =
ufloa
t32.findIndex((value : number, _ : number, _a : Int32Array): boolean => value > 100);
in
t32 = new Int32Array([4, 6, 7, 120]);
res =
in
t32.findIndex((value : number, _ : number, _a : Int32Array): boolean => value > 100);
expect(res).toEqual(3);
}
...
...
@@ -139,44 +139,44 @@ export class TInt32Array {
}
includes() {
let
floa
t32 = new Int32Array([1, 2, 3]);
let res =
floa
t32.includes(2);
let
in
t32 = new Int32Array([1, 2, 3]);
let res =
in
t32.includes(2);
expect(res).toEqual(true);
res =
floa
t32.includes(4);
res =
in
t32.includes(4);
expect(res).toEqual(false);
res =
floa
t32.includes(3, 3);
res =
in
t32.includes(3, 3);
expect(res).toEqual(false);
}
indexOf() {
let
floa
t32 = new Int32Array([2, 5, 9]);
let res =
floa
t32.indexOf(2);
let
in
t32 = new Int32Array([2, 5, 9]);
let res =
in
t32.indexOf(2);
expect(res).toEqual(0);
res =
floa
t32.indexOf(7);
res =
in
t32.indexOf(7);
expect(res).toEqual(-1);
res =
floa
t32.indexOf(9, 2);
res =
in
t32.indexOf(9, 2);
expect(res).toEqual(2);
res =
floa
t32.indexOf(2, -1);
res =
in
t32.indexOf(2, -1);
expect(res).toEqual(-1);
res =
floa
t32.indexOf(2, -3);
res =
in
t32.indexOf(2, -3);
expect(res).toEqual(0);
}
join() {
let
floa
t32 = new Int32Array([1, 2, 3]);
let res =
floa
t32.join();
let
in
t32 = new Int32Array([1, 2, 3]);
let res =
in
t32.join();
expect(res).toEqual("1,2,3");
res =
floa
t32.join(" / ");
res =
in
t32.join(" / ");
expect(res).toEqual("1 / 2 / 3");
res =
floa
t32.join("");
res =
in
t32.join("");
expect(res).toEqual("123");
}
...
...
@@ -214,23 +214,23 @@ export class TInt32Array {
}
reverse() {
let
floa
t32 = new Int32Array([1, 2, 3]);
floa
t32.reverse();
expect(
floa
t32.toString()).toEqual("3,2,1");
let
in
t32 = new Int32Array([1, 2, 3]);
in
t32.reverse();
expect(
in
t32.toString()).toEqual("3,2,1");
}
slice() {
let
floa
t32 = new Int32Array([1, 2, 3]);
let res =
floa
t32.slice(1);
let
in
t32 = new Int32Array([1, 2, 3]);
let res =
in
t32.slice(1);
expect(res.toString()).toEqual("2,3");
res =
floa
t32.slice(2);
res =
in
t32.slice(2);
expect(res.toString()).toEqual("3");
res =
floa
t32.slice(-2);
res =
in
t32.slice(-2);
expect(res.toString()).toEqual("2,3");
res =
floa
t32.slice(0, 1);
res =
in
t32.slice(0, 1);
expect(res.toString()).toEqual("1");
}
...
...
@@ -245,11 +245,11 @@ export class TInt32Array {
subarray() {
let buffer = new ArrayBuffer(16);
let
floa
t32 = new Int32Array(buffer);
floa
t32.set([1, 2, 3]);
expect(
floa
t32.toString()).toEqual("1,2,3,0");
let
in
t32 = new Int32Array(buffer);
in
t32.set([1, 2, 3]);
expect(
in
t32.toString()).toEqual("1,2,3,0");
let sub =
floa
t32.subarray(0, 4);
let sub =
in
t32.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
floa
t32 = new Int32Array(buffer);
floa
t32[3] = 42;
expect(
floa
t32.toString()).toEqual("0,0,0,42");
let
in
t32 = new Int32Array(buffer);
in
t32[3] = 42;
expect(
in
t32.toString()).toEqual("0,0,0,42");
let res = buffer.slice(8);
let sliced = new Int32Array(res);
...
...
uni_modules/uts-tests/utssdk/TInt8Array.uts
浏览文件 @
cc739400
...
...
@@ -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);
...
...
uni_modules/uts-tests/utssdk/TUInt8Array.uts
浏览文件 @
cc739400
...
...
@@ -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 u
float32
= new Uint8Array([4, 6, 7, 120]);
res = u
float32
.findIndex((value: number, _: number, _a: Uint8Array): boolean => value > 100);
let u
uint8
= new Uint8Array([4, 6, 7, 120]);
res = u
uint8
.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);
...
...
uni_modules/uts-tests/utssdk/TUInt8ClampedArray.uts
浏览文件 @
cc739400
...
...
@@ -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 u
float32
= new Uint8ClampedArray([4, 6, 7, 120]);
res = u
float32
.findIndex((value: number, _: number, _a: Uint8ClampedArray): boolean => value > 100);
let u
uint8Clamped
= new Uint8ClampedArray([4, 6, 7, 120]);
res = u
uint8Clamped
.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);
...
...
uni_modules/uts-tests/utssdk/TUint16Array.uts
浏览文件 @
cc739400
...
...
@@ -8,7 +8,7 @@ import {
export class TUint16Array {
test() {
// #ifdef APP-ANDROID
this.test
float32
();
this.test
uint16
();
this.testConstructor();
this.testSet();
this.testCopyWith();
...
...
@@ -36,11 +36,11 @@ export class TUint16Array {
}
// #ifdef APP-ANDROID
test
float32
() {
let
float32
= new Uint16Array(2);
float32
[0] = 42;
expect(
float32
[0]).toEqual(42);
expect(
float32
.length).toEqual(2);
test
uint16
() {
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 u
float32
= new Uint16Array([4, 6, 7, 120]);
res = u
float32
.findIndex((value: number, _: number, _a: Uint16Array): boolean => value > 100);
let u
uint16
= new Uint16Array([4, 6, 7, 120]);
res = u
uint16
.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);
...
...
uni_modules/uts-tests/utssdk/TUint32Array.uts
浏览文件 @
cc739400
...
...
@@ -8,7 +8,7 @@ import {
export class TUint32Array {
test() {
// #ifdef APP-ANDROID
this.test
floa
t32();
this.test
uin
t32();
this.testConstructor();
this.testSet();
this.testCopyWith();
...
...
@@ -36,11 +36,11 @@ export class TUint32Array {
}
// #ifdef APP-ANDROID
test
floa
t32() {
let
floa
t32 = new Uint32Array(2);
floa
t32[0] = 42;
expect(
floa
t32[0]).toEqual(42);
expect(
floa
t32.length).toEqual(2);
test
uin
t32() {
let
uin
t32 = new Uint32Array(2);
uin
t32[0] = 42;
expect(
uin
t32[0]).toEqual(42);
expect(
uin
t32.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
floa
t32 = new Uint32Array(buffer);
floa
t32[1] = 42;
expect(
floa
t32.toString()).toEqual("0,42,0,0");
let
uin
t32 = new Uint32Array(buffer);
uin
t32[1] = 42;
expect(
uin
t32.toString()).toEqual("0,42,0,0");
}
testSet() {
let
floa
t32 = new Uint32Array(8);
let
uin
t32 = new Uint32Array(8);
var array = [1, 2, 3]
floa
t32.set(array, 1);
expect(
floa
t32.toString()).toEqual("0,1,2,3,0,0,0,0");
uin
t32.set(array, 1);
expect(
uin
t32.toString()).toEqual("0,1,2,3,0,0,0,0");
}
testCopyWith() {
console.log("testCopyWith 1")
let
floa
t32 = new Uint32Array(8);
floa
t32.set([1, 2, 3], 1);
let
uin
t32 = new Uint32Array(8);
uin
t32.set([1, 2, 3], 1);
console.log("testCopyWith 1")
floa
t32.copyWithin(3, 0, 3);
uin
t32.copyWithin(3, 0, 3);
console.log("testCopyWith 1")
expect(
floa
t32.toString()).toEqual("0,1,2,0,1,2,0,0");
expect(
uin
t32.toString()).toEqual("0,1,2,0,1,2,0,0");
}
testEvery() {
...
...
@@ -87,43 +87,43 @@ export class TUint32Array {
}
testFill() {
let
floa
t32 = new Uint32Array([1, 2, 3]).fill(4);
expect(
floa
t32.toString()).toEqual("4,4,4");
let
uin
t32 = new Uint32Array([1, 2, 3]).fill(4);
expect(
uin
t32.toString()).toEqual("4,4,4");
floa
t32 = new Uint32Array([1, 2, 3]).fill(4, 1);
expect(
floa
t32.toString()).toEqual("1,4,4");
uin
t32 = new Uint32Array([1, 2, 3]).fill(4, 1);
expect(
uin
t32.toString()).toEqual("1,4,4");
floa
t32 = new Uint32Array([1, 2, 3]).fill(4, 1, 2);
expect(
floa
t32.toString()).toEqual("1,4,3");
uin
t32 = new Uint32Array([1, 2, 3]).fill(4, 1, 2);
expect(
uin
t32.toString()).toEqual("1,4,3");
floa
t32 = new Uint32Array([1, 2, 3]).fill(4, 1, 1);
expect(
floa
t32.toString()).toEqual("1,2,3");
uin
t32 = new Uint32Array([1, 2, 3]).fill(4, 1, 1);
expect(
uin
t32.toString()).toEqual("1,2,3");
floa
t32 = new Uint32Array([1, 2, 3]).fill(4, -3, -2);
expect(
floa
t32.toString()).toEqual("4,2,3");
uin
t32 = new Uint32Array([1, 2, 3]).fill(4, -3, -2);
expect(
uin
t32.toString()).toEqual("4,2,3");
}
testFilter() {
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let
floa
t32 = new Uint32Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint32Array):
let
uin
t32 = new Uint32Array([12, 5, 8, 44]).filter((value: number, _: number, _a: Uint32Array):
boolean => value >= 10);
expect(
floa
t32.toString()).toEqual("12,44");
expect(
uin
t32.toString()).toEqual("12,44");
}
find() {
let
floa
t32 = new Uint32Array([4, 5, 8, 12]);
let res =
floa
t32.find((value: number, _: number, _a: Uint32Array): boolean => value > 5);
let
uin
t32 = new Uint32Array([4, 5, 8, 12]);
let res =
uin
t32.find((value: number, _: number, _a: Uint32Array): boolean => value > 5);
expect(res).toEqual(8);
}
findIndex() {
let
floa
t32 = new Uint32Array([4, 6, 8, 12]);
let res =
floa
t32.findIndex((value: number, _: number, _a: Uint32Array): boolean => value > 100);
let
uin
t32 = new Uint32Array([4, 6, 8, 12]);
let res =
uin
t32.findIndex((value: number, _: number, _a: Uint32Array): boolean => value > 100);
expect(res).toEqual(-1);
let u
floa
t32 = new Uint32Array([4, 6, 7, 120]);
res = u
floa
t32.findIndex((value: number, _: number, _a: Uint32Array): boolean => value > 100);
let u
uin
t32 = new Uint32Array([4, 6, 7, 120]);
res = u
uin
t32.findIndex((value: number, _: number, _a: Uint32Array): boolean => value > 100);
expect(res).toEqual(3);
}
...
...
@@ -141,44 +141,44 @@ export class TUint32Array {
}
includes() {
let
floa
t32 = new Uint32Array([1, 2, 3]);
let res =
floa
t32.includes(2);
let
uin
t32 = new Uint32Array([1, 2, 3]);
let res =
uin
t32.includes(2);
expect(res).toEqual(true);
res =
floa
t32.includes(4);
res =
uin
t32.includes(4);
expect(res).toEqual(false);
res =
floa
t32.includes(3, 3);
res =
uin
t32.includes(3, 3);
expect(res).toEqual(false);
}
indexOf() {
let
floa
t32 = new Uint32Array([2, 5, 9]);
let res =
floa
t32.indexOf(2);
let
uin
t32 = new Uint32Array([2, 5, 9]);
let res =
uin
t32.indexOf(2);
expect(res).toEqual(0);
res =
floa
t32.indexOf(7);
res =
uin
t32.indexOf(7);
expect(res).toEqual(-1);
res =
floa
t32.indexOf(9, 2);
res =
uin
t32.indexOf(9, 2);
expect(res).toEqual(2);
res =
floa
t32.indexOf(2, -1);
res =
uin
t32.indexOf(2, -1);
expect(res).toEqual(-1);
res =
floa
t32.indexOf(2, -3);
res =
uin
t32.indexOf(2, -3);
expect(res).toEqual(0);
}
join() {
let
floa
t32 = new Uint32Array([1, 2, 3]);
let res =
floa
t32.join();
let
uin
t32 = new Uint32Array([1, 2, 3]);
let res =
uin
t32.join();
expect(res).toEqual("1,2,3");
res =
floa
t32.join(" / ");
res =
uin
t32.join(" / ");
expect(res).toEqual("1 / 2 / 3");
res =
floa
t32.join("");
res =
uin
t32.join("");
expect(res).toEqual("123");
}
...
...
@@ -220,23 +220,23 @@ export class TUint32Array {
}
reverse() {
let
floa
t32 = new Uint32Array([1, 2, 3]);
floa
t32.reverse();
expect(
floa
t32.toString()).toEqual("3,2,1");
let
uin
t32 = new Uint32Array([1, 2, 3]);
uin
t32.reverse();
expect(
uin
t32.toString()).toEqual("3,2,1");
}
slice() {
let
floa
t32 = new Uint32Array([1, 2, 3]);
let res =
floa
t32.slice(1);
let
uin
t32 = new Uint32Array([1, 2, 3]);
let res =
uin
t32.slice(1);
expect(res.toString()).toEqual("2,3");
res =
floa
t32.slice(2);
res =
uin
t32.slice(2);
expect(res.toString()).toEqual("3");
res =
floa
t32.slice(-2);
res =
uin
t32.slice(-2);
expect(res.toString()).toEqual("2,3");
res =
floa
t32.slice(0, 1);
res =
uin
t32.slice(0, 1);
expect(res.toString()).toEqual("1");
}
...
...
@@ -251,11 +251,11 @@ export class TUint32Array {
subarray() {
let buffer = new ArrayBuffer(16);
let
floa
t32 = new Uint32Array(buffer);
floa
t32.set([1, 2, 3]);
expect(
floa
t32.toString()).toEqual("1,2,3,0");
let
uin
t32 = new Uint32Array(buffer);
uin
t32.set([1, 2, 3]);
expect(
uin
t32.toString()).toEqual("1,2,3,0");
let sub =
floa
t32.subarray(0, 4);
let sub =
uin
t32.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
floa
t32 = new Uint32Array(buffer);
floa
t32[3] = 42;
expect(
floa
t32.toString()).toEqual("0,0,0,42");
let
uin
t32 = new Uint32Array(buffer);
uin
t32[3] = 42;
expect(
uin
t32.toString()).toEqual("0,0,0,42");
let res = buffer.slice(8);
let sliced = new Uint32Array(res);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录