Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
70c91cb7
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1692
Star
30
Fork
9
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
Hello UTS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
70c91cb7
编写于
12月 04, 2024
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 修复语法及用法错误
上级
559e20aa
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
41 addition
and
53 deletion
+41
-53
uni_modules/uts-tests/utssdk/Array.uts
uni_modules/uts-tests/utssdk/Array.uts
+10
-4
uni_modules/uts-tests/utssdk/Math.uts
uni_modules/uts-tests/utssdk/Math.uts
+1
-1
uni_modules/uts-tests/utssdk/Number.uts
uni_modules/uts-tests/utssdk/Number.uts
+2
-2
uni_modules/uts-tests/utssdk/Operators.uts
uni_modules/uts-tests/utssdk/Operators.uts
+2
-2
uni_modules/uts-tests/utssdk/Promise.uts
uni_modules/uts-tests/utssdk/Promise.uts
+1
-1
uni_modules/uts-tests/utssdk/UTSJSONObject.uts
uni_modules/uts-tests/utssdk/UTSJSONObject.uts
+1
-1
uni_modules/uts-tests/utssdk/index.uts
uni_modules/uts-tests/utssdk/index.uts
+1
-5
uni_modules/uts-tests/utssdk/iterator.uts
uni_modules/uts-tests/utssdk/iterator.uts
+22
-36
uni_modules/uts-tests/utssdk/tests.uts
uni_modules/uts-tests/utssdk/tests.uts
+1
-1
未找到文件。
uni_modules/uts-tests/utssdk/Array.uts
浏览文件 @
70c91cb7
...
...
@@ -300,8 +300,8 @@ export function testArray() : Result {
})
test("of-1", () => {
let a1 = Array.of('foo', 2, 'bar', true)
let a2 = Array.of()
let a1 = Array.of
<any>
('foo', 2, 'bar', true)
let a2 = Array.of
<any>
()
console.log(a1,a2)
type User = {
id:number
...
...
@@ -311,7 +311,7 @@ export function testArray() : Result {
id:1001,
name:"张三"
} as User
let a3 = Array.of("aaa",false,u1)
let a3 = Array.of
<any>
("aaa",false,u1)
expect(a1).toEqual([ "foo", 2, "bar", true ]);
expect(a2).toEqual([]);
// #ifdef APP-ANDROID
...
...
@@ -324,7 +324,12 @@ export function testArray() : Result {
let a1 = Array.from('foo')
let a2 = Array.from([1, 2, 3], function(x:any|null,index:number){
// #ifdef APP
return (x as Number).toInt() + (x as Number).toInt()
// #endif
// #ifndef APP
return (x as number) + (x as number)
// #endif
})
// #ifdef APP-ANDROID
expect(a1).toEqual(["f", "o", "o"]);
...
...
@@ -360,13 +365,14 @@ export function testArray() : Result {
});
// #endif
// #ifdef APP
let s1 = new Set([Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)])
Array.fromAsync(
s1
).then((array) => {
expect(array).toEqual([1, 2, 3]);
});
// #endif
// #ifdef APP-ANDROID
UTSAndroid.getDispatcher("io").async(function(_){
...
...
uni_modules/uts-tests/utssdk/Math.uts
浏览文件 @
70c91cb7
...
...
@@ -107,7 +107,7 @@ export function testMath() : Result {
expect(difference(5, 3)).toEqual(2);
expect(difference(1.23456, 7.89012)).toEqual(6.6555599999999995);
let utsNumber1 = JSON.parse("-160")! as
N
umber
let utsNumber1 = JSON.parse("-160")! as
n
umber
expect(Math.abs(utsNumber1)).toEqual(160);
let utsNumber2 = Math.abs(0) - 0.123456
...
...
uni_modules/uts-tests/utssdk/Number.uts
浏览文件 @
70c91cb7
...
...
@@ -379,10 +379,10 @@ export function testNumber() : Result {
expect(a10 == b10).toEqual(true);
expect(a10 === b10).toEqual(true);
let num1:
A
ny = 1.0
let num1:
a
ny = 1.0
let num2 = 1
console.log(num1 == num2)
let num3:
A
ny = 112233
let num3:
a
ny = 112233
let num4 = 112233.0
console.log(num3 == num4)
...
...
uni_modules/uts-tests/utssdk/Operators.uts
浏览文件 @
70c91cb7
...
...
@@ -123,8 +123,8 @@ export function testOperators(): Result {
expect(divide(16788990015, 5)).toEqualNumber(3357798003);
expectNumber(divide(16788990015, 10088990000)).toEqualDouble(1.6640902622561822);
let utsNum1 = JSON.parse("0.123456")! as
N
umber
let utsNum2 = JSON.parse("0.123456")! as
N
umber
let utsNum1 = JSON.parse("0.123456")! as
n
umber
let utsNum2 = JSON.parse("0.123456")! as
n
umber
let utsNum3 = utsNum1 / utsNum2
expect(utsNum3).toEqualNumber(1);
...
...
uni_modules/uts-tests/utssdk/Promise.uts
浏览文件 @
70c91cb7
...
...
@@ -321,7 +321,7 @@ export function testPromise() : Result {
console.log(res);
let statusArr : string[] = []
res.forEach((item, index : number) => {
statusArr.
add
(item.status)
statusArr.
push
(item.status)
})
expect(statusArr).toEqual(["fulfilled", "fulfilled", "rejected", "rejected"])
})
...
...
uni_modules/uts-tests/utssdk/UTSJSONObject.uts
浏览文件 @
70c91cb7
...
...
@@ -276,7 +276,7 @@ export function testUTSJSONObject() : Result {
}
}
//返回指定键对应的值,如果对象中不存在此键则返回 null。
let name : string = person["name"] as
S
tring
let name : string = person["name"] as
s
tring
//get 方法可以简化为使用下标运算符 `[]` 访问
name = person['name'] as string
//增加或更新指定键对应的值。
...
...
uni_modules/uts-tests/utssdk/index.uts
浏览文件 @
70c91cb7
...
...
@@ -54,9 +54,7 @@ export function runTests() : UTSJSONObject {
const TextDecoderRes = testDecoder();
// #endif
// #ifdef APP-IOS || APP-ANDROID
const IteratorRes = testIterator()
// #endif
return {
Array: ArrayRes,
...
...
@@ -85,8 +83,6 @@ export function runTests() : UTSJSONObject {
NativeCode: NativeCodeRes,
Primise: PromiseRes,
// #ifdef APP-IOS || APP-ANDROID
Iterator: IteratorRes
// #endif
Iterator: IteratorRes
}
}
\ No newline at end of file
uni_modules/uts-tests/utssdk/iterator.uts
浏览文件 @
70c91cb7
...
...
@@ -14,14 +14,10 @@ import { describe, test, expect, Result } from './tests.uts'
class TestChild implements UTSValueIterable<any | null> {
a: string = ""
b:
Int
= 1
b:
number
= 1
c: boolean = false
holderArray: (any | null)[] = [11, 22, null, 33, 44, null];
constructor(){
super()
}
ignoredKeys(): string[] {
...
...
@@ -33,8 +29,8 @@ class TestChild implements UTSValueIterable<any | null> {
valueIterator(): UTSIterator<any | null> {
let holderIndex = 0;
let obj: UTSIterator<any | null> = {
next
(): UTSIteratorResult<any | null
> {
return UTSIteratorResult<any | null>(holderIndex == this.holderArray.
size
- 1, this.holderArray[holderIndex++])
next
: (): UTSIteratorResult<any | null> =
> {
return UTSIteratorResult<any | null>(holderIndex == this.holderArray.
length
- 1, this.holderArray[holderIndex++])
}
}
return obj
...
...
@@ -44,14 +40,11 @@ class TestChild implements UTSValueIterable<any | null> {
class TestClass implements UTSValueIterable<any | null> {
holderArray: (any | null)[] = [null, null]
constructor(){
super()
}
valueIterator(): UTSIterator<any | null> {
let holderIndex = 0;
let obj: UTSIterator<any | null> = {
next
(): UTSIteratorResult<any | null
> {
next
: (): UTSIteratorResult<any | null> =
> {
let currentVal = this.holderArray[holderIndex++]
while(currentVal == null ){
...
...
@@ -73,14 +66,11 @@ class TestChild implements UTSValueIterable<any | null> {
class TestClass2 implements UTSValueIterable<any | null> {
holderArray: (any | null)[] = [11, 22, null, 33, 44, null]
constructor(){
super()
}
valueIterator(): UTSIterator<any | null> {
let holderIndex = 0;
let obj: UTSIterator<any | null> = {
next
(): UTSIteratorResult<any | null
> {
next
: (): UTSIteratorResult<any | null> =
> {
let currentVal = this.holderArray[holderIndex++]
while(currentVal == null ){
...
...
@@ -103,14 +93,10 @@ class TestChild implements UTSValueIterable<any | null> {
holderArray: (any | null)[] = [11, 22, null, 33, 44, null]
constructor(){
super()
}
valueIterator(): UTSIterator<any | null> {
let holderIndex = 0;
let obj: UTSIterator<any | null> = {
next
(): UTSIteratorResult<any | null
> {
next
: (): UTSIteratorResult<any | null> =
> {
return UTSIteratorResult<any | null>(holderIndex == this.holderArray.length - 1, this.holderArray[holderIndex++])
}
}
...
...
@@ -141,7 +127,7 @@ export function testIterator(): Result {
let arr = ["a", "b", "c", "d"]
let result1: string[] = []
for (let item of arr) {
result1.
add
(item)
result1.
push
(item)
}
expect(result1).toEqual(["a", "b", "c", "d"])
...
...
@@ -153,7 +139,7 @@ export function testIterator(): Result {
//let result2: [any] = []
let result2: Array<any> = []
for (let item of dic) {
result2.
add
(item)
result2.
push
(item)
}
// #ifdef APP-ANDROID
expect(result2).toEqual(
...
...
@@ -168,37 +154,37 @@ export function testIterator(): Result {
set.add("c")
var result3: any[] = []
for (let item of set) {
result3.
add
(item)
result3.
push
(item)
}
expect(result3).toEqual(["a", "b", "c"])
// test Class for UTSValueIterable
let test = new TestChild()
let result4: (any | null)[] = []
for (item of test) {
result4.
add
(item)
for (
let
item of test) {
result4.
push
(item)
}
expect(result4).toEqual([11, 22, null, 33, 44, null])
let test221 = new TestClass()
let forofRet:Array<
A
ny|null> = []
for (item of test221) {
forofRet.
add
(item)
let forofRet:Array<
a
ny|null> = []
for (
let
item of test221) {
forofRet.
push
(item)
}
expect(forofRet).toEqual([11, 22, null, 33, 44, null])
let test222 = new TestClass2()
let forofRet2:Array<
A
ny|null> = []
for (item of test222) {
forofRet2.
add
(item)
let forofRet2:Array<
a
ny|null> = []
for (
let
item of test222) {
forofRet2.
push
(item)
}
expect(forofRet2).toEqual([11, 22, 33, 44, ])
let test223 = new TestClass3()
let forofRet3:Array<
A
ny|null> = []
for (item of test223) {
forofRet3.
add
(item)
let forofRet3:Array<
a
ny|null> = []
for (
let
item of test223) {
forofRet3.
push
(item)
}
expect(forofRet3).toEqual([11, 22, null, 33, 44, null])
...
...
uni_modules/uts-tests/utssdk/tests.uts
浏览文件 @
70c91cb7
...
...
@@ -43,7 +43,7 @@ export function test(name: string, fn: () => void) {
result.passed.push(name)
// console.log('push....',result.passed.length)
} catch (e) {
result.failed.push(`${name}:\n${
e
.message}`)
result.failed.push(`${name}:\n${
(e as Error)
.message}`)
}
result.total++
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录