Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
4621bbc1
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1598
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看板
提交
4621bbc1
编写于
8月 01, 2024
作者:
M
mahaifeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[array-buffer]uint16array添加console
上级
51cfb9da
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
102 addition
and
106 deletion
+102
-106
uni_modules/uts-tests/utssdk/TFloat64Array.uts
uni_modules/uts-tests/utssdk/TFloat64Array.uts
+7
-5
uni_modules/uts-tests/utssdk/TUint16Array.uts
uni_modules/uts-tests/utssdk/TUint16Array.uts
+95
-101
未找到文件。
uni_modules/uts-tests/utssdk/TFloat64Array.uts
浏览文件 @
4621bbc1
...
@@ -237,13 +237,14 @@ export class TFloat64Array {
...
@@ -237,13 +237,14 @@ export class TFloat64Array {
// #TEST Float64Array.keys
// #TEST Float64Array.keys
let arr = new Float64Array([10, 20, 30, 40, 50]);
let arr = new Float64Array([10, 20, 30, 40, 50]);
let keys = arr.keys();
let keys = arr.keys();
console.log(keys.next().value); // 0
let value = keys.next().value
console.log(value); // 0
console.log(keys.next().value); // 1
console.log(keys.next().value); // 1
console.log(keys.next().value); // 2
console.log(keys.next().value); // 2
console.log(keys.next().value); // 3
console.log(keys.next().value); // 3
console.log(keys.next().value); // 4
console.log(keys.next().value); // 4
// #END
// #END
expect(
keys.next().value).toEqual(-1
);
expect(
value).toEqual(0
);
}
}
map() {
map() {
...
@@ -389,11 +390,12 @@ export class TFloat64Array {
...
@@ -389,11 +390,12 @@ export class TFloat64Array {
// #TEST Float64Array.values
// #TEST Float64Array.values
let arr = new Float64Array([1, 2, 3]);
let arr = new Float64Array([1, 2, 3]);
let values = arr.values();
let values = arr.values();
console.log(values.next().value); // 1
let value = values.next().value
console.log(value); // 1
console.log(values.next().value); // 2
console.log(values.next().value); // 2
console.log(values.next().value); // 3
console.log(values.next().value); // 3
// #END
// #END
expect(value
s.next().value).toEqual(-
1);
expect(value
).toEqual(
1);
}
}
arrayBufferSlice() {
arrayBufferSlice() {
...
...
uni_modules/uts-tests/utssdk/TUint16Array.uts
浏览文件 @
4621bbc1
...
@@ -98,28 +98,24 @@ export class TUint16Array {
...
@@ -98,28 +98,24 @@ export class TUint16Array {
// #TEST Uint16Array.fill
// #TEST Uint16Array.fill
let uint16 = new Uint16Array([1, 2, 3]).fill(4);
let uint16 = new Uint16Array([1, 2, 3]).fill(4);
console.log(uint16.toString()); // "4,4,4"
console.log(uint16.toString()); // "4,4,4"
// #END
expect(uint16.toString()).toEqual("4,4,4");
uint16 = new Uint16Array([1, 2, 3]).fill(4, 1);
let uint16_t1 = new Uint16Array([1, 2, 3]).fill(4, 1);
console.log(uint16.toString()); // "1,4,4"
console.log(uint16_t1.toString()); // "1,4,4"
// #END
expect(uint16.toString()).toEqual("1,4,4");
uint16 = new Uint16Array([1, 2, 3]).fill(4, 1, 2);
let uint16_t2 = new Uint16Array([1, 2, 3]).fill(4, 1, 2);
console.log(uint16.toString()); // "1,4,3"
console.log(uint16_t2.toString()); // "1,4,3"
// #END
expect(uint16.toString()).toEqual("1,4,3");
uint16 = new Uint16Array([1, 2, 3]).fill(4, 1, 1);
let uint16_t3 = new Uint16Array([1, 2, 3]).fill(4, 1, 1);
console.log(uint16.toString()); // "1,2,3"
console.log(uint16_t3.toString()); // "1,2,3"
// #END
expect(uint16.toString()).toEqual("1,2,3");
uint16
= new Uint16Array([1, 2, 3]).fill(4, -3, -2);
let uint16_t4
= new Uint16Array([1, 2, 3]).fill(4, -3, -2);
console.log(uint16.toString()); // "4,2,3"
console.log(uint16
_t4
.toString()); // "4,2,3"
// #END
// #END
expect(uint16.toString()).toEqual("4,2,3");
expect(uint16_t4.toString()).toEqual("4,2,3");
expect(uint16.toString()).toEqual("4,4,4");
expect(uint16_t1.toString()).toEqual("1,4,4");
expect(uint16_t2.toString()).toEqual("1,4,3");
expect(uint16_t3.toString()).toEqual("1,2,3");
}
}
testFilter() {
testFilter() {
...
@@ -145,14 +141,15 @@ export class TUint16Array {
...
@@ -145,14 +141,15 @@ export class TUint16Array {
let uint16 = new Uint16Array([4, 6, 8, 12]);
let uint16 = new Uint16Array([4, 6, 8, 12]);
let res = uint16.findIndex((value : number, _ : number, _a : Uint16Array) : boolean => value > 100);
let res = uint16.findIndex((value : number, _ : number, _a : Uint16Array) : boolean => value > 100);
console.log(res); // -1
console.log(res); // -1
// #END
expect(res).toEqual(-1);
let uuint16 = new Uint16Array([4, 6, 7, 120]);
let uuint16 = new Uint16Array([4, 6, 7, 120]);
res
= uuint16.findIndex((value : number, _ : number, _a : Uint16Array) : boolean => value > 100);
let res1
= uuint16.findIndex((value : number, _ : number, _a : Uint16Array) : boolean => value > 100);
console.log(res); // 3
console.log(res
1
); // 3
// #END
// #END
expect(res).toEqual(3);
expect(res1).toEqual(3);
expect(res).toEqual(-1);
}
}
foreach() {
foreach() {
...
@@ -178,66 +175,60 @@ export class TUint16Array {
...
@@ -178,66 +175,60 @@ export class TUint16Array {
let uint16 = new Uint16Array([1, 2, 3]);
let uint16 = new Uint16Array([1, 2, 3]);
let res = uint16.includes(2);
let res = uint16.includes(2);
console.log(res); // true
console.log(res); // true
// #END
expect(res).toEqual(true);
res = uint16.includes(4);
let res1 = uint16.includes(4);
console.log(res); // false
console.log(res1); // false
// #END
expect(res).toEqual(false);
res
= uint16.includes(3, 3);
let res2
= uint16.includes(3, 3);
console.log(res); // false
console.log(res
2
); // false
// #END
// #END
expect(res).toEqual(false);
expect(res2).toEqual(false);
expect(res1).toEqual(false);
expect(res).toEqual(true);
}
}
indexOf() {
indexOf() {
// #TEST Uint16Array.indexOf
// #TEST Uint16Array.indexOf
let uint16 = new Uint16Array([2, 5, 9]);
let uint16 = new Uint16Array([2, 5, 9]);
let res = uint16.indexOf(2);
console.log(res); // 0
// #END
expect(res).toEqual(0);
res = uint16.indexOf(7);
let res1 = uint16.indexOf(2);
console.log(res); // -1
console.log(res1); // 0
// #END
expect(res).toEqual(-1);
res = uint16.indexOf(9, 2);
let res2 = uint16.indexOf(7);
console.log(res); // 2
console.log(res2); // -1
// #END
expect(res).toEqual(2);
res = uint16.indexOf(2, -1);
let res3 = uint16.indexOf(9, 2);
console.log(res); // -1
console.log(res3); // 2
// #END
expect(res).toEqual(-1);
let res4 = uint16.indexOf(2, -1);
console.log(res4); // -1
res
= uint16.indexOf(2, -3);
let res5
= uint16.indexOf(2, -3);
console.log(res); // 0
console.log(res
5
); // 0
// #END
// #END
expect(res).toEqual(0);
}
expect(res1).toEqual(0);
expect(res2).toEqual(-1);
expect(res3).toEqual(2);
expect(res4).toEqual(-1);
expect(res5).toEqual(0);
}
join() {
join() {
// #TEST Uint16Array.join
// #TEST Uint16Array.join
let uint16 = new Uint16Array([1, 2, 3]);
let uint16 = new Uint16Array([1, 2, 3]);
let res = uint16.join();
let res1 = uint16.join();
console.log(res); // "1,2,3"
console.log(res1); // "1,2,3"
// #END
expect(res).toEqual("1,2,3");
res = uint16.join(" / ");
let res2 = uint16.join(" / ");
console.log(res); // "1 / 2 / 3"
console.log(res2); // "1 / 2 / 3"
// #END
expect(res).toEqual("1 / 2 / 3");
res
= uint16.join("");
let res3
= uint16.join("");
console.log(res); // "123"
console.log(res
3
); // "123"
// #END
// #END
expect(res).toEqual("123");
expect(res1).toEqual("1,2,3");
expect(res2).toEqual("1 / 2 / 3");
expect(res3).toEqual("123");
}
}
keys() {
keys() {
...
@@ -263,35 +254,39 @@ export class TUint16Array {
...
@@ -263,35 +254,39 @@ export class TUint16Array {
reduce() {
reduce() {
// #TEST Uint16Array.reduce
// #TEST Uint16Array.reduce
let total = new Uint16Array([0, 1, 2, 3]);
let total = new Uint16Array([0, 1, 2, 3]);
let res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Uint16Array) : number =>
let res1 = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Uint16Array) : number =>
accumulator + currentValue);
accumulator + currentValue
console.log(res); // 6
);
// #END
console.log(res1); // 6
expect(res).toEqual(6);
total = new Uint16Array([0, 1, 2, 3]);
total = new Uint16Array([0, 1, 2, 3]);
res = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Uint16Array) : number =>
let res2 = total.reduce((accumulator : number, currentValue : number, _ : number, _a : Uint16Array) : number =>
accumulator + currentValue, 8);
accumulator + currentValue, 8
console.log(res); // 14
);
console.log(res2); // 14
// #END
// #END
expect(res).toEqual(14);
expect(res1).toEqual(6);
expect(res2).toEqual(14);
}
}
reduceRight() {
reduceRight() {
// #TEST Uint16Array.reduceRight
// #TEST Uint16Array.reduceRight
let total = new Uint16Array([0, 1, 2, 3]);
let total = new Uint16Array([0, 1, 2, 3]);
let res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Uint16Array) : number =>
let res1 = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Uint16Array) : number =>
accumulator + currentValue);
accumulator + currentValue
console.log(res); // 6
);
// #END
console.log(res1); // 6
expect(res).toEqual(6);
total = new Uint16Array([0, 1, 2, 3]);
total = new Uint16Array([0, 1, 2, 3]);
res = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Uint16Array) : number =>
let res2 = total.reduceRight((accumulator : number, currentValue : number, _ : number, _a : Uint16Array) : number =>
accumulator + currentValue, 8);
accumulator + currentValue, 8
console.log(res); // 14
);
console.log(res2); // 14
// #END
// #END
expect(res).toEqual(14);
expect(res1).toEqual(6);
expect(res2).toEqual(14);
}
}
reverse() {
reverse() {
...
@@ -306,56 +301,57 @@ export class TUint16Array {
...
@@ -306,56 +301,57 @@ export class TUint16Array {
slice() {
slice() {
// #TEST Uint16Array.slice
// #TEST Uint16Array.slice
let uint16 = new Uint16Array([1, 2, 3]);
let uint16 = new Uint16Array([1, 2, 3]);
let res = uint16.slice(1);
let res1 = uint16.slice(1);
console.log(res.toString()); // "2,3"
console.log(res1.toString()); // "2,3"
// #END
expect(res.toString()).toEqual("2,3");
res = uint16.slice(2);
let res2 = uint16.slice(2);
console.log(res.toString()); // "3"
console.log(res2.toString()); // "3"
// #END
expect(res.toString()).toEqual("3");
res = uint16.slice(-2);
let res3 = uint16.slice(-2);
console.log(res.toString()); // "2,3"
console.log(res3.toString()); // "2,3"
// #END
expect(res.toString()).toEqual("2,3");
res
= uint16.slice(0, 1);
let res4
= uint16.slice(0, 1);
console.log(res.toString()); // "1"
console.log(res
4
.toString()); // "1"
// #END
// #END
expect(res.toString()).toEqual("1");
expect(res1.toString()).toEqual("2,3");
expect(res2.toString()).toEqual("3");
expect(res3.toString()).toEqual("2,3");
expect(res4.toString()).toEqual("1");
}
}
sort() {
sort() {
// #TEST Uint16Array.sort
// #TEST Uint16Array.sort
let numbers = new Uint16Array([40, 1, 5]);
let numbers = new Uint16Array([40, 1, 5]);
numbers.sort();
numbers.sort();
console.log(numbers.toString()); // "1,5,40"
console.log(numbers.toString()); // "1,5,40"
// #END
expect(numbers.toString()).toEqual("1,5,40");
numbers.sort((a, b) : number => a - b);
numbers.sort((a, b) : number => a - b);
console.log(numbers.toString()); // "1,5,40"
console.log(numbers.toString()); // "1,5,40"
// #END
// #END
expect(numbers.toString()).toEqual("1,5,40");
expect(numbers.toString()).toEqual("1,5,40");
expect(numbers.toString()).toEqual("1,5,40");
}
}
subarray() {
subarray() {
// #TEST Uint16Array.subarray
// #TEST Uint16Array.subarray
let buffer = new ArrayBuffer(16);
let buffer = new ArrayBuffer(16);
let uint16 = new Uint16Array(buffer);
let uint16 = new Uint16Array(buffer);
uint16.set([1, 2, 3]);
uint16.set([1, 2, 3]);
console.log(uint16.toString()); // "1,2,3,0,0,0,0,0"
console.log(uint16.toString()); // "1,2,3,0,0,0,0,0"
// #END
expect(uint16.toString()).toEqual("1,2,3,0,0,0,0,0");
let sub = uint16.subarray(0, 4);
let sub = uint16.subarray(0, 4);
console.log(sub.toString()); // "1,2,3,0"
console.log(sub.toString()); // "1,2,3,0"
// #END
// #END
expect(uint16.toString()).toEqual("1,2,3,0,0,0,0,0");
expect(sub.toString()).toEqual("1,2,3,0");
expect(sub.toString()).toEqual("1,2,3,0");
}
}
values() {
values() {
// #TEST Uint16Array.values
// #TEST Uint16Array.values
let arr = new Uint16Array([1, 2, 3]);
let arr = new Uint16Array([1, 2, 3]);
...
@@ -372,8 +368,6 @@ export class TUint16Array {
...
@@ -372,8 +368,6 @@ export class TUint16Array {
let uint16 = new Uint16Array(buffer);
let uint16 = new Uint16Array(buffer);
uint16[4] = 42;
uint16[4] = 42;
console.log(uint16.toString()); // "0,0,0,0,42,0,0,0"
console.log(uint16.toString()); // "0,0,0,0,42,0,0,0"
// #END
expect(uint16.toString()).toEqual("0,0,0,0,42,0,0,0");
let res = buffer.slice(8);
let res = buffer.slice(8);
let sliced = new Uint16Array(res);
let sliced = new Uint16Array(res);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录