From c0567af5184fa1f9e44b1da3d39ce43766f9d5d2 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Fri, 16 Aug 2024 20:40:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0UTSNumber=20=E9=83=A8?= =?UTF-8?q?=E5=88=86=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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/uni_modules/uts-tests/utssdk/Number.uts b/uni_modules/uts-tests/utssdk/Number.uts index 1411f96..8f35215 100644 --- a/uni_modules/uts-tests/utssdk/Number.uts +++ b/uni_modules/uts-tests/utssdk/Number.uts @@ -127,21 +127,45 @@ export function testNumber() : Result { }) test('Unary-Operators', () => { + // #ifdef APP-ANDROID let a = JSON.parse("1") as Number a++; expect(a.toString()).toEqual("2"); + expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); + a--; expect(a.toString()).toEqual("1"); + expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); a /= 0.5; expect(a.toString()).toEqual("2"); + expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); a *= 5; expect(a.toString()).toEqual("10"); + expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); a += -1; expect(a.toString()).toEqual("9"); + expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); a -= -2; expect(a.toString()).toEqual("11"); + expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); let a2 = a % 5 expect(a2.toString()).toEqual("1"); + expect(UTSAndroid.getJavaClass(a2).name).toEqual("io.dcloud.uts.UTSNumber"); + + let b = 12 + let c1 = b + a2 + expect(c1.toString()).toEqual("13"); + expect(UTSAndroid.getJavaClass(c1).name).toEqual("io.dcloud.uts.UTSNumber"); + + let c2 = a2 + 2 + expect(c2.toString()).toEqual("3"); + expect(UTSAndroid.getJavaClass(c2).name).toEqual("io.dcloud.uts.UTSNumber"); + + let c3 = 2 + a2 + expect(c3.toString()).toEqual("3"); + expect(UTSAndroid.getJavaClass(c3).name).toEqual("io.dcloud.uts.UTSNumber"); + // #endif + }) -- GitLab