提交 0fa51608 编写于 作者: 杜庆泉's avatar 杜庆泉

增加 Math.abs 和 除法 部分测试示例

上级 ae663dd9
...@@ -106,6 +106,14 @@ export function testMath() : Result { ...@@ -106,6 +106,14 @@ export function testMath() : Result {
expect(difference(3, 5)).toEqual(2); expect(difference(3, 5)).toEqual(2);
expect(difference(5, 3)).toEqual(2); expect(difference(5, 3)).toEqual(2);
expect(difference(1.23456, 7.89012)).toEqual(6.6555599999999995); 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', () => { test('acos', () => {
......
...@@ -119,10 +119,19 @@ export function testOperators(): Result { ...@@ -119,10 +119,19 @@ export function testOperators(): Result {
// web 返回 Infinity // web 返回 Infinity
// todo 统一处理 // todo 统一处理
// expect(divide(1, 0)).toEqual(); // expect(divide(1, 0)).toEqual();
expect(divide(16788990011, 5)).toEqualNumber(3357798002.2); expect(divide(16788990011, 5)).toEqualNumber(3357798002.2);
expect(divide(16788990015, 5)).toEqualNumber(3357798003); expect(divide(16788990015, 5)).toEqualNumber(3357798003);
expectNumber(divide(16788990015, 10088990000)).toEqualDouble(1.6640902622561822); 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('/=', () => { test('/=', () => {
let a:number = 3; let a:number = 3;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册