Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
3ab9e700
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看板
提交
3ab9e700
编写于
10月 21, 2023
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into alpha
上级
c2c4e73e
ec5ca379
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
285 addition
and
123 deletion
+285
-123
pages/SDKIntegration/SDKIntegration.uvue
pages/SDKIntegration/SDKIntegration.uvue
+6
-21
uni_modules/uts-animation-view/package.json
uni_modules/uts-animation-view/package.json
+1
-1
uni_modules/uts-animation-view/utssdk/app-android/index.vue
uni_modules/uts-animation-view/utssdk/app-android/index.vue
+5
-5
uni_modules/uts-platform-api/utssdk/app-android/index.uts
uni_modules/uts-platform-api/utssdk/app-android/index.uts
+56
-19
uni_modules/uts-tests/utssdk/Global.uts
uni_modules/uts-tests/utssdk/Global.uts
+84
-0
uni_modules/uts-tests/utssdk/KeyWord.uts
uni_modules/uts-tests/utssdk/KeyWord.uts
+69
-29
uni_modules/uts-tests/utssdk/Matchers.uts
uni_modules/uts-tests/utssdk/Matchers.uts
+11
-0
uni_modules/uts-tests/utssdk/Number.uts
uni_modules/uts-tests/utssdk/Number.uts
+17
-34
uni_modules/uts-tests/utssdk/Operators.uts
uni_modules/uts-tests/utssdk/Operators.uts
+26
-11
uni_modules/uts-tests/utssdk/String.uts
uni_modules/uts-tests/utssdk/String.uts
+4
-0
uni_modules/uts-tests/utssdk/index.uts
uni_modules/uts-tests/utssdk/index.uts
+6
-3
未找到文件。
pages/SDKIntegration/SDKIntegration.uvue
浏览文件 @
3ab9e700
...
@@ -67,29 +67,14 @@
...
@@ -67,29 +67,14 @@
})
})
},
},
gotoLottie: function () {
gotoLottie: function () {
// if (checkHasLottieIntegration()) {
uni.showToast({
// uni.navigateTo({
title:'暂时不支持uni-appx'
// url: '/pages/SDKIntegration/Lottie/index'
})
// })
// } else {
// uni.showToast({
// icon: 'none',
// title: '需要在自定义基座中运行'
// })
// }
},
},
gotoTencentLocation: function () {
gotoTencentLocation: function () {
// let ret = checkHasIntegration();
uni.showToast({
// if (!ret) {
title:'暂时不支持uni-appx'
// uni.showToast({
})
// icon: 'none',
// title: '需要在自定义基座中运行'
// })
// } else {
// uni.navigateTo({
// url: '/pages/SDKIntegration/TencentLocation/TencentLocation'
// })
// }
},
},
gotoTencentMap: function () {
gotoTencentMap: function () {
uni.navigateTo({
uni.navigateTo({
...
...
uni_modules/uts-animation-view/package.json
浏览文件 @
3ab9e700
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
],
],
"repository"
:
""
,
"repository"
:
""
,
"engines"
:
{
"engines"
:
{
"HBuilderX"
:
"^3.
6.8
"
"HBuilderX"
:
"^3.
94
"
},
},
"dcloudext"
:
{
"dcloudext"
:
{
"type"
:
"uts"
,
"type"
:
"uts"
,
...
...
uni_modules/uts-animation-view/utssdk/app-android/index.vue
浏览文件 @
3ab9e700
...
@@ -19,17 +19,17 @@
...
@@ -19,17 +19,17 @@
this
.
comp
=
com
this
.
comp
=
com
}
}
override
onAnimationStart
(
animation
:
Animator
|
null
)
{}
override
onAnimationStart
(
animation
:
Animator
)
{}
override
onAnimationEnd
(
animation
:
Animator
|
null
,
isReverse
:
Boolean
)
{
override
onAnimationEnd
(
animation
:
Animator
,
isReverse
:
Boolean
)
{
this
.
comp
.
$emit
(
"
bindended
"
)
this
.
comp
.
$emit
(
"
bindended
"
)
}
}
override
onAnimationEnd
(
animation
:
Animator
|
null
)
{}
override
onAnimationEnd
(
animation
:
Animator
)
{}
override
onAnimationCancel
(
animation
:
Animator
|
null
)
{}
override
onAnimationCancel
(
animation
:
Animator
)
{}
override
onAnimationRepeat
(
animation
:
Animator
|
null
)
{}
override
onAnimationRepeat
(
animation
:
Animator
)
{}
}
}
//原生提供以下属性或方法的实现
//原生提供以下属性或方法的实现
...
...
uni_modules/uts-platform-api/utssdk/app-android/index.uts
浏览文件 @
3ab9e700
...
@@ -63,9 +63,16 @@ export function privacyStateTest(callback : (ret : boolean, desc : string) => vo
...
@@ -63,9 +63,16 @@ export function privacyStateTest(callback : (ret : boolean, desc : string) => vo
* UTSAndroid.getAppTempPath 测试示例
* UTSAndroid.getAppTempPath 测试示例
*/
*/
export function getAppTempPathTest() : boolean {
export function getAppTempPathTest() : boolean {
console.log(UTSAndroid.getAppTempPath())
// 1.0 的路径
if (UTSAndroid.getAppTempPath()!.contains("data/io.dcloud.HBuilder/apps/HBuilder/temp")) {
if (UTSAndroid.getAppTempPath()!.contains("data/io.dcloud.HBuilder/apps/HBuilder/temp")) {
return true
return true
}
}
// 2.0的路径
if (UTSAndroid.getAppTempPath()!.contains("cache/temp")) {
return true
}
return false
return false
}
}
...
@@ -74,19 +81,22 @@ export function getAppTempPathTest() : boolean {
...
@@ -74,19 +81,22 @@ export function getAppTempPathTest() : boolean {
*/
*/
export function typeofClickTest() : boolean {
export function typeofClickTest() : boolean {
if (UTSAndroid.typeof('hello wrold') != 'string') {
if ((typeof 'hello wrold') != 'string') {
return false
return false
}
}
if (UTSAndroid.typeof(3.1415926) != 'number') {
if ((typeof 3.1415) != 'Double') {
return false
return false
}
}
if (UTSAndroid.typeof(false) != 'boolean') {
if ((typeof false) != 'boolean') {
return false
return false
}
}
if (
UTSAndroid.typeof(
true) != 'boolean') {
if (
(typeof
true) != 'boolean') {
return false
return false
}
}
if (
UTSAndroid.typeof(
new Date()) != 'object') {
if (
(typeof
new Date()) != 'object') {
return false
return false
}
}
...
@@ -258,13 +268,24 @@ export function unRegLifecycle() {
...
@@ -258,13 +268,24 @@ export function unRegLifecycle() {
*/
*/
export function arrayPermissionFlowTest(callback : (ret : boolean, desc : string) => void) {
export function arrayPermissionFlowTest(callback : (ret : boolean, desc : string) => void) {
if("io.dcloud.uniappx" != UTSAndroid.getAppContext()?.packageName && "io.dcloud.HBuilder" != UTSAndroid.getAppContext()?.packageName){
/**
* 说明是自定义基座,不支持权限测试
*/
uni.showToast({
title:'自定义基座不支持当前测试'
})
return
}
/**
/**
* 同时申请日历和联系人权限
* 同时申请日历和联系人权限
*/
*/
let permissionNeed = utsArrayOf("android.permission.
READ_CALENDAR", "android.permission.WRITE_CALENDAR", "android.permission.READ_CONTACTS", "android.permission.WRITE_CONTACTS", "android.permission.GET_ACCOUNTS
")
let permissionNeed = utsArrayOf("android.permission.
WRITE_EXTERNAL_STORAGE", "android.permission.ACCESS_FINE_LOCATION", "android.permission.READ_PHONE_STATE
")
if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) {
if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) {
callback(false, "已具备
日历/联系人
权限")
callback(false, "已具备
请求
权限")
return;
return;
}
}
...
@@ -299,23 +320,23 @@ export function getDeviceInfoTest():string {
...
@@ -299,23 +320,23 @@ export function getDeviceInfoTest():string {
let info = ''
let info = ''
info += 'isUniMp: '+UTSAndroid.isUniMp() + "\n ";
info += 'isUniMp: '+UTSAndroid.isUniMp() + "\n ";
info += 'getAppDarkMode: '+UTSAndroid.getAppDarkMode() + "\n ";
info += 'getAppDarkMode: '+UTSAndroid.getAppDarkMode() + "\n ";
info += 'getLanguageInfo: '+
UTSAndroid.getLanguageInfo(UTSAndroid.getAppContext()!!
) + "\n ";
info += 'getLanguageInfo: '+
JSON.stringify(UTSAndroid.getLanguageInfo(UTSAndroid.getAppContext()!!)
) + "\n ";
info += 'getWebViewInfo: '+
UTSAndroid.getWebViewInfo(UTSAndroid.getAppContext()!!
) + "\n ";
info += 'getWebViewInfo: '+
JSON.stringify(UTSAndroid.getWebViewInfo(UTSAndroid.getAppContext()!!)
) + "\n ";
info += 'getDeviceID: '+UTSAndroid.getDeviceID(UTSAndroid.getAppContext()!!) + "\n ";
info += 'getDeviceID: '+UTSAndroid.getDeviceID(UTSAndroid.getAppContext()!!) + "\n ";
info += 'getOAID: '+UTSAndroid.getOAID() + "\n ";
info += 'getOAID: '+UTSAndroid.getOAID() + "\n ";
info += 'getInnerVersion: '+UTSAndroid.getInnerVersion() + "\n ";
info += 'getInnerVersion: '+UTSAndroid.getInnerVersion() + "\n ";
info += 'getUniCompileVersion: '+UTSAndroid.getUniCompileVersion() + "\n ";
info += 'getUniCompileVersion: '+UTSAndroid.getUniCompileVersion() + "\n ";
info += 'getUniRuntimeVersion: '+UTSAndroid.getUniRuntimeVersion() + "\n ";
info += 'getUniRuntimeVersion: '+UTSAndroid.getUniRuntimeVersion() + "\n ";
info += 'getAppId: '+UTSAndroid.getAppId() + "\n ";
info += 'getAppId: '+UTSAndroid.getAppId() + "\n ";
info += 'getAppVersion: '+
UTSAndroid.getAppVersion(
) + "\n ";
info += 'getAppVersion: '+
JSON.stringify(UTSAndroid.getAppVersion()
) + "\n ";
info += 'getAppName: '+UTSAndroid.getAppName() + "\n ";
info += 'getAppName: '+UTSAndroid.getAppName() + "\n ";
info += 'getOsTheme: '+UTSAndroid.getOsTheme() + "\n ";
info += 'getOsTheme: '+UTSAndroid.getOsTheme() + "\n ";
info += 'getScreenInfo: '+
UTSAndroid.getScreenInfo(
) + "\n ";
info += 'getScreenInfo: '+
JSON.stringify(UTSAndroid.getScreenInfo()
) + "\n ";
info += 'getStatusBarHeight: '+UTSAndroid.getStatusBarHeight() + "\n ";
info += 'getStatusBarHeight: '+UTSAndroid.getStatusBarHeight() + "\n ";
info += 'isTitleNViewShow: '+UTSAndroid.isTitleNViewShow() + "\n ";
info += 'isTitleNViewShow: '+UTSAndroid.isTitleNViewShow() + "\n ";
info += 'isTabBarShow: '+UTSAndroid.isTabBarShow() + "\n ";
info += 'isTabBarShow: '+UTSAndroid.isTabBarShow() + "\n ";
info += 'getWindowHeight: '+UTSAndroid.getWindowHeight() + "\n ";
info += 'getWindowHeight: '+UTSAndroid.getWindowHeight() + "\n ";
info += 'getSafeAreaInsets: '+
UTSAndroid.getSafeAreaInsets(
) + "\n ";
info += 'getSafeAreaInsets: '+
JSON.stringify(UTSAndroid.getSafeAreaInsets()
) + "\n ";
info += 'isUniAppX: '+UTSAndroid.isUniAppX() + "\n ";
info += 'isUniAppX: '+UTSAndroid.isUniAppX() + "\n ";
return info
return info
...
@@ -367,10 +388,18 @@ export function convert2AbsFullPathTest() : boolean {
...
@@ -367,10 +388,18 @@ export function convert2AbsFullPathTest() : boolean {
return false;
return false;
}
}
if("io.dcloud.uniappx" == UTSAndroid.getAppContext()?.packageName || "io.dcloud.HBuilder" == UTSAndroid.getAppContext()?.packageName){
/**
* 只有标准基座,校验这个选项
*/
if (!resourcePath.contains("Android/data/io.dcloud")) {
if (!resourcePath.contains("Android/data/io.dcloud")) {
console.log("路径转换结果错误")
console.log("路径转换结果错误")
return false;
return false;
}
}
}
let sdcardPath = UTSAndroid.convert2AbsFullPath(resourcePath)
let sdcardPath = UTSAndroid.convert2AbsFullPath(resourcePath)
console.log(sdcardPath)
console.log(sdcardPath)
...
@@ -390,18 +419,26 @@ export function convert2AbsFullPathTest() : boolean {
...
@@ -390,18 +419,26 @@ export function convert2AbsFullPathTest() : boolean {
*/
*/
export function singlePermissionFlowTest(callback : (ret : boolean, desc : string) => void) {
export function singlePermissionFlowTest(callback : (ret : boolean, desc : string) => void) {
let permissionNeed = utsArrayOf("android.permission.RECORD_AUDIO")
if("io.dcloud.uniappx" != UTSAndroid.getAppContext()?.packageName && "io.dcloud.HBuilder" != UTSAndroid.getAppContext()?.packageName){
/**
* 说明是自定义基座,不支持权限测试
*/
uni.showToast({
title:'自定义基座不支持当前测试'
})
return
}
let permissionNeed = utsArrayOf("android.permission.READ_PHONE_STATE")
if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) {
if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) {
callback(false, "
预期当前不具备 录音的
权限")
callback(false, "
已具备
权限")
return;
return;
}
}
UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, permissionNeed, function (allRight : boolean, _grantedList : string[]) {
UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, permissionNeed, function (allRight : boolean, _grantedList : string[]) {
if (allRight) {
if (allRight) {
// 交给目前的location 引擎,真实执行
// 测试权限api 返回值
// 测试权限api 返回值
if (!UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) {
if (!UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) {
// 预期当前基座具备了读写日历的权限
callback(false, "权限请求完成,getSystemPermissionDenied 失败")
callback(false, "权限请求完成,getSystemPermissionDenied 失败")
return;
return;
}
}
...
...
uni_modules/uts-tests/utssdk/Global.uts
0 → 100644
浏览文件 @
3ab9e700
import { describe, test, expect, Result } from './tests.uts'
export function testGlobal(): Result {
return describe("Global", () => {
test('parseInt', () => {
expect(parseInt("123.456")).toEqual(123);
expect(parseInt("123")).toEqual(123);
expect(parseInt("123", 10)).toEqual(123);
expect(parseInt(" 123", 10)).toEqual(123);
expect(parseInt("077")).toEqual(77);
expect(parseInt("1.9")).toEqual(1);
expect(parseInt("ff", 16)).toEqual(255);
expect(parseInt("0xFF", 0)).toEqual(255);
expect(parseInt("0xFF", 16)).toEqual(255);
expect(parseInt("0xFF")).toEqual(255);
expect(parseInt("0xFF", 10)).toEqual(0);
expect(parseInt("0xF", 16)).toEqual(15);
expect(parseInt("F", 16)).toEqual(15);
expect(parseInt("021", 8)).toEqual(17);
expect(parseInt("015", 10)).toEqual(15);
expect(parseInt("15,123", 10)).toEqual(15);
expect(parseInt("FXX123.99", 16)).toEqual(15);
expect(parseInt("1111", 2)).toEqual(15);
expect(parseInt("15 * 3", 10)).toEqual(15);
expect(parseInt("15e2", 10)).toEqual(15);
expect(parseInt("15px", 10)).toEqual(15);
expect(parseInt("12", 13)).toEqual(15);
expect(parseInt("17", 8)).toEqual(15);
expect(isNaN(parseInt("a"))).toEqual(true)
expect(parseInt("a", 16)).toEqual(10)
expect(isNaN(parseInt("345", 2))).toEqual(true)
expect(isNaN(parseInt("hello"))).toEqual(true)
expect(parseInt("6.022e23")).toEqual(6)
expect(parseInt("9223372036854775807")).toEqual(9.223372036854778e+18)
expect(parseInt("9223372036854775807000")).toEqual(9.223372036854777e+21)
expect(parseInt("922337203685477580700099999999999999999999999999999999999999999999999999999999999999999")).toEqual(9.223372036854776e+86)
expect(parseInt("50") / 100).toEqualNumber(0.5);
expect(parseInt("500") / 100).toEqualNumber(5);
})
test('parseFloat', () => {
expect(parseFloat("11.20")).toEqual(11.2);
expect(parseFloat("3.14")).toEqual(3.14);
expect(parseFloat(" 3.14 ")).toEqual(3.14);
expect(parseFloat("314e-2")).toEqual(3.14);
expect(parseFloat("0.0314E+2")).toEqual(3.14);
expect(parseFloat("3.14some non-digit characters")).toEqual(3.14);
expect(parseFloat("100") / 50).toEqualNumber(2);
expect(parseFloat("105") / 50).toEqual(2.1);
})
test('encodeURI', () => {
expect(encodeURI("你好")).toEqual('%E4%BD%A0%E5%A5%BD')
expect(encodeURI("你好+22")).toEqual('%E4%BD%A0%E5%A5%BD+22')
expect(encodeURI("你;/=好+22")).toEqual('%E4%BD%A0;/=%E5%A5%BD+22')
expect(encodeURI("https://demo.dcloud.net.cn/mock/最新/12")).toEqual('https://demo.dcloud.net.cn/mock/%E6%9C%80%E6%96%B0/12')
})
test('decodeURI', () => {
expect(decodeURI('%E4%BD%A0%E5%A5%BD')).toEqual('你好')
expect(decodeURI("%E4%BD%A0%E5%A5%BD+22")).toEqual('你好+22')
expect(decodeURI("%E4%BD%A0;/=%E5%A5%BD+22")).toEqual('你;/=好+22')
expect(decodeURI("https://demo.dcloud.net.cn/mock/%E6%9C%80%E6%96%B0/12")).toEqual('https://demo.dcloud.net.cn/mock/最新/12')
})
test('encodeURIComponent', () => {
expect(encodeURIComponent("你好")).toEqual('%E4%BD%A0%E5%A5%BD')
expect(encodeURIComponent("你好+22")).toEqual('%E4%BD%A0%E5%A5%BD%2B22')
expect(encodeURIComponent("你;/=好+22")).toEqual('%E4%BD%A0%3B%2F%3D%E5%A5%BD%2B22')
expect(encodeURIComponent("https://demo.dcloud.net.cn/mock/最新/12")).toEqual('https%3A%2F%2Fdemo.dcloud.net.cn%2Fmock%2F%E6%9C%80%E6%96%B0%2F12')
})
test('decodeURIComponent', () => {
expect(decodeURIComponent('%E4%BD%A0%E5%A5%BD')).toEqual('你好')
expect(decodeURIComponent('%E4%BD%A0%E5%A5%BD%2B22')).toEqual('你好+22')
expect(decodeURIComponent('%E4%BD%A0%3B%2F%3D%E5%A5%BD%2B22')).toEqual('你;/=好+22')
expect(decodeURIComponent("https://demo.dcloud.net.cn/mock/%E6%9C%80%E6%96%B0/12")).toEqual('https://demo.dcloud.net.cn/mock/最新/12')
})
})
}
uni_modules/uts-tests/utssdk/KeyWord.uts
浏览文件 @
3ab9e700
...
@@ -5,37 +5,67 @@ class User{
...
@@ -5,37 +5,67 @@ class User{
age:number = 0
age:number = 0
}
}
export function testKeyWord(): Result {
const passcode = "secret passcode";
return describe("KeyWord", () => {
class Parent {
private _name: string = ""; // private是私有的,外部不能访问
get name(): string { // 读取name会触发此拦截器
console.log("start to get parent.name");
return this._name;
}
set name(newName: string) { // 给name赋值会触发此拦截器
console.log("start to set parent.name");
if (passcode == "secret passcode") { // 校验是否有权修改name的值,这里的条件可以修改以方便测试
this._name = newName;
} else {
console.log("Error: set parent.name fail");
}
}
// 静态属性和方法
static age: number = 30
static run(): string {
console.log("this is a static method")
return "static method"
}
// readonly
readonly address: string = ""
weight: number = 80
// constructor
constructor(weight: number) {
console.log("开始实例化")
this.weight = weight
}
// 实例方法
eat(): string {
console.log("this is parent")
return "parent instance method"
}
test('encodeURI', () => {
}
expect(encodeURI("你好")).toEqual('%E4%BD%A0%E5%A5%BD')
expect(encodeURI("你好+22")).toEqual('%E4%BD%A0%E5%A5%BD+22')
expect(encodeURI("你;/=好+22")).toEqual('%E4%BD%A0;/=%E5%A5%BD+22')
expect(encodeURI("https://demo.dcloud.net.cn/mock/最新/12")).toEqual('https://demo.dcloud.net.cn/mock/%E6%9C%80%E6%96%B0/12')
})
test('decodeURI', () => {
class ChildrenTest extends Parent {
expect(decodeURI('%E4%BD%A0%E5%A5%BD')).toEqual('你好')
expect(decodeURI("%E4%BD%A0%E5%A5%BD+22")).toEqual('你好+22')
expect(decodeURI("%E4%BD%A0;/=%E5%A5%BD+22")).toEqual('你;/=好+22')
expect(decodeURI("https://demo.dcloud.net.cn/mock/%E6%9C%80%E6%96%B0/12")).toEqual('https://demo.dcloud.net.cn/mock/最新/12')
})
test('encodeURIComponent', () => {
// override constructor(weight: number) {
expect(encodeURIComponent("你好")).toEqual('%E4%BD%A0%E5%A5%BD')
// super(weight)
expect(encodeURIComponent("你好+22")).toEqual('%E4%BD%A0%E5%A5%BD%2B22')
// }
expect(encodeURIComponent("你;/=好+22")).toEqual('%E4%BD%A0%3B%2F%3D%E5%A5%BD%2B22')
expect(encodeURIComponent("https://demo.dcloud.net.cn/mock/最新/12")).toEqual('https%3A%2F%2Fdemo.dcloud.net.cn%2Fmock%2F%E6%9C%80%E6%96%B0%2F12')
})
test('decodeURIComponent', () => {
override eat(): string {
expect(decodeURIComponent('%E4%BD%A0%E5%A5%BD')).toEqual('你好')
super.eat()
expect(decodeURIComponent('%E4%BD%A0%E5%A5%BD%2B22')).toEqual('你好+22')
return "children instance method"
expect(decodeURIComponent('%E4%BD%A0%3B%2F%3D%E5%A5%BD%2B22')).toEqual('你;/=好+22')
}
expect(decodeURIComponent("https://demo.dcloud.net.cn/mock/%E6%9C%80%E6%96%B0/12")).toEqual('https://demo.dcloud.net.cn/mock/最新/12')
})
// swift 中不能重写父类的存储属性,只能重写父类的计算的属性(本质上是重写计算属性的get set方法)
// #ifndef APP-IOS
override weight = 8
// #endif
}
export function testKeyWord(): Result {
return describe("KeyWord", () => {
test('new', () => {
test('new', () => {
let new1 = new User()
let new1 = new User()
...
@@ -91,6 +121,16 @@ export function testKeyWord(): Result {
...
@@ -91,6 +121,16 @@ export function testKeyWord(): Result {
expect(Array.isArray([1,2,3])).toEqual(true)
expect(Array.isArray([1,2,3])).toEqual(true)
})
})
test('class', () => {
let p = new Parent(20)
p.name = "tom" // 会打印"start to set person.name"
console.log(p.name); // 先打印"start to get person.name",然后打印"tom"
expect(Parent.age).toEqual(30)
expect(Parent.run()).toEqual("static method")
expect(p.eat()).toEqual("parent instance method")
// let c = new ChildrenTest(0)
// expect(c.eat()).toEqual("children instance method")
})
})
})
}
}
uni_modules/uts-tests/utssdk/Matchers.uts
浏览文件 @
3ab9e700
...
@@ -15,6 +15,17 @@ export class Matchers<T> {
...
@@ -15,6 +15,17 @@ export class Matchers<T> {
NSException(name = NSExceptionName.internalInconsistencyException, reason = format(expected, this.actual)).raise()
NSException(name = NSExceptionName.internalInconsistencyException, reason = format(expected, this.actual)).raise()
// #endif
// #endif
}
}
toEqualNumber(expected: T) {
// #ifndef APP-IOS
if (expected == this.actual) {
return
}
// #endif
// #ifdef APP-IOS
this.toEqual(expected)
// #endif
}
}
}
/**
/**
* 数值对比器
* 数值对比器
...
...
uni_modules/uts-tests/utssdk/Number.uts
浏览文件 @
3ab9e700
...
@@ -21,40 +21,23 @@ export function testNumber(): Result {
...
@@ -21,40 +21,23 @@ export function testNumber(): Result {
let obj = {"id":"3be2c600-894c-4231-aa56-82fd989cc961","result":{"result":[num1, num2, num3]}}
let obj = {"id":"3be2c600-894c-4231-aa56-82fd989cc961","result":{"result":[num1, num2, num3]}}
console.log(JSON.stringify(obj))
console.log(JSON.stringify(obj))
})
test('parseInt', () => {
expect(123456.789.toFixed(2)).toEqual("123456.79");
expect(parseInt("123.456")).toEqual(123);
expect(12345600123.789123.toFixed(2)).toEqual("12345600123.79");
expect(parseInt("123")).toEqual(123);
expect((-123456.789).toFixed(5)).toEqual("-123456.78900");
expect(parseInt("123", 10)).toEqual(123);
expect(parseFloat("16688995566.369").toFixed(3)).toEqual("16688995566.369");
expect(parseInt(" 123", 10)).toEqual(123);
// #ifndef APP-IOS
expect(parseInt("077")).toEqual(77);
// android 专有数据类型
expect(parseInt("1.9")).toEqual(1);
let a1 = 56
expect(parseInt("ff", 16)).toEqual(255);
let a2 = -122
expect(parseInt("0xFF", 0)).toEqual(255);
expect(a1.toByte().toFixed(2)).toEqual("56.00");
expect(parseInt("0xFF", 16)).toEqual(255);
expect(a2.toByte().toFixed(2)).toEqual("-122.00");
expect(parseInt("0xFF")).toEqual(255);
expect(parseInt("0xFF", 10)).toEqual(0);
expect(a1.toShort().toFixed(5)).toEqual("56.00000");
expect(parseInt("0xF", 16)).toEqual(15);
expect(a2.toShort().toFixed(5)).toEqual("-122.00000");
expect(parseInt("F", 16)).toEqual(15);
expect(parseInt("021", 8)).toEqual(17);
// #endif
expect(parseInt("015", 10)).toEqual(15);
expect(parseInt("15,123", 10)).toEqual(15);
expect(parseInt("FXX123.99", 16)).toEqual(15);
expect(parseInt("1111", 2)).toEqual(15);
expect(parseInt("15 * 3", 10)).toEqual(15);
expect(parseInt("15e2", 10)).toEqual(15);
expect(parseInt("15px", 10)).toEqual(15);
expect(parseInt("12", 13)).toEqual(15);
expect(parseInt("17", 8)).toEqual(15);
})
test('parseFloat', () => {
expect(parseFloat("11.20")).toEqual(11.2);
expect(parseFloat("3.14")).toEqual(3.14);
expect(parseFloat(" 3.14 ")).toEqual(3.14);
expect(parseFloat("314e-2")).toEqual(3.14);
expect(parseFloat("0.0314E+2")).toEqual(3.14);
expect(parseFloat("3.14some non-digit characters")).toEqual(3.14);
})
})
test('isFinite', () => {
test('isFinite', () => {
...
...
uni_modules/uts-tests/utssdk/Operators.uts
浏览文件 @
3ab9e700
...
@@ -47,6 +47,9 @@ export function testOperators(): Result {
...
@@ -47,6 +47,9 @@ export function testOperators(): Result {
const a: number = 5; // 00000000000000000000000000000101
const a: number = 5; // 00000000000000000000000000000101
const b: number = 3; // 00000000000000000000000000000011
const b: number = 3; // 00000000000000000000000000000011
expect(a & b).toEqual(1); // 00000000000000000000000000000001
expect(a & b).toEqual(1); // 00000000000000000000000000000001
//expect(16677889900 & 10).toEqual(8);
//expect(888999555666 & 23.567).toEqual(18);
})
})
test('&=', () => {
test('&=', () => {
let a = 5; // 00000000000000000000000000000101
let a = 5; // 00000000000000000000000000000101
...
@@ -58,11 +61,14 @@ export function testOperators(): Result {
...
@@ -58,11 +61,14 @@ export function testOperators(): Result {
const b: number = -3; // 11111111111111111111111111111101
const b: number = -3; // 11111111111111111111111111111101
expect(~a).toEqual(-6); // 11111111111111111111111111111010
expect(~a).toEqual(-6); // 11111111111111111111111111111010
expect(~b).toEqual(2); // 00000000000000000000000000000010
expect(~b).toEqual(2); // 00000000000000000000000000000010
})
})
test('|', () => {
test('|', () => {
const a: number = 5; // 00000000000000000000000000000101
const a: number = 5; // 00000000000000000000000000000101
const b: number = 3; // 00000000000000000000000000000011
const b: number = 3; // 00000000000000000000000000000011
expect(a | b).toEqual(7); // 00000000000000000000000000000111
expect(a | b).toEqual(7); // 00000000000000000000000000000111
//expect(16677889901 | 10).toEqual(-501979281);
//expect(888999555661 | 23.567).toEqual(-58674593);
})
})
test('|=', () => {
test('|=', () => {
let a = 5; // 00000000000000000000000000000101
let a = 5; // 00000000000000000000000000000101
...
@@ -73,6 +79,8 @@ export function testOperators(): Result {
...
@@ -73,6 +79,8 @@ export function testOperators(): Result {
const a: number = 5; // 00000000000000000000000000000101
const a: number = 5; // 00000000000000000000000000000101
const b: number = 3; // 00000000000000000000000000000011
const b: number = 3; // 00000000000000000000000000000011
expect(a ^ b).toEqual(6); // 00000000000000000000000000000110
expect(a ^ b).toEqual(6); // 00000000000000000000000000000110
//expect(16677889902 ^ 10).toEqual(-501979292);
//expect(888999555662 ^ 23.567).toEqual(-58674599);
})
})
test('^=', () => {
test('^=', () => {
let a = 5; // 00000000000000000000000000000101
let a = 5; // 00000000000000000000000000000101
...
@@ -91,25 +99,30 @@ export function testOperators(): Result {
...
@@ -91,25 +99,30 @@ export function testOperators(): Result {
function divide (a: number, b: number): number {
function divide (a: number, b: number): number {
return a / b
return a / b
}
}
expect(divide(10, 5)).toEqual(2);
expect(divide(-10, -5)).toEqual(2);
expect(divide(10, 5)).toEqualNumber(2);
expect(divide(10, -5)).toEqual(-2);
expect(divide(-10, -5)).toEqualNumber(2);
expect(divide(-10, 5)).toEqual(-2);
expect(divide(10, -5)).toEqualNumber(-2);
expect(divide(0.1, 0.3)).toEqual(0.33333333333333337);
expect(divide(-10, 5)).toEqualNumber(-2);
expect(divide(0.3, 0.1)).toEqual(2.9999999999999996);
expect(divide(0.1, 0.3)).toEqualNumber(0.33333333333333337);
expect(divide(0.3, 0.1)).toEqualNumber(2.9999999999999996);
expectNumber(divide(1.5, 0.5)).toEqualDouble(3);
expectNumber(divide(1.5, 0.5)).toEqualDouble(3);
expect(divide(3, 2)).toEqual(1.5);
expect(divide(3, 2)).toEqual
Number
(1.5);
// 暂不支持字面量
// 暂不支持字面量
// expect(3 / 2).toEqual(1.5);
// expect(3 / 2).toEqual(1.5);
expect(divide(10, 3)).toEqual(3.3333333333333335);
expect(divide(10, 3)).toEqual
Number
(3.3333333333333335);
expect(divide(3, 10)).toEqual(0.3);
expect(divide(3, 10)).toEqual
Number
(0.3);
expect(divide(1, 3)).toEqual(0.3333333333333333);
expect(divide(1, 3)).toEqual
Number
(0.3333333333333333);
expect(divide(1000000, 2000000)).toEqual(0.5);
expect(divide(1000000, 2000000)).toEqual
Number
(0.5);
// kotlin java.lang.ArithmeticException: divide by zero
// kotlin java.lang.ArithmeticException: divide by zero
// swift 返回 inf
// swift 返回 inf
// web 返回 Infinity
// web 返回 Infinity
// todo 统一处理
// todo 统一处理
// expect(divide(1, 0)).toEqual();
// expect(divide(1, 0)).toEqual();
expect(divide(16788990011, 5)).toEqualNumber(3357798002.2);
expect(divide(16788990015, 5)).toEqualNumber(3357798003);
expectNumber(divide(16788990015, 10088990000)).toEqualDouble(1.6640902622561822);
})
})
test('/=', () => {
test('/=', () => {
let a:Number = 3;
let a:Number = 3;
...
@@ -251,6 +264,8 @@ export function testOperators(): Result {
...
@@ -251,6 +264,8 @@ export function testOperators(): Result {
const c: number = -5; // 11111111111111111111111111111011
const c: number = -5; // 11111111111111111111111111111011
expect(a >> b).toEqual(1); // 00000000000000000000000000000001
expect(a >> b).toEqual(1); // 00000000000000000000000000000001
expect(c >> b).toEqual(-2); // 11111111111111111111111111111110
expect(c >> b).toEqual(-2); // 11111111111111111111111111111110
//expect(16677889900 >> 10).toEqual(-490215);
//expect(888999555666 >> 23.567).toEqual(-7);
})
})
test('>>=', () => {
test('>>=', () => {
let a = 5; // 00000000000000000000000000000101
let a = 5; // 00000000000000000000000000000101
...
...
uni_modules/uts-tests/utssdk/String.uts
浏览文件 @
3ab9e700
...
@@ -206,6 +206,10 @@ export function testString(): Result {
...
@@ -206,6 +206,10 @@ export function testString(): Result {
expect(str6).toEqual("The morning is upon us.");
expect(str6).toEqual("The morning is upon us.");
expect("".slice()).toEqual("");
expect("".slice()).toEqual("");
expect("abcdefg".slice(-1)).toEqual("g");
expect("abcdefg".slice(-1,-2)).toEqual("");
})
})
test('split', () => {
test('split', () => {
const str = 'The quick brown fox jumps over the lazy dog.';
const str = 'The quick brown fox jumps over the lazy dog.';
...
...
uni_modules/uts-tests/utssdk/index.uts
浏览文件 @
3ab9e700
...
@@ -11,6 +11,7 @@ import { testOperators } from './Operators.uts'
...
@@ -11,6 +11,7 @@ import { testOperators } from './Operators.uts'
import { testMath } from './Math.uts'
import { testMath } from './Math.uts'
import { testRegExp } from './RegExp.uts'
import { testRegExp } from './RegExp.uts'
import { testForLoop } from './ForLoop.uts'
import { testForLoop } from './ForLoop.uts'
import { testGlobal } from './Global.uts'
export { Result } from './tests.uts'
export { Result } from './tests.uts'
// Promise、Proxy、Reflect、Weakmap、WeakSet 不支持
// Promise、Proxy、Reflect、Weakmap、WeakSet 不支持
...
@@ -28,6 +29,7 @@ export function runTests() : UTSJSONObject {
...
@@ -28,6 +29,7 @@ export function runTests() : UTSJSONObject {
const RegExpRes = testRegExp();
const RegExpRes = testRegExp();
const KeyWordRes = testKeyWord();
const KeyWordRes = testKeyWord();
const ForLoopRes = testForLoop();
const ForLoopRes = testForLoop();
const GlobalRes = testGlobal();
return {
return {
Array: ArrayRes,
Array: ArrayRes,
...
@@ -43,5 +45,6 @@ export function runTests() : UTSJSONObject {
...
@@ -43,5 +45,6 @@ export function runTests() : UTSJSONObject {
RegExp: RegExpRes,
RegExp: RegExpRes,
KeyWord: KeyWordRes,
KeyWord: KeyWordRes,
ForLoop: ForLoopRes,
ForLoop: ForLoopRes,
Global: GlobalRes,
}
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录