From 224ac5a0ce92f9aff03ea18c21f8412ea43c92ed Mon Sep 17 00:00:00 2001 From: duqingquan Date: Thu, 31 Oct 2024 15:05:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DHello=20uts=20=E5=9B=A0?= =?UTF-8?q?=E4=B8=BAUTSNumber=E7=BC=96=E8=AF=91=E6=8A=A5=E9=94=99=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/Number.uts | 42 +++++++++---------- .../uts-tests/utssdk/UTSJSONObject.uts | 2 +- uni_modules/uts-tests/utssdk/console.uts | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/Number.uts b/uni_modules/uts-tests/utssdk/Number.uts index 3d48ed9..a536ed5 100644 --- a/uni_modules/uts-tests/utssdk/Number.uts +++ b/uni_modules/uts-tests/utssdk/Number.uts @@ -69,11 +69,11 @@ export function testNumber() : Result { expect(isFinite(0)).toEqual(true); // #ifdef APP-ANDROID let aj2 = JSON.parse('{"a":1}') as UTSJSONObject; - let aNumber = aj2['a'] as UTSNumber + let aNumber = aj2['a'] as Number 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); + expect(Number.isFinite(aNumber)).toEqual(true); + expect(Number.isFinite(11.00)).toEqual(true); + expect(Number.isFinite(Double.POSITIVE_INFINITY)).toEqual(false); // #endif }) @@ -138,39 +138,39 @@ export function testNumber() : Result { let a = JSON.parse("1") as Number a++; expect(a.toString()).toEqual("2"); - expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); + expect(UTSAndroid.getJavaClass(a).name).toEqual("java.lang.Integer"); a--; expect(a.toString()).toEqual("1"); - expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); + expect(UTSAndroid.getJavaClass(a).name).toEqual("java.lang.Integer"); a /= 0.5; expect(a.toString()).toEqual("2"); - expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); + expect(UTSAndroid.getJavaClass(a).name).toEqual("java.lang.Integer"); a *= 5; expect(a.toString()).toEqual("10"); - expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); + expect(UTSAndroid.getJavaClass(a).name).toEqual("java.lang.Integer"); a += -1; expect(a.toString()).toEqual("9"); - expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); + expect(UTSAndroid.getJavaClass(a).name).toEqual("java.lang.Integer"); a -= -2; expect(a.toString()).toEqual("11"); - expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); + expect(UTSAndroid.getJavaClass(a).name).toEqual("java.lang.Integer"); let a2 = a % 5 expect(a2.toString()).toEqual("1"); - expect(UTSAndroid.getJavaClass(a2).name).toEqual("io.dcloud.uts.UTSNumber"); + expect(UTSAndroid.getJavaClass(a2).name).toEqual("java.lang.Integer"); let b = 12 let c1 = b + a2 expect(c1.toString()).toEqual("13"); - expect(UTSAndroid.getJavaClass(c1).name).toEqual("io.dcloud.uts.UTSNumber"); + expect(UTSAndroid.getJavaClass(c1).name).toEqual("java.lang.Integer"); let c2 = a2 + 2 expect(c2.toString()).toEqual("3"); - expect(UTSAndroid.getJavaClass(c2).name).toEqual("io.dcloud.uts.UTSNumber"); + expect(UTSAndroid.getJavaClass(c2).name).toEqual("java.lang.Integer"); let c3 = 2 + a2 expect(c3.toString()).toEqual("3"); - expect(UTSAndroid.getJavaClass(c3).name).toEqual("io.dcloud.uts.UTSNumber"); + expect(UTSAndroid.getJavaClass(c3).name).toEqual("java.lang.Integer"); // #endif @@ -180,12 +180,12 @@ export function testNumber() : Result { expect(isNaN(0)).toEqual(false); // #ifdef APP-ANDROID let aj2 = JSON.parse('{"a":1}') as UTSJSONObject; - let aNumber = aj2['a'] as UTSNumber + let aNumber = aj2['a'] as Number expect(isNaN(aNumber)).toEqual(false); - expect(UTSNumber.isNaN(aNumber)).toEqual(false); - expect(UTSNumber.isNaN(11)).toEqual(false); - expect(UTSNumber.isNaN(null)).toEqual(false); - expect(UTSNumber.isNaN(1 / 0)).toEqual(false); + expect(Number.isNaN(aNumber)).toEqual(false); + expect(Number.isNaN(11)).toEqual(false); + expect(Number.isNaN(null)).toEqual(false); + expect(Number.isNaN(1 / 0)).toEqual(false); // #endif }) @@ -233,8 +233,8 @@ export function testNumber() : Result { // #ifdef APP-ANDROID expect(0.6.toString()).toEqual("0.6"); - expect((new UTSNumber(2709954670497349.5)).toString()).toEqual("2709954670497349.5"); - expect((new UTSNumber(0.00000000000001)).toString()).toEqual("1e-14"); + expect((2709954670497349.5).toString(10)).toEqual("2709954670497349.5"); + expect(((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"); diff --git a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts index 9682272..bb265f8 100644 --- a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts +++ b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts @@ -57,7 +57,7 @@ export function testUTSJSONObject() : Result { } let data2 = JSON.parse(JSON.stringify(data1)) - expect(data2!.toJSONString()).toEqual('{"str":"test","num":1.0,"num2":2.369}') + expect(data2!.toJSONString()).toEqual('{"str":"test","num":1,"num2":2.369}') class TestData2 implements IJSONStringify{ toJSON():any|null{ diff --git a/uni_modules/uts-tests/utssdk/console.uts b/uni_modules/uts-tests/utssdk/console.uts index 1fc5bf5..f5c30b3 100644 --- a/uni_modules/uts-tests/utssdk/console.uts +++ b/uni_modules/uts-tests/utssdk/console.uts @@ -30,7 +30,7 @@ export function testConsole() : Result { let aj2 = JSON.parse('{"a":1}') as UTSJSONObject; - expect(obtainInnerObject(aj2['a']).get("type")).toEqual("number"); + expect(obtainInnerObject(aj2['a']).get("type")).toEqual("Int"); expect(obtainInnerObject(aj2['a']).get("subType")).toEqual("number"); // #endif -- GitLab