From 9e3574397a4e54e4a74fb9a08a23fa57dead6a32 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Fri, 20 Oct 2023 20:15:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A064=E4=BD=8D=E6=95=B4=E6=95=B0?= =?UTF-8?q?=E7=9A=84=E9=83=A8=E5=88=86=E6=B5=8B=E8=AF=95=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 | 17 +++++++++++++++++ uni_modules/uts-tests/utssdk/Operators.uts | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/uni_modules/uts-tests/utssdk/Number.uts b/uni_modules/uts-tests/utssdk/Number.uts index c2a03ab..a487b75 100644 --- a/uni_modules/uts-tests/utssdk/Number.uts +++ b/uni_modules/uts-tests/utssdk/Number.uts @@ -21,6 +21,23 @@ export function testNumber(): Result { let obj = {"id":"3be2c600-894c-4231-aa56-82fd989cc961","result":{"result":[num1, num2, num3]}} console.log(JSON.stringify(obj)) + + expect(123456.789.toFixed(2)).toEqual("123456.79"); + expect(12345600123.789123.toFixed(2)).toEqual("12345600123.79"); + expect((-123456.789).toFixed(5)).toEqual("-123456.78900"); + expect(parseFloat("16688995566.369").toFixed(3)).toEqual("16688995566.369"); + // #ifndef APP-IOS + // android 专有数据类型 + let a1 = 56 + let a2 = -122 + expect(a1.toByte().toFixed(2)).toEqual("56.00"); + expect(a2.toByte().toFixed(2)).toEqual("-122.00"); + + expect(a1.toShort().toFixed(5)).toEqual("56.00000"); + expect(a2.toShort().toFixed(5)).toEqual("-122.00000"); + + // #endif + }) test('isFinite', () => { diff --git a/uni_modules/uts-tests/utssdk/Operators.uts b/uni_modules/uts-tests/utssdk/Operators.uts index 1b32623..c279f37 100644 --- a/uni_modules/uts-tests/utssdk/Operators.uts +++ b/uni_modules/uts-tests/utssdk/Operators.uts @@ -47,6 +47,9 @@ export function testOperators(): Result { const a: number = 5; // 00000000000000000000000000000101 const b: number = 3; // 00000000000000000000000000000011 expect(a & b).toEqual(1); // 00000000000000000000000000000001 + + //expect(16677889900 & 10).toEqual(8); + //expect(888999555666 & 23.567).toEqual(18); }) test('&=', () => { let a = 5; // 00000000000000000000000000000101 @@ -58,11 +61,14 @@ export function testOperators(): Result { const b: number = -3; // 11111111111111111111111111111101 expect(~a).toEqual(-6); // 11111111111111111111111111111010 expect(~b).toEqual(2); // 00000000000000000000000000000010 + }) test('|', () => { const a: number = 5; // 00000000000000000000000000000101 const b: number = 3; // 00000000000000000000000000000011 expect(a | b).toEqual(7); // 00000000000000000000000000000111 + //expect(16677889901 | 10).toEqual(-501979281); + //expect(888999555661 | 23.567).toEqual(-58674593); }) test('|=', () => { let a = 5; // 00000000000000000000000000000101 @@ -73,6 +79,8 @@ export function testOperators(): Result { const a: number = 5; // 00000000000000000000000000000101 const b: number = 3; // 00000000000000000000000000000011 expect(a ^ b).toEqual(6); // 00000000000000000000000000000110 + //expect(16677889902 ^ 10).toEqual(-501979292); + //expect(888999555662 ^ 23.567).toEqual(-58674599); }) test('^=', () => { let a = 5; // 00000000000000000000000000000101 @@ -256,6 +264,8 @@ export function testOperators(): Result { const c: number = -5; // 11111111111111111111111111111011 expect(a >> b).toEqual(1); // 00000000000000000000000000000001 expect(c >> b).toEqual(-2); // 11111111111111111111111111111110 + //expect(16677889900 >> 10).toEqual(-490215); + //expect(888999555666 >> 23.567).toEqual(-7); }) test('>>=', () => { let a = 5; // 00000000000000000000000000000101 -- GitLab