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

number aa

上级 24bf9b23
...@@ -270,7 +270,7 @@ export function arrayPermissionFlowTest(callback : (ret : boolean, desc : string ...@@ -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") 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()) { if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) {
callback(false, "预期当前不具备 读写日历/联系人的权限") callback(false, "已具备 日历/联系人权限")
return; return;
} }
......
import { describe, test, expect, Result } from './tests.uts' import { describe, test, expect, Result } from './tests.uts'
class User{
name:string = "";
age:number = 12;
}
export function testJSON() : Result { export function testJSON() : Result {
return describe("JSON", () => { return describe("JSON", () => {
test('parse', () => { test('parse', () => {
...@@ -19,7 +26,8 @@ export function testJSON() : Result { ...@@ -19,7 +26,8 @@ export function testJSON() : Result {
age: 30, age: 30,
city: 'New York', city: 'New York',
}); });
const json2 = '{"string":"Hello","number":42,"boolean":true,"nullValue":null,"array":[1,2,3],"object":{"nestedKey":"nestedValue"}}'; const json2 = '{"string":"Hello","number":42,"boolean":true,"nullValue":null,"array":[1,2,3],"object":{"nestedKey":"nestedValue"}}';
const obj2 = JSON.parse(json2)!; const obj2 = JSON.parse(json2)!;
expect(obj2).toEqual({ expect(obj2).toEqual({
...@@ -35,7 +43,11 @@ export function testJSON() : Result { ...@@ -35,7 +43,11 @@ export function testJSON() : Result {
expect(obj2['object']).toEqual({ expect(obj2['object']).toEqual({
nestedKey: 'nestedValue', nestedKey: 'nestedValue',
}) })
// 目前仅android 支持,暂不放开
// let obj3 = JSON.parse<User>(json1);
// console.log(obj3)
// const json3 = '["apple","banana","cherry"]'; // const json3 = '["apple","banana","cherry"]';
// const obj3 = JSON.parse(json3)!; // const obj3 = JSON.parse(json3)!;
// TODO JSON.parse 后数组的类型 无法强转 // TODO JSON.parse 后数组的类型 无法强转
......
...@@ -11,5 +11,29 @@ export function testNumber(): Result { ...@@ -11,5 +11,29 @@ export function testNumber(): Result {
expect(financial(0)).toEqual("0.00"); expect(financial(0)).toEqual("0.00");
expect(financial(1)).toEqual("1.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.
先完成此消息的编辑!
想要评论请 注册