From 80894ed0c9a4f5de886af17fa1178a442dabaea7 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Thu, 22 Aug 2024 15:25:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=83=A8=E5=88=86=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/Number.uts | 8 ++++++ .../uts-tests/utssdk/UTSJSONObject.uts | 25 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/uni_modules/uts-tests/utssdk/Number.uts b/uni_modules/uts-tests/utssdk/Number.uts index 8f35215..00645cc 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 46c8c6c..26e16fb 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 }; -- GitLab