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