From edece136ef854067eb15fd4f375915a37d95e99e Mon Sep 17 00:00:00 2001 From: duqingquan Date: Tue, 29 Oct 2024 19:35:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Math.abs=20=E5=92=8C=20?= =?UTF-8?q?=E9=99=A4=E6=B3=95=20=E9=83=A8=E5=88=86=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=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/Math.uts | 8 ++++++++ uni_modules/uts-tests/utssdk/Operators.uts | 17 +++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/Math.uts b/uni_modules/uts-tests/utssdk/Math.uts index 8e88f5d..9afc1ba 100644 --- a/uni_modules/uts-tests/utssdk/Math.uts +++ b/uni_modules/uts-tests/utssdk/Math.uts @@ -106,6 +106,14 @@ export function testMath() : Result { expect(difference(3, 5)).toEqual(2); expect(difference(5, 3)).toEqual(2); expect(difference(1.23456, 7.89012)).toEqual(6.6555599999999995); + + let utsNumber1 = JSON.parse("-160")! as Number + expect(Math.abs(utsNumber1)).toEqual(160); + + let utsNumber2 = Math.abs(0) - 0.123456 + expect(Math.abs(utsNumber2)).toEqual(0.123456); + + }) test('acos', () => { diff --git a/uni_modules/uts-tests/utssdk/Operators.uts b/uni_modules/uts-tests/utssdk/Operators.uts index 7907c33..1abe68c 100644 --- a/uni_modules/uts-tests/utssdk/Operators.uts +++ b/uni_modules/uts-tests/utssdk/Operators.uts @@ -119,10 +119,19 @@ export function testOperators(): Result { // web 返回 Infinity // todo 统一处理 // expect(divide(1, 0)).toEqual(); - expect(divide(16788990011, 5)).toEqualNumber(3357798002.2); - expect(divide(16788990015, 5)).toEqualNumber(3357798003); - expectNumber(divide(16788990015, 10088990000)).toEqualDouble(1.6640902622561822); - + expect(divide(16788990011, 5)).toEqualNumber(3357798002.2); + expect(divide(16788990015, 5)).toEqualNumber(3357798003); + expectNumber(divide(16788990015, 10088990000)).toEqualDouble(1.6640902622561822); + + let utsNum1 = JSON.parse("0.123456")! as Number + let utsNum2 = JSON.parse("0.123456")! as Number + + let utsNum3 = utsNum1 / utsNum2 + expect(utsNum3).toEqualNumber(1); + + let utsNum4 = 0.030864 / utsNum2 + expect(utsNum4).toEqualNumber(0.25); + }) test('/=', () => { let a:number = 3; -- GitLab