Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
3daea108
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1593
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看板
提交
3daea108
编写于
9月 13, 2024
作者:
lizhongyi_
提交者:
mahaifeng
9月 14, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调整部分示例避免iOS编译报错
上级
207157cd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
31 deletion
+33
-31
uni_modules/uts-syntaxcase/utssdk/index.uts
uni_modules/uts-syntaxcase/utssdk/index.uts
+24
-27
uni_modules/uts-tests/utssdk/String.uts
uni_modules/uts-tests/utssdk/String.uts
+8
-3
uni_modules/uts-tests/utssdk/UTSJSONObject.uts
uni_modules/uts-tests/utssdk/UTSJSONObject.uts
+1
-1
未找到文件。
uni_modules/uts-syntaxcase/utssdk/index.uts
浏览文件 @
3daea108
...
@@ -52,14 +52,11 @@ export function testSyncWithCallback(opts : AsyncOptions) : SyntaxResult {
...
@@ -52,14 +52,11 @@ export function testSyncWithCallback(opts : AsyncOptions) : SyntaxResult {
async
function
testAwaitPromise
(
res
:
SyntaxResult
)
:
Promise
<
SyntaxResult
>
{
async
function
testAwaitPromise
(
res
:
SyntaxResult
)
:
Promise
<
SyntaxResult
>
{
// #ifdef APP-ANDROID
return
await
new
Promise
(
function
(
resolve
:
(
res
:
SyntaxResult
)
=>
void
)
{
return
await
new
Promise
(
function
(
resolve
:
(
res
:
SyntaxResult
)
=>
void
)
{
resolve
(
res
)
setTimeout
(()
=>
{
resolve
(
res
)
},
2000
)
})
})
// #endif
// #ifndef APP-ANDROID
return
res
// #endif
}
}
/**
/**
* 导出一个异步方法
* 导出一个异步方法
...
@@ -100,7 +97,7 @@ export async function testAsyncParam3(id : number, name : string, opts : AsyncOp
...
@@ -100,7 +97,7 @@ export async function testAsyncParam3(id : number, name : string, opts : AsyncOp
export
class
Test
{
export
class
Test
{
id
:
number
;
id
:
number
;
name
:
string
;
name
:
string
;
static
type
:
string
=
"Test"
;
static
type
:
string
=
"Test"
;
constructor
(
id
:
number
,
options
:
TestOptions
)
{
constructor
(
id
:
number
,
options
:
TestOptions
)
{
...
@@ -122,21 +119,21 @@ export class Test {
...
@@ -122,21 +119,21 @@ export class Test {
const
res
=
await
testAsync
(
opts
);
const
res
=
await
testAsync
(
opts
);
return
res
;
return
res
;
}
}
}
}
export
class
SetterTest
{
export
class
SetterTest
{
private
_nickName
:
string
=
''
;
private
_nickName
:
string
=
''
;
get
nickName
()
:
string
{
get
nickName
()
:
string
{
console
.
log
(
'get nickName'
);
console
.
log
(
'get nickName'
);
return
this
.
_nickName
;
return
this
.
_nickName
;
}
}
set
nickName
(
value
:
string
)
{
set
nickName
(
value
:
string
)
{
console
.
log
(
'set nickName'
);
console
.
log
(
'set nickName'
);
this
.
_nickName
=
value
;
this
.
_nickName
=
value
;
}
}
}
}
class
RequestTaskImpl
implements
RequestTask
{
class
RequestTaskImpl
implements
RequestTask
{
...
@@ -161,15 +158,15 @@ export function request(url : string) : RequestTask | null {
...
@@ -161,15 +158,15 @@ export function request(url : string) : RequestTask | null {
return
new
RequestTaskImpl
(
url
)
return
new
RequestTaskImpl
(
url
)
}
}
// #ifdef APP-ANDROID
// #ifdef APP-ANDROID
// #ifdef UNI-APP-X
// #ifdef UNI-APP-X
export
function
callKotlinMethodGetInfo
():
String
{
export
function
callKotlinMethodGetInfo
():
String
{
return
NativeCode
.
getPhoneInfo
()
return
NativeCode
.
getPhoneInfo
()
}
}
export
function
callJavaMethodGetInfo
():
String
{
export
function
callJavaMethodGetInfo
():
String
{
return
new
JavaUser
(
"jack"
,
12
)
.
name
return
new
JavaUser
(
"jack"
,
12
)
.
name
}
}
import
KeyEvent
from
'android.view.KeyEvent'
;
import
KeyEvent
from
'android.view.KeyEvent'
;
import
Configuration
from
'android.content.res.Configuration'
;
import
Configuration
from
'android.content.res.Configuration'
;
...
...
uni_modules/uts-tests/utssdk/String.uts
浏览文件 @
3daea108
...
@@ -7,10 +7,10 @@ export function testString() : Result {
...
@@ -7,10 +7,10 @@ export function testString() : Result {
const x = "Mozilla";
const x = "Mozilla";
const e = "";
const e = "";
console.log("Mozilla is " +
x.length
+ " code units long");
console.log("Mozilla is " +
`${x.length}`
+ " code units long");
/* "Mozilla is 7 code units long" */
/* "Mozilla is 7 code units long" */
console.log("The empty string is has a length of " +
e.length
);
console.log("The empty string is has a length of " +
`${e.length}`
);
/* "The e string is has a length of 0" */
/* "The e string is has a length of 0" */
// #END
// #END
...
@@ -335,6 +335,7 @@ export function testString() : Result {
...
@@ -335,6 +335,7 @@ export function testString() : Result {
// #TEST String.replace_1
// #TEST String.replace_1
// #ifdef APP-ANDROID
// 不包含捕捉组的示例
// 不包含捕捉组的示例
let a = "The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?"
let a = "The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?"
let b = a.replace(RegExp("fox"), function (match : string, offset : number, string : string) : string {
let b = a.replace(RegExp("fox"), function (match : string, offset : number, string : string) : string {
...
@@ -344,7 +345,7 @@ export function testString() : Result {
...
@@ -344,7 +345,7 @@ export function testString() : Result {
return "cat"
return "cat"
})
})
console.log("b:", b)
console.log("b:", b)
// 包含一个捕获组的示例。注意,目前android仅支持最多五个捕获组
// 包含一个捕获组的示例。注意,目前android仅支持最多五个捕获组
let a1 = "The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?"
let a1 = "The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?"
let b1 = a1.replace(RegExp("(fox)"), function (match : string, p1 : string, offset : number, string : string) : string {
let b1 = a1.replace(RegExp("(fox)"), function (match : string, p1 : string, offset : number, string : string) : string {
...
@@ -355,6 +356,8 @@ export function testString() : Result {
...
@@ -355,6 +356,8 @@ export function testString() : Result {
return "cat"
return "cat"
})
})
console.log("b1", b1)
console.log("b1", b1)
// #endif
// #END
// #END
// const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|SSS/g
// const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|SSS/g
...
@@ -374,10 +377,12 @@ export function testString() : Result {
...
@@ -374,10 +377,12 @@ export function testString() : Result {
// #TEST String.search
// #TEST String.search
const paragraph = 'The quick brown fox jumps over the lazy dog. If the dog barked, was it really lazy?';
const paragraph = 'The quick brown fox jumps over the lazy dog. If the dog barked, was it really lazy?';
const regex = /[^\w\s]/g;
const regex = /[^\w\s]/g;
// #ifdef APP-ANDROID
console.log(paragraph.search(regex));
console.log(paragraph.search(regex));
// expected output: 43
// expected output: 43
console.log(paragraph[paragraph.search(regex)]);
console.log(paragraph[paragraph.search(regex)]);
// expected output: "."
// expected output: "."
// #endif
// #END
// #END
expect(paragraph.search(regex)).toEqual(43);
expect(paragraph.search(regex)).toEqual(43);
...
...
uni_modules/uts-tests/utssdk/UTSJSONObject.uts
浏览文件 @
3daea108
...
@@ -163,7 +163,7 @@ export function testUTSJSONObject() : Result {
...
@@ -163,7 +163,7 @@ export function testUTSJSONObject() : Result {
}
}
}
}
//返回指定键对应的值,如果对象中不存在此键则返回 null。
//返回指定键对应的值,如果对象中不存在此键则返回 null。
let name : string = person
.get('name') as s
tring
let name : string = person
["name"] as S
tring
//get 方法可以简化为使用下标运算符 `[]` 访问
//get 方法可以简化为使用下标运算符 `[]` 访问
name = person['name'] as string
name = person['name'] as string
//增加或更新指定键对应的值。
//增加或更新指定键对应的值。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录