Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
8a80ff86
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看板
提交
8a80ff86
编写于
6月 26, 2024
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复hello uts 编译告警
上级
813ac9fd
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
58 addition
and
54 deletion
+58
-54
pages/advance/advance.vue
pages/advance/advance.vue
+11
-11
uni_modules/uts-advance/utssdk/app-android/index.uts
uni_modules/uts-advance/utssdk/app-android/index.uts
+1
-1
uni_modules/uts-platform-api/utssdk/app-android/index.uts
uni_modules/uts-platform-api/utssdk/app-android/index.uts
+1
-0
uni_modules/uts-syntaxcase/utssdk/index.uts
uni_modules/uts-syntaxcase/utssdk/index.uts
+1
-1
uni_modules/uts-tests/utssdk/JSON.uts
uni_modules/uts-tests/utssdk/JSON.uts
+22
-21
uni_modules/uts-tests/utssdk/JSON_large.uts
uni_modules/uts-tests/utssdk/JSON_large.uts
+2
-2
uni_modules/uts-tests/utssdk/Number.uts
uni_modules/uts-tests/utssdk/Number.uts
+7
-4
uni_modules/uts-tests/utssdk/String.uts
uni_modules/uts-tests/utssdk/String.uts
+10
-10
uni_modules/uts-tests/utssdk/UTSJSONObject.uts
uni_modules/uts-tests/utssdk/UTSJSONObject.uts
+1
-1
uni_modules/uts-tests/utssdk/console.uts
uni_modules/uts-tests/utssdk/console.uts
+2
-3
未找到文件。
pages/advance/advance.vue
浏览文件 @
8a80ff86
...
@@ -221,7 +221,7 @@
...
@@ -221,7 +221,7 @@
quitApp
()
quitApp
()
},
},
testOpenFileWithProvider
()
{
testOpenFileWithProvider
()
{
openFileWithProvider
(
"
apps/__UNI__70BE9D0/www/static/logo.png
"
)
openFileWithProvider
()
},
},
testArrayConvert
()
{
testArrayConvert
()
{
let
convertRet
=
arrayConvert
()
let
convertRet
=
arrayConvert
()
...
...
uni_modules/uts-advance/utssdk/app-android/index.uts
浏览文件 @
8a80ff86
...
@@ -510,7 +510,7 @@ export function arrayConvert():boolean{
...
@@ -510,7 +510,7 @@ export function arrayConvert():boolean{
}
}
export function openFileWithProvider(
url:String
){
export function openFileWithProvider(){
let file = new File(UTSAndroid.getResourcePath("static/logo.png"))
let file = new File(UTSAndroid.getResourcePath("static/logo.png"))
const uri = UTSAndroid.getFileProviderUri(file)
const uri = UTSAndroid.getFileProviderUri(file)
console.log("uri",uri.toString())
console.log("uri",uri.toString())
...
...
uni_modules/uts-platform-api/utssdk/app-android/index.uts
浏览文件 @
8a80ff86
...
@@ -168,6 +168,7 @@ export function gotoSystemPermissionActivityTest() {
...
@@ -168,6 +168,7 @@ export function gotoSystemPermissionActivityTest() {
/**
/**
* 跳转系统拍照界面,并触发相关生命周期测试
* 跳转系统拍照界面,并触发相关生命周期测试
*/
*/
@Suppress("DEPRECATION")
export function gotoCameraTake(imageDone : (event : string) => void) : boolean {
export function gotoCameraTake(imageDone : (event : string) => void) : boolean {
let permissionNeed = ["android.permission.CAMERA"]
let permissionNeed = ["android.permission.CAMERA"]
...
...
uni_modules/uts-syntaxcase/utssdk/index.uts
浏览文件 @
8a80ff86
...
@@ -177,7 +177,7 @@ import WindowManager from 'android.view.WindowManager';
...
@@ -177,7 +177,7 @@ import WindowManager from 'android.view.WindowManager';
import
ActionMode
from
'android.view.ActionMode'
;
import
ActionMode
from
'android.view.ActionMode'
;
// export let onCallBackChange: (event: string) => void = (res) => {};
// export let onCallBackChange: (event: string) => void = (res) => {};
let
callback
:
(
eventLog
:
string
)
=>
void
=
(
res
)
=>
{
};
let
callback
:
(
eventLog
:
string
)
=>
void
=
(
_
)
=>
{
};
export
function
onCallbackChange
(
fn
:
(
eventLog
:
string
)
=>
void
)
{
export
function
onCallbackChange
(
fn
:
(
eventLog
:
string
)
=>
void
)
{
callback
=
fn
callback
=
fn
...
...
uni_modules/uts-tests/utssdk/JSON.uts
浏览文件 @
8a80ff86
...
@@ -119,8 +119,8 @@ export function testJSON() : Result {
...
@@ -119,8 +119,8 @@ export function testJSON() : Result {
test('parseObject', () => {
test('parseObject', () => {
const json = `{"result":true, "count":42}`;
const json = `{"result":true, "count":42}`;
const obj = JSON.parseObject(json);
const obj = JSON.parseObject(json);
expect(obj
!
["count"]).toEqual(42);
expect(obj
?.
["count"]).toEqual(42);
expect(obj
!
["result"] as boolean).toEqual(true);
expect(obj
?.
["result"] as boolean).toEqual(true);
expect(JSON.parseObject('{}')!).toEqual({});
expect(JSON.parseObject('{}')!).toEqual({});
...
@@ -152,10 +152,11 @@ export function testJSON() : Result {
...
@@ -152,10 +152,11 @@ export function testJSON() : Result {
expect(array2).toEqual([1, "hello world", 3]);
expect(array2).toEqual([1, "hello world", 3]);
// #ifdef APP-ANDROID
const json3 = `[{"name":"John","id":"30"},{"name":"jack","id":"21"}]`;
const json3 = `[{"name":"John","id":"30"},{"name":"jack","id":"21"}]`;
const array3 = JSON.parseArray<UTSJSONObject>(json3);
const array3 = JSON.parseArray<UTSJSONObject>(json3);
//
expect((array3![0])["name"]).toEqual("John");
expect((array3![0])["name"]).toEqual("John");
// #endif
})
})
test('merge-test-1', () => {
test('merge-test-1', () => {
...
@@ -181,13 +182,13 @@ export function testJSON() : Result {
...
@@ -181,13 +182,13 @@ export function testJSON() : Result {
// #endif
// #endif
})
})
test('stringify', () => {
test('stringify', () => {
const obj = { name: 'John', age: 30 };
// #ifdef APP-ANDROID
const json = JSON.stringify(obj);
// expect(json).toEqual('{"name":"John","age":30}');
const obj1 = { name: 'John', age: 30, address: { city: 'New York', country: 'USA' } };
const obj1 = { name: 'John', age: 30, address: { city: 'New York', country: 'USA' } };
const json1 = JSON.stringify(obj1);
const json1 = JSON.stringify(obj1);
// expect(json1).toEqual('{"address":{"country":"USA","city":"New York"},"name":"John","age":30}');
expect(json1).toEqual('{"address":{"country":"USA","city":"New York"},"name":"John","age":30}');
// #endif
const obj2 = ['apple', 'banana', 'cherry'];
const obj2 = ['apple', 'banana', 'cherry'];
const json2 = JSON.stringify(obj2);
const json2 = JSON.stringify(obj2);
...
@@ -223,6 +224,7 @@ export function testJSON() : Result {
...
@@ -223,6 +224,7 @@ export function testJSON() : Result {
* add since 2023-09-23
* add since 2023-09-23
* 部分出错过的示例场景
* 部分出错过的示例场景
*/
*/
// #ifdef APP-ANDROID
const arr = [{
const arr = [{
"$method": "collection",
"$method": "collection",
"$param": ["type"] as Array<any>,
"$param": ["type"] as Array<any>,
...
@@ -241,26 +243,25 @@ export function testJSON() : Result {
...
@@ -241,26 +243,25 @@ export function testJSON() : Result {
let ret = JSON.stringify({
let ret = JSON.stringify({
$db: arr
$db: arr
})
})
//
expect(ret).toEqual('{"$db":[{"$method":"collection","$param":["type"]},{"$method":"add","$param":[[{"num":2,"tag":"default-tag"},{"num":3,"tag":"default-tag"}]]}]}')
expect(ret).toEqual('{"$db":[{"$method":"collection","$param":["type"]},{"$method":"add","$param":[[{"num":2,"tag":"default-tag"},{"num":3,"tag":"default-tag"}]]}]}')
type Msg = {
type Msg = {
id : string,
id : string,
method : string,
method : string,
params : any
params : any
}
}
//
type CallUniMethodParams = {
type CallUniMethodParams = {
//
method : string
method : string
//
args : com.alibaba.fastjson.JSONArray
args : com.alibaba.fastjson.JSONArray
//
}
}
const msg = `{"id":"6fd6ca73-c313-48ac-ad30-87ff4eba2be8","method":"App.callUniMethod","params":{"method":"reLaunch","args":[{"url":"/pages/index/index"}]}}`
const msg = `{"id":"6fd6ca73-c313-48ac-ad30-87ff4eba2be8","method":"App.callUniMethod","params":{"method":"reLaunch","args":[{"url":"/pages/index/index"}]}}`
const jsonRet2 = JSON.parse<Msg>(msg)!
const jsonRet2 = JSON.parse<Msg>(msg)!
const paramsStr = JSON.stringify(jsonRet2.params)
const paramsStr = JSON.stringify(jsonRet2.params)
console.log(paramsStr)
console.log(paramsStr)
//expect(paramsStr).toEqual('{"method":"reLaunch","args":[{"url":"/pages/index/index"}]}')
expect(paramsStr).toEqual('{"method":"reLaunch","args":[{"url":"/pages/index/index"}]}')
// const params = JSON.parse<CallUniMethodParams>(paramsStr)!
const params = JSON.parse<CallUniMethodParams>(paramsStr)!
//console.warn('params', JSON.stringify(params))
expect(JSON.stringify(params)).toEqual('{"method":"reLaunch","args":[{"url":"/pages/index/index"}]}')
//expect(JSON.stringify(params)).toEqual('{"method":"reLaunch","args":[{"url":"/pages/index/index"}]}')
class Stage {
class Stage {
...
@@ -275,9 +276,9 @@ export function testJSON() : Result {
...
@@ -275,9 +276,9 @@ export function testJSON() : Result {
const obj22 = {
const obj22 = {
data: [new Stage()] as Array<any>
data: [new Stage()] as Array<any>
} as UTSJSONObject
} as UTSJSONObject
expect(JSON.stringify(obj22)).toEqual('{"data":[{}]}')
console.log(JSON.stringify(obj22))
// #endif
// expect(JSON.stringify(obj22)).toEqual('{"data":[{}]}')
type A = {
type A = {
inserted : number
inserted : number
...
...
uni_modules/uts-tests/utssdk/JSON_large.uts
浏览文件 @
8a80ff86
...
@@ -22527,7 +22527,7 @@ export function testJSONLarge() : Result {
...
@@ -22527,7 +22527,7 @@ export function testJSONLarge() : Result {
let spendTime = System.currentTimeMillis() - startTime
let spendTime = System.currentTimeMillis() - startTime
console.log('指定类型转换耗时',spendTime,listdata!.length)
console.log('指定类型转换耗时',spendTime,listdata!.length)
expect(listdata
!
.length).toEqual(33);
expect(listdata.length).toEqual(33);
expect(spendTime < 500).toEqual(true);
expect(spendTime < 500).toEqual(true);
startTime = System.currentTimeMillis()
startTime = System.currentTimeMillis()
...
@@ -22535,7 +22535,7 @@ export function testJSONLarge() : Result {
...
@@ -22535,7 +22535,7 @@ export function testJSONLarge() : Result {
spendTime = System.currentTimeMillis() - startTime
spendTime = System.currentTimeMillis() - startTime
expect(listdata2 instanceof Array).toEqual(true);
expect(listdata2 instanceof Array).toEqual(true);
let parseArray = listdata2 as Array
let parseArray = listdata2 as Array
expect(parseArray
!
.length).toEqual(33);
expect(parseArray.length).toEqual(33);
expect(spendTime < 300).toEqual(true);
expect(spendTime < 300).toEqual(true);
console.log('不指定类型转换耗时',spendTime,listdata2)
console.log('不指定类型转换耗时',spendTime,listdata2)
...
...
uni_modules/uts-tests/utssdk/Number.uts
浏览文件 @
8a80ff86
import { describe, test, expect, Result } from './tests.uts'
import { describe, test, expect, Result } from './tests.uts'
@Suppress("UnsafeCall")
export function testNumber() : Result {
export function testNumber() : Result {
return describe("Number", () => {
return describe("Number", () => {
...
@@ -69,6 +70,8 @@ export function testNumber() : Result {
...
@@ -69,6 +70,8 @@ export function testNumber() : Result {
// #endif
// #endif
})
})
test('number-from-json-parse', () => {
test('number-from-json-parse', () => {
type A = {
type A = {
a:number
a:number
...
@@ -79,10 +82,10 @@ export function testNumber() : Result {
...
@@ -79,10 +82,10 @@ export function testNumber() : Result {
expect(aj?.a == 1.0).toEqual(true);
expect(aj?.a == 1.0).toEqual(true);
expect(aj?.a == 1.0 as number).toEqual(true);
expect(aj?.a == 1.0 as number).toEqual(true);
// #ifdef APP-ANDROID
// #ifdef APP-ANDROID
expect(
aj?.a === 1
).toEqual(true);
expect(
numberEquals(aj?.a,1)
).toEqual(true);
expect(
aj?.a === 1 as number
).toEqual(true);
expect(
numberEquals(aj?.a,1 as number)
).toEqual(true);
expect(
aj?.a === 1.0
).toEqual(true);
expect(
numberEquals(aj?.a,1.0)
).toEqual(true);
expect(
aj?.a === 1.0 as number
).toEqual(true);
expect(
numberEquals(aj?.a,1.0 as number)
).toEqual(true);
let ki:Int = 1;
let ki:Int = 1;
let kd:Double = 1.0;
let kd:Double = 1.0;
let kf:Float = (1.0).toFloat();
let kf:Float = (1.0).toFloat();
...
...
uni_modules/uts-tests/utssdk/String.uts
浏览文件 @
8a80ff86
...
@@ -116,27 +116,27 @@ export function testString(): Result {
...
@@ -116,27 +116,27 @@ export function testString(): Result {
const str = 'The quick brown fox jumps over the lazy dog. It barked.';
const str = 'The quick brown fox jumps over the lazy dog. It barked.';
const result = str.match(new RegExp('[A-Z]', 'g'));
const result = str.match(new RegExp('[A-Z]', 'g'));
// expect(result!.length).toEqual(2);
// expect(result!.length).toEqual(2);
expect(result
!
[0]).toEqual("T");
expect(result
?.
[0]).toEqual("T");
expect(result
!
[1]).toEqual("I");
expect(result
?.
[1]).toEqual("I");
const result2 = str.match(new RegExp('[A-Z]'));
const result2 = str.match(new RegExp('[A-Z]'));
// expect(result2!.length).toEqual(1);
// expect(result2!.length).toEqual(1);
expect(result2
!
[0]).toEqual("T");
expect(result2
?.
[0]).toEqual("T");
// #ifdef APP-ANDROID
// #ifdef APP-ANDROID
const gradientString = 'linear-gradient(to right, rgb(255, 0, 0), #00FF00, hsl(120, 100%, 50%))';
const gradientString = 'linear-gradient(to right, rgb(255, 0, 0), #00FF00, hsl(120, 100%, 50%))';
const pattern = /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|#([a-fA-F0-9]{2}){3}|hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)/g;
const pattern = /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|#([a-fA-F0-9]{2}){3}|hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)/g;
const result3 = gradientString.match(pattern);
const result3 = gradientString.match(pattern);
expect(result3
!
.length).toEqual(3);
expect(result3
?
.length).toEqual(3);
expect(result3
!
[0]).toEqual("rgb(255, 0, 0)");
expect(result3
?.
[0]).toEqual("rgb(255, 0, 0)");
expect(result3
!
[2]).toEqual("hsl(120, 100%, 50%)");
expect(result3
?.
[2]).toEqual("hsl(120, 100%, 50%)");
const pattern2 = /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|#([a-fA-F0-9]{2}){3}|hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)/;
const pattern2 = /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|#([a-fA-F0-9]{2}){3}|hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)/;
const result4 = gradientString.match(pattern2);
const result4 = gradientString.match(pattern2);
expect(result4
!
.length).toEqual(8);
expect(result4
?
.length).toEqual(8);
expect(result4
!
[0]).toEqual("rgb(255, 0, 0)");
expect(result4
?.
[0]).toEqual("rgb(255, 0, 0)");
expect(result4
!
[1]).toEqual("255");
expect(result4
?.
[1]).toEqual("255");
expect(result4
!
[2]).toEqual("0");
expect(result4
?.
[2]).toEqual("0");
const url = '';
const url = '';
...
...
uni_modules/uts-tests/utssdk/UTSJSONObject.uts
浏览文件 @
8a80ff86
...
@@ -21,7 +21,7 @@ export function testUTSJSONObject() : Result {
...
@@ -21,7 +21,7 @@ export function testUTSJSONObject() : Result {
const source = { b: 4, c: 5 };
const source = { b: 4, c: 5 };
const returnedTarget = UTSJSONObject.assign(target, source);
const returnedTarget = UTSJSONObject.assign(target, source);
expect(returnedTarget
!
.toMap().size).toEqual(3);
expect(returnedTarget.toMap().size).toEqual(3);
console.log(returnedTarget)
console.log(returnedTarget)
// #endif
// #endif
})
})
...
...
uni_modules/uts-tests/utssdk/console.uts
浏览文件 @
8a80ff86
...
@@ -27,10 +27,9 @@ export function testConsole() : Result {
...
@@ -27,10 +27,9 @@ export function testConsole() : Result {
// #ifdef APP-ANDROID
// #ifdef APP-ANDROID
let aj2 = JSON.parse('{"a":1}') as UTSJSONObject;
let aj2 = JSON.parse('{"a":1}') as UTSJSONObject;
console.log(aj2!['a'])
expect(obtainInnerObject(aj2
!
['a']).get("type")).toEqual("number");
expect(obtainInnerObject(aj2['a']).get("type")).toEqual("number");
expect(obtainInnerObject(aj2
!
['a']).get("subType")).toEqual("number");
expect(obtainInnerObject(aj2['a']).get("subType")).toEqual("number");
// #endif
// #endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录