Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
4f39a3f7
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看板
提交
4f39a3f7
编写于
9月 13, 2024
作者:
lizhongyi_
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调整部分示例避免iOS编译报错
上级
16b9306d
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
41 addition
and
14 deletion
+41
-14
uni_modules/uts-helloworld/utssdk/index.uts
uni_modules/uts-helloworld/utssdk/index.uts
+1
-1
uni_modules/uts-syntaxcase/utssdk/index.uts
uni_modules/uts-syntaxcase/utssdk/index.uts
+2
-2
uni_modules/uts-tests/utssdk/Math.uts
uni_modules/uts-tests/utssdk/Math.uts
+29
-7
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-helloworld/utssdk/index.uts
浏览文件 @
4f39a3f7
...
@@ -53,7 +53,7 @@ export function onCallback(callback: (sth:string) => void) {
...
@@ -53,7 +53,7 @@ export function onCallback(callback: (sth:string) => void) {
let count = 1
let count = 1
let taskId = -1
let taskId = -1
taskId = setInterval(function() {
taskId = setInterval(function() {
callback(
"第" + count + "次回调"
)
callback(
`第 ${count} 次回调`
)
count++;
count++;
console.log("count",count)
console.log("count",count)
if(count > 3){
if(count > 3){
...
...
uni_modules/uts-syntaxcase/utssdk/index.uts
浏览文件 @
4f39a3f7
...
@@ -440,7 +440,7 @@ export function Scan1(timeMillis ?: Number):string {
...
@@ -440,7 +440,7 @@ export function Scan1(timeMillis ?: Number):string {
if
(
timeMillis
==
null
){
if
(
timeMillis
==
null
){
return
"null"
return
"null"
}
}
return
timeMillis
.
toString
()
return
timeMillis
!
.
toString
()
}
}
export
function
Scan2
(
timeMillis
?:
Number
|
null
)
:
string
{
export
function
Scan2
(
timeMillis
?:
Number
|
null
)
:
string
{
...
@@ -448,7 +448,7 @@ export function Scan2(timeMillis ?: Number | null):string {
...
@@ -448,7 +448,7 @@ export function Scan2(timeMillis ?: Number | null):string {
if
(
timeMillis
==
null
){
if
(
timeMillis
==
null
){
return
"null"
return
"null"
}
}
return
timeMillis
.
toString
()
return
timeMillis
!
.
toString
()
}
}
export
class
myClass
{
export
class
myClass
{
...
...
uni_modules/uts-tests/utssdk/Math.uts
浏览文件 @
4f39a3f7
...
@@ -112,8 +112,9 @@ export function testMath() : Result {
...
@@ -112,8 +112,9 @@ export function testMath() : Result {
// #TEST Math.acos
// #TEST Math.acos
console.log(Math.acos(-1));
console.log(Math.acos(-1));
// expected output: 3.141592653589793
// expected output: 3.141592653589793
// #ifdef APP-ANDROID
console.log(Math.acos(NaN));
console.log(Math.acos(NaN));
// #endif
// expected output: NaN
// expected output: NaN
console.log(Math.acos(0));
console.log(Math.acos(0));
...
@@ -133,8 +134,9 @@ export function testMath() : Result {
...
@@ -133,8 +134,9 @@ export function testMath() : Result {
// #TEST Math.acosh
// #TEST Math.acosh
console.log(Math.acosh(1));
console.log(Math.acosh(1));
// expected output: 0
// expected output: 0
// #ifdef APP-ANDROID
console.log(Math.acosh(NaN));
console.log(Math.acosh(NaN));
// #endif
// expected output: NaN
// expected output: NaN
console.log(Math.acosh(2));
console.log(Math.acosh(2));
...
@@ -152,7 +154,9 @@ export function testMath() : Result {
...
@@ -152,7 +154,9 @@ export function testMath() : Result {
test('asin', () => {
test('asin', () => {
// #TEST Math.asin
// #TEST Math.asin
// #ifdef APP-ANDROID
console.log(Math.asin(NaN));
console.log(Math.asin(NaN));
// #endif
// expected output: NaN
// expected output: NaN
console.log(Math.asin(-1));
console.log(Math.asin(-1));
...
@@ -177,7 +181,9 @@ export function testMath() : Result {
...
@@ -177,7 +181,9 @@ export function testMath() : Result {
test('asinh', () => {
test('asinh', () => {
// #TEST Math.asinh
// #TEST Math.asinh
// #ifdef APP-ANDROID
console.log(Math.asinh(NaN));
console.log(Math.asinh(NaN));
// #endif
// expected output: NaN
// expected output: NaN
console.log(Math.asinh(1));
console.log(Math.asinh(1));
...
@@ -202,7 +208,9 @@ export function testMath() : Result {
...
@@ -202,7 +208,9 @@ export function testMath() : Result {
test('atan', () => {
test('atan', () => {
// #TEST Math.atan
// #TEST Math.atan
// #ifdef APP-ANDROID
console.log(Math.atan(NaN));
console.log(Math.atan(NaN));
// #endif
// expected output: NaN
// expected output: NaN
console.log(Math.atan(1));
console.log(Math.atan(1));
...
@@ -231,7 +239,9 @@ export function testMath() : Result {
...
@@ -231,7 +239,9 @@ export function testMath() : Result {
test('atanh', () => {
test('atanh', () => {
// #TEST Math.atanh
// #TEST Math.atanh
// #ifdef APP-ANDROID
console.log(Math.atanh(NaN));
console.log(Math.atanh(NaN));
// #endif
// expected output: NaN
// expected output: NaN
console.log(Math.atanh(0));
console.log(Math.atanh(0));
...
@@ -253,8 +263,9 @@ export function testMath() : Result {
...
@@ -253,8 +263,9 @@ export function testMath() : Result {
// #TEST Math.ceil
// #TEST Math.ceil
console.log(Math.ceil(0.95));
console.log(Math.ceil(0.95));
// expected output: 1
// expected output: 1
// #ifdef APP-ANDROID
console.log(Math.ceil(NaN));
console.log(Math.ceil(NaN));
// #endif
// expected output: NaN
// expected output: NaN
console.log(Math.ceil(4));
console.log(Math.ceil(4));
...
@@ -383,7 +394,9 @@ export function testMath() : Result {
...
@@ -383,7 +394,9 @@ export function testMath() : Result {
test('fround', () => {
test('fround', () => {
// #TEST Math.fround
// #TEST Math.fround
// #ifdef APP-ANDROID
console.log(Math.fround(NaN));
console.log(Math.fround(NaN));
// #endif
// expected output: NaN
// expected output: NaN
console.log(Math.fround(1.5));
console.log(Math.fround(1.5));
...
@@ -626,12 +639,15 @@ export function testMath() : Result {
...
@@ -626,12 +639,15 @@ export function testMath() : Result {
test('round', () => {
test('round', () => {
// #TEST Math.round
// #TEST Math.round
// #ifdef APP-ANDROID
console.log(Math.round(NaN));
console.log(Math.round(NaN));
// #endif
// expected output: NaN
// expected output: NaN
console.log(Math.round(Math.E));
console.log(Math.round(Math.E));
// expected output: 3
// expected output: 3
// #ifdef APP-ANDROID
console.log(Math.round(Number.MAX_VALUE));
console.log(Math.round(Number.MAX_VALUE));
// expected output: 1.7976931348623157e+308
// expected output: 1.7976931348623157e+308
...
@@ -644,6 +660,8 @@ export function testMath() : Result {
...
@@ -644,6 +660,8 @@ export function testMath() : Result {
console.log(Math.round(Number.POSITIVE_INFINITY));
console.log(Math.round(Number.POSITIVE_INFINITY));
// expected output: Infinity
// expected output: Infinity
// #endif
console.log(Math.round(0.9));
console.log(Math.round(0.9));
// expected output: 1
// expected output: 1
...
@@ -661,10 +679,14 @@ export function testMath() : Result {
...
@@ -661,10 +679,14 @@ export function testMath() : Result {
// #END
// #END
expect(Math.round(NaN)).toEqual(NaN);
expect(Math.round(NaN)).toEqual(NaN);
expect(Math.round(Math.E)).toEqual(3);
expect(Math.round(Math.E)).toEqual(3);
// #ifdef APP-ANDROID
expectNumber(Math.round(Number.MAX_VALUE)).toEqualDouble(1.7976931348623157e+308);
expectNumber(Math.round(Number.MAX_VALUE)).toEqualDouble(1.7976931348623157e+308);
expect(Math.round(Number.MIN_VALUE)).toEqual(0);
expect(Math.round(Number.MIN_VALUE)).toEqual(0);
expect(Math.round(Number.NEGATIVE_INFINITY)).toEqual(-Infinity);
expect(Math.round(Number.NEGATIVE_INFINITY)).toEqual(-Infinity);
expect(Math.round(Number.POSITIVE_INFINITY)).toEqual(Infinity);
expect(Math.round(Number.POSITIVE_INFINITY)).toEqual(Infinity);
// #endif
expect(Math.round(0.9)).toEqual(1);
expect(Math.round(0.9)).toEqual(1);
expect(Math.round(5.95)).toEqual(6);
expect(Math.round(5.95)).toEqual(6);
expect(Math.round(-5.05)).toEqual(-5);
expect(Math.round(-5.05)).toEqual(-5);
...
...
uni_modules/uts-tests/utssdk/String.uts
浏览文件 @
4f39a3f7
...
@@ -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 {
...
@@ -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
浏览文件 @
4f39a3f7
...
@@ -170,7 +170,7 @@ export function testUTSJSONObject() : Result {
...
@@ -170,7 +170,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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录