Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
3c5045a2
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看板
提交
3c5045a2
编写于
9月 14, 2024
作者:
M
mahaifeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[promise,global]去除文档中手动生成的代码,添加注释
上级
26658618
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
517 addition
and
482 deletion
+517
-482
uni_modules/uts-tests/utssdk/Global.uts
uni_modules/uts-tests/utssdk/Global.uts
+111
-95
uni_modules/uts-tests/utssdk/Promise.uts
uni_modules/uts-tests/utssdk/Promise.uts
+406
-387
未找到文件。
uni_modules/uts-tests/utssdk/Global.uts
浏览文件 @
3c5045a2
import { describe, test, expect, Result } from './tests.uts'
export function testGlobal(): Result {
return describe("Global", () => {
export function testGlobal()
: Result {
return describe("Global", () => {
test('setInterval', () => {
// #TEST Global.setInterval
// #ifdef APP-ANDROID
let aCount = 0
let taskId = setInterval(function
()
{
aCount += 1
},0)
setTimeout(function
()
{
console.log(aCount)
console.log(taskId)
clearInterval(taskId)
expect(aCount > 10).toEqual(true);
},200)
let taskId = setInterval(function
()
{
aCount += 1
},
0)
setTimeout(function
()
{
console.log(aCount)
console.log(taskId)
clearInterval(taskId)
expect(aCount > 10).toEqual(true);
},
200)
// #endif
// #END
})
test('btoa', () => {
// #TEST Global.btoa
// #ifdef APP-ANDROID
expect(btoa("")).toEqual('');
expect(btoa("hello world")).toEqual('aGVsbG8gd29ybGQ=');
expect(btoa("@-1234567890qwertyuiopasdfghjklzxcvbnm-QWERTYUIOPASDFGHJKLZXCVBNM@-1234567890qwertyuiopasdfghjklzxcvbnm-QWERTYUIOPASDFGHJKLZXCVBNM@-1234567890qwertyuiopasdfghjklzxcvbnm-QWERTYUIOPASDFGHJKLZXCVBNM@-1234567890qwertyuiopasdfghjklzxcvbnm-QWERTYUIOPASDFGHJKLZXCVBNM@-1234567890qwertyuiopasdfghjklzxcvbnm-QWERTYUIOPASDFGHJKLZXCVBNM")).toEqual('QC0xMjM0NTY3ODkwcXdlcnR5dWlvcGFzZGZnaGprbHp4Y3Zibm0tUVdFUlRZVUlPUEFTREZHSEpLTFpYQ1ZCTk1ALTEyMzQ1Njc4OTBxd2VydHl1aW9wYXNkZmdoamtsenhjdmJubS1RV0VSVFlVSU9QQVNERkdISktMWlhDVkJOTUAtMTIzNDU2Nzg5MHF3ZXJ0eXVpb3Bhc2RmZ2hqa2x6eGN2Ym5tLVFXRVJUWVVJT1BBU0RGR0hKS0xaWENWQk5NQC0xMjM0NTY3ODkwcXdlcnR5dWlvcGFzZGZnaGprbHp4Y3Zibm0tUVdFUlRZVUlPUEFTREZHSEpLTFpYQ1ZCTk1ALTEyMzQ1Njc4OTBxd2VydHl1aW9wYXNkZmdoamtsenhjdmJubS1RV0VSVFlVSU9QQVNERkdISktMWlhDVkJOTQ==');
// #endif
// #END
})
test('atob', () => {
// #TEST Global.atob
// #ifdef APP-ANDROID
expect(atob("")).toEqual('');
expect(atob('aGVsbG8gd29ybGQ=')).toEqual('hello world');
expect(atob("QC0xMjM0NTY3ODkwcXdlcnR5dWlvcGFzZGZnaGprbHp4Y3Zibm0tUVdFUlRZVUlPUEFTREZHSEpLTFpYQ1ZCTk1ALTEyMzQ1Njc4OTBxd2VydHl1aW9wYXNkZmdoamtsenhjdmJubS1RV0VSVFlVSU9QQVNERkdISktMWlhDVkJOTUAtMTIzNDU2Nzg5MHF3ZXJ0eXVpb3Bhc2RmZ2hqa2x6eGN2Ym5tLVFXRVJUWVVJT1BBU0RGR0hKS0xaWENWQk5NQC0xMjM0NTY3ODkwcXdlcnR5dWlvcGFzZGZnaGprbHp4Y3Zibm0tUVdFUlRZVUlPUEFTREZHSEpLTFpYQ1ZCTk1ALTEyMzQ1Njc4OTBxd2VydHl1aW9wYXNkZmdoamtsenhjdmJubS1RV0VSVFlVSU9QQVNERkdISktMWlhDVkJOTQ==")).toEqual('@-1234567890qwertyuiopasdfghjklzxcvbnm-QWERTYUIOPASDFGHJKLZXCVBNM@-1234567890qwertyuiopasdfghjklzxcvbnm-QWERTYUIOPASDFGHJKLZXCVBNM@-1234567890qwertyuiopasdfghjklzxcvbnm-QWERTYUIOPASDFGHJKLZXCVBNM@-1234567890qwertyuiopasdfghjklzxcvbnm-QWERTYUIOPASDFGHJKLZXCVBNM@-1234567890qwertyuiopasdfghjklzxcvbnm-QWERTYUIOPASDFGHJKLZXCVBNM');
// #endif
// #END
})
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")).toEqualNumber(9.223372036854778e+18)
expect(parseInt("9223372036854775807000")).toEqualNumber(9.223372036854777e+21)
expect(parseInt("922337203685477580700099999999999999999999999999999999999999999999999999999999999999999")).toEqualNumber(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')
})
test('parseInt', () => {
// #TEST Global.parseInt,Global.isNaN
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")).toEqualNumber(9.223372036854778e+18)
expect(parseInt("9223372036854775807000")).toEqualNumber(9.223372036854777e+21)
expect(parseInt("922337203685477580700099999999999999999999999999999999999999999999999999999999999999999")).toEqualNumber(9.223372036854776e+86)
expect(parseInt("50") / 100).toEqualNumber(0.5);
expect(parseInt("500") / 100).toEqualNumber(5);
// #END
})
test('parseFloat', () => {
// #TEST Global.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);
// #END
})
}
test('encodeURI', () => {
// #TEST Global.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')
// #END
})
test('decodeURI', () => {
// #TEST Global.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')
// #END
})
test('encodeURIComponent', () => {
// #TEST Global.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')
// #END
})
test('decodeURIComponent', () => {
// #TEST Global.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')
// #END
})
})
}
\ No newline at end of file
uni_modules/uts-tests/utssdk/Promise.uts
浏览文件 @
3c5045a2
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录