提交 256f76cb 编写于 作者: 杜庆泉's avatar 杜庆泉

number aa

上级 24bf9b23
......@@ -270,7 +270,7 @@ export function arrayPermissionFlowTest(callback : (ret : boolean, desc : string
let permissionNeed = utsArrayOf("android.permission.READ_CALENDAR", "android.permission.WRITE_CALENDAR", "android.permission.READ_CONTACTS", "android.permission.WRITE_CONTACTS", "android.permission.GET_ACCOUNTS")
if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) {
callback(false, "预期当前不具备 读写日历/联系人的权限")
callback(false, "已具备 日历/联系人权限")
return;
}
......
import { describe, test, expect, Result } from './tests.uts'
class User{
name:string = "";
age:number = 12;
}
export function testJSON() : Result {
return describe("JSON", () => {
test('parse', () => {
......@@ -20,6 +27,7 @@ export function testJSON() : Result {
city: 'New York',
});
const json2 = '{"string":"Hello","number":42,"boolean":true,"nullValue":null,"array":[1,2,3],"object":{"nestedKey":"nestedValue"}}';
const obj2 = JSON.parse(json2)!;
expect(obj2).toEqual({
......@@ -36,6 +44,10 @@ export function testJSON() : Result {
nestedKey: 'nestedValue',
})
// 目前仅android 支持,暂不放开
// let obj3 = JSON.parse<User>(json1);
// console.log(obj3)
// const json3 = '["apple","banana","cherry"]';
// const obj3 = JSON.parse(json3)!;
// TODO JSON.parse 后数组的类型 无法强转
......
......@@ -11,5 +11,29 @@ export function testNumber(): Result {
expect(financial(0)).toEqual("0.00");
expect(financial(1)).toEqual("1.00");
})
test('parseInt', () => {
expect(parseInt("123.456")).toEqual(123);
})
test('parseFloat', () => {
expect(parseFloat("11.20")).toEqual(11.2);
})
test('isFinite', () => {
expect(isFinite(1000 / 1)).toEqual(true);
expect(isFinite(910)).toEqual(true);
expect(isFinite(0)).toEqual(true);
})
test('isNaN', () => {
expect(isNaN(0)).toEqual(false);
})
test('toPrecision', () => {
expect(123.456.toPrecision(4)).toEqual("123.5");
expect(0.004.toPrecision(4)).toEqual("0.004000");
expect(1.23e5.toPrecision(4)).toEqual("1.230e+5");
})
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册