From 3de775b058ae615ee545ff00b09f727d4cb59f59 Mon Sep 17 00:00:00 2001 From: m0_75226990 Date: Tue, 25 Jun 2024 17:35:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=83=A8=E5=88=86=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/JSON.uts | 3 ++- uni_modules/uts-tests/utssdk/Number.uts | 10 +++++++--- uni_modules/uts-tests/utssdk/UTSJSONObject.uts | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/JSON.uts b/uni_modules/uts-tests/utssdk/JSON.uts index 00ebc1e..ad362a3 100644 --- a/uni_modules/uts-tests/utssdk/JSON.uts +++ b/uni_modules/uts-tests/utssdk/JSON.uts @@ -323,8 +323,9 @@ export function testJSON() : Result { const json = `{"result":true, "count":42}`; const obj = JSON.parse(json) as UTSJSONObject; let retStr = JSON.stringify(obj) + // #ifdef APP-ANDROID expect(retStr).toEqual('{"result":true,"count":42}') - + // #endif }) test('parse Map', () => { diff --git a/uni_modules/uts-tests/utssdk/Number.uts b/uni_modules/uts-tests/utssdk/Number.uts index 5a22aa7..7c33dd7 100644 --- a/uni_modules/uts-tests/utssdk/Number.uts +++ b/uni_modules/uts-tests/utssdk/Number.uts @@ -59,14 +59,14 @@ export function testNumber() : Result { expect(isFinite(1000 / 1)).toEqual(true); expect(isFinite(910)).toEqual(true); expect(isFinite(0)).toEqual(true); - + // #ifdef APP-ANDROID let aj2 = JSON.parse('{"a":1}') as UTSJSONObject; let aNumber = aj2['a'] as UTSNumber expect(isFinite(aNumber)).toEqual(true); expect(UTSNumber.isFinite(aNumber)).toEqual(true); expect(UTSNumber.isFinite(11.00)).toEqual(true); expect(UTSNumber.isFinite(Double.POSITIVE_INFINITY)).toEqual(false); - + // #endif }) test('number-from-json-parse', () => { @@ -78,6 +78,7 @@ export function testNumber() : Result { expect(aj?.a == 1 as number).toEqual(true); expect(aj?.a == 1.0).toEqual(true); expect(aj?.a == 1.0 as number).toEqual(true); + // #ifdef APP-ANDROID expect(aj?.a === 1).toEqual(true); expect(aj?.a === 1 as number).toEqual(true); expect(aj?.a === 1.0).toEqual(true); @@ -110,6 +111,8 @@ export function testNumber() : Result { let aj2 = JSON.parse('{"a":1}'); expect(aj?.a == aj2?.a).toEqual(true); + // #endif + }) @@ -122,7 +125,7 @@ export function testNumber() : Result { test('isNaN', () => { expect(isNaN(0)).toEqual(false); - + // #ifdef APP-ANDROID let aj2 = JSON.parse('{"a":1}') as UTSJSONObject; let aNumber = aj2['a'] as UTSNumber expect(isNaN(aNumber)).toEqual(false); @@ -130,6 +133,7 @@ export function testNumber() : Result { expect(UTSNumber.isNaN(11)).toEqual(false); expect(UTSNumber.isNaN(null)).toEqual(false); expect(UTSNumber.isNaN(1 / 0)).toEqual(false); + // #endif }) test('toPrecision', () => { diff --git a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts index cb4820e..6b38239 100644 --- a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts +++ b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts @@ -27,6 +27,7 @@ export function testUTSJSONObject() : Result { }) test('setvalue-after-get', () => { + // #ifdef APP-ANDROID let obj = { "cars":[ { @@ -35,12 +36,12 @@ export function testUTSJSONObject() : Result { } ] } - + let cars = obj.getArray("cars") cars![0].set("value",20) let firstCar = obj.getJSON("cars[0]") expect(firstCar!['value']).toEqual(20); - + // #endif }) test('assign-withtype', () => { -- GitLab