diff --git a/uni_modules/uts-tests/utssdk/Number.uts b/uni_modules/uts-tests/utssdk/Number.uts index 8f35215e9baf0adcd48f107948a12f0223abcb3a..00645ccc222bb40421260dfc35fbf1d5682b4a71 100644 --- a/uni_modules/uts-tests/utssdk/Number.uts +++ b/uni_modules/uts-tests/utssdk/Number.uts @@ -217,6 +217,14 @@ export function testNumber() : Result { expect(bStr12.length).toEqual(21); expect(bStr12.substring(0,14)).toEqual("27373a86ba1a19"); + // #ifdef APP-ANDROID + expect((new UTSNumber(2709954670497349.5)).toString()).toEqual("2709954670497349.5"); + expect((new UTSNumber(0.00000000000001)).toString()).toEqual("1e-14"); + expect((new UTSNumber(0.000001)).toString()).toEqual("0.000001"); + expect((new UTSNumber(0.0000001)).toString()).toEqual("1e-7"); + expect((new UTSNumber(100000000000000000000.0)).toString()).toEqual("100000000000000000000"); + expect((new UTSNumber(1000000000000000000000.0)).toString()).toEqual("1e21"); + // #endif }) test('valueOf', () => { diff --git a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts index 46c8c6c52de16a7a4b7e42a6970472044239eb04..26e16fb41b718e8d1ed686154d58b11048e485b8 100644 --- a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts +++ b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts @@ -13,6 +13,31 @@ export function testUTSJSONObject() : Result { console.log(UTSJSONObject.keys(obj)) }) + test('toJSONObject', () => { + // #ifdef APP-ANDROID + let result = {} + result["opt"] = "xxxx" + + let subArray = [] as Array + let subModel = {} + subModel["name"] = "xxx" + subModel["type"] = 0 + subArray.push(subModel) + + let service = {} + service["name"] = "0xxxb34fb" + service["type"] = 0 + + //这个数据返回为空对象数组 + service["array"] = subArray + + result["service"] = service + + expect(result.toJSONObject().toJSONString()).toEqual('{"opt":"xxxx","service":{"array":[{"name":"xxx","type":0}],"name":"0xxxb34fb","type":0}}'); + + // #endif + }) + test('assign-notype', () => { // #ifdef APP-ANDROID const target = { a: 1, b: 2 };