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 838163471b605410a48262c6d3b012ddf7b6427c..3a922c65d84ffc86a7da651332367f8863d073ee 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 7bc2a0a4042ce7c4a4fe595656fce6497839d3cd..cd6fc11460e73c067816000b3268f2885dc3607f 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 c3844c3577d89159f0a5db9b25fa35a06e10afda..fbf626f34651c5fb3559999a7494a06f0cf702a5 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"); + }) + }) }