From 256f76cbf2995197bc44febeb0b1160f2b317bdf Mon Sep 17 00:00:00 2001 From: duqingquan Date: Sat, 15 Jul 2023 19:42:42 +0800 Subject: [PATCH] number aa --- .../utssdk/app-android/index.uts | 2 +- uni_modules/uts-tests/utssdk/JSON.uts | 16 +++++++++++-- uni_modules/uts-tests/utssdk/Number.uts | 24 +++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/uni_modules/uts-platform-api/utssdk/app-android/index.uts b/uni_modules/uts-platform-api/utssdk/app-android/index.uts index 8381634..3a922c6 100644 --- a/uni_modules/uts-platform-api/utssdk/app-android/index.uts +++ b/uni_modules/uts-platform-api/utssdk/app-android/index.uts @@ -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; } diff --git a/uni_modules/uts-tests/utssdk/JSON.uts b/uni_modules/uts-tests/utssdk/JSON.uts index 7bc2a0a..cd6fc11 100644 --- a/uni_modules/uts-tests/utssdk/JSON.uts +++ b/uni_modules/uts-tests/utssdk/JSON.uts @@ -1,5 +1,12 @@ import { describe, test, expect, Result } from './tests.uts' + + +class User{ + name:string = ""; + age:number = 12; +} + export function testJSON() : Result { return describe("JSON", () => { test('parse', () => { @@ -19,7 +26,8 @@ export function testJSON() : Result { age: 30, 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({ @@ -35,7 +43,11 @@ export function testJSON() : Result { expect(obj2['object']).toEqual({ nestedKey: 'nestedValue', }) - + + // 目前仅android 支持,暂不放开 + // let obj3 = JSON.parse(json1); + // console.log(obj3) + // const json3 = '["apple","banana","cherry"]'; // const obj3 = JSON.parse(json3)!; // TODO JSON.parse 后数组的类型 无法强转 diff --git a/uni_modules/uts-tests/utssdk/Number.uts b/uni_modules/uts-tests/utssdk/Number.uts index c3844c3..fbf626f 100644 --- a/uni_modules/uts-tests/utssdk/Number.uts +++ b/uni_modules/uts-tests/utssdk/Number.uts @@ -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"); + }) + }) } -- GitLab