From 4d55ce5905d26697885aaf44042663b161f65513 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Fri, 26 Jan 2024 12:15:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9number/global=20=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=95=B0=E5=AD=97=E5=88=A4=E6=96=AD=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/Global.uts | 6 +++--- uni_modules/uts-tests/utssdk/Number.uts | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/Global.uts b/uni_modules/uts-tests/utssdk/Global.uts index 92e135e..b36b15d 100644 --- a/uni_modules/uts-tests/utssdk/Global.uts +++ b/uni_modules/uts-tests/utssdk/Global.uts @@ -32,9 +32,9 @@ export function testGlobal(): Result { expect(isNaN(parseInt("345", 2))).toEqual(true) expect(isNaN(parseInt("hello"))).toEqual(true) expect(parseInt("6.022e23")).toEqual(6) - expect(parseInt("9223372036854775807")).toEqual(9.223372036854778e+18) - expect(parseInt("9223372036854775807000")).toEqual(9.223372036854777e+21) - expect(parseInt("922337203685477580700099999999999999999999999999999999999999999999999999999999999999999")).toEqual(9.223372036854776e+86) + expect(parseInt("9223372036854775807")).toEqualNumber(9.223372036854778e+18) + expect(parseInt("9223372036854775807000")).toEqualNumber(9.223372036854777e+21) + expect(parseInt("922337203685477580700099999999999999999999999999999999999999999999999999999999999999999")).toEqualNumber(9.223372036854776e+86) expect(parseInt("50") / 100).toEqualNumber(0.5); expect(parseInt("500") / 100).toEqualNumber(5); diff --git a/uni_modules/uts-tests/utssdk/Number.uts b/uni_modules/uts-tests/utssdk/Number.uts index 8775305..a9ab25e 100644 --- a/uni_modules/uts-tests/utssdk/Number.uts +++ b/uni_modules/uts-tests/utssdk/Number.uts @@ -98,7 +98,13 @@ export function testNumber() : Result { expect(a.toString(2).substring(0,32)).toEqual("10010110011101101001100101010000"); expect(a.toString(2).substring(100)).toEqual("000000000000000000000000000"); const b = 1e22 - expect(b.toString(12)).toEqual("27373a86ba1a194a65054"); + const bStr12 = b.toString(12) + /** + * 移动端: 27373a86ba1a194a65054 + * 浏览器端:27373a86ba1a195400000 + */ + expect(bStr12.length).toEqual(21); + expect(bStr12.substring(0,14)).toEqual("27373a86ba1a19"); }) -- GitLab