diff --git a/uni_modules/uts-tests/utssdk/Number.uts b/uni_modules/uts-tests/utssdk/Number.uts index c2a03ab285a480fbfb7679a3a61ea9c2973c1917..a487b7506c35eef505c9c1eca0e7663471a0bcc5 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 1b32623dae5bb644575d3f41798f682a4345ecaa..c279f3729916f792ddbc949bdfcf58c37d135196 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