From 252d554deaed134da68128835ddd59402296767e Mon Sep 17 00:00:00 2001 From: duqingquan Date: Tue, 1 Aug 2023 11:31:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=83=A8=E5=88=86=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uts-advance/utssdk/app-android/index.uts | 2 ++ uni_modules/uts-tests/utssdk/Array.uts | 4 ++++ uni_modules/uts-tests/utssdk/Number.uts | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/uni_modules/uts-advance/utssdk/app-android/index.uts b/uni_modules/uts-advance/utssdk/app-android/index.uts index a1746d9..e7bbff0 100644 --- a/uni_modules/uts-advance/utssdk/app-android/index.uts +++ b/uni_modules/uts-advance/utssdk/app-android/index.uts @@ -444,6 +444,8 @@ export function logFloatTest() { } export function logIntTest() { console.log(2023) + console.log(2023.0) + console.log(2023.002) } export function logObjectTest(){ diff --git a/uni_modules/uts-tests/utssdk/Array.uts b/uni_modules/uts-tests/utssdk/Array.uts index b0eac59..6ec6872 100644 --- a/uni_modules/uts-tests/utssdk/Array.uts +++ b/uni_modules/uts-tests/utssdk/Array.uts @@ -176,6 +176,10 @@ export function testArray(): Result { expect(index).toEqual(3); index = array.lastIndexOf(2, 2); expect(index).toEqual(0); + + + + }) test("map", () => { const array1: number[] = [1, 4, 9, 16]; diff --git a/uni_modules/uts-tests/utssdk/Number.uts b/uni_modules/uts-tests/utssdk/Number.uts index 8c3b417..1e43aae 100644 --- a/uni_modules/uts-tests/utssdk/Number.uts +++ b/uni_modules/uts-tests/utssdk/Number.uts @@ -2,6 +2,7 @@ import { describe, test, expect, Result } from './tests.uts' export function testNumber(): Result { return describe("Number", () => { + test('toFixed', () => { function financial(x: Number): String { return x.toFixed(2); @@ -10,6 +11,16 @@ export function testNumber(): Result { expect(financial(0.004)).toEqual("0.00"); expect(financial(0)).toEqual("0.00"); expect(financial(1)).toEqual("1.00"); + + let num1: number = -1.1 / 0 + let num2: number = -1.1 / 0.1 + let num3: number = -1.1 / -0.1 + console.warn(num1) + console.warn(num2) + console.warn(num3) + let obj = {"id":"3be2c600-894c-4231-aa56-82fd989cc961","result":{"result":[num1, num2, num3]}} + console.log(JSON.stringify(obj)) + }) test('parseInt', () => { @@ -51,5 +62,12 @@ export function testNumber(): Result { expect((0xf).valueOf()).toEqual(15); }) + // 数据转换操作示例 + test('toX', () => { + let num = 10.123 + expect(num.toInt()).toEqual(10); + expect(num.toDouble()).toEqual(10.123); + }) + }) } -- GitLab