|
1
|
|
|
var percent = 0;
|
|
2
|
|
|
describe("The arb.js test suite", function(){
|
|
3
|
|
|
var arb = require("../../dist/arb.js");
|
|
4
|
|
|
|
|
5
|
|
|
var mulTestPair = ["1234567890", "9876543210"];
|
|
6
|
|
|
var mulTestAnswer = "12193263111263526900.0";
|
|
7
|
|
|
var addTestPair = ["1234567890", "9876543210"];
|
|
8
|
|
|
var addTestAnswer = "11111111100.0";
|
|
9
|
|
|
var subTestPair = ["1234567890", "9876543210"];
|
|
10
|
|
|
var subTestAnswer = "-8641975320.0";
|
|
11
|
|
|
var divTestPair = ["1234567890", "9876543210"];
|
|
12
|
|
|
var divTestAnswer = "0.1249999988609375000";
|
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
describe("Addition tests", function(){
|
|
16
|
|
|
it("should work properly on addition", function(){
|
|
17
|
|
|
//console.info("Running Addition Test...");
|
|
18
|
|
|
expect(arb(addTestPair[0]).add(addTestPair[1]).value).toBe(addTestAnswer);
|
|
19
|
|
|
});
|
|
20
|
|
|
});
|
|
21
|
|
|
|
|
22
|
|
|
describe("Subtraction tests", function(){
|
|
23
|
|
|
//console.info("Running Subtraction Test...");
|
|
24
|
|
|
it("should work properly on subtraction", function(){
|
|
25
|
|
|
expect(arb(subTestPair[0]).sub(subTestPair[1]).value).toBe(subTestAnswer);
|
|
26
|
|
|
});
|
|
27
|
|
|
});
|
|
28
|
|
|
|
|
29
|
|
|
describe("Multiplication tests", function(){
|
|
30
|
|
|
//console.info("Running multiplication Test...");
|
|
31
|
|
|
it("should work properly on multiplication", function(){
|
|
32
|
|
|
expect(arb(mulTestPair[0]).mul(mulTestPair[1]).value).toBe(mulTestAnswer);
|
|
33
|
|
|
});
|
|
34
|
|
|
});
|
|
35
|
|
|
|
|
36
|
|
|
describe("Division tests", function(){
|
|
37
|
|
|
//console.info("Running Division Test...");
|
|
38
|
|
|
it("should work properly on division", function(){
|
|
39
|
|
|
expect(arb(divTestPair[0]).div(divTestPair[1]).value.substr(0, 21)).toBe(divTestAnswer);
|
|
40
|
|
|
expect(arb("1").div("0.0001").value).toBe("10000.0");
|
|
41
|
|
|
expect(arb("1").div("89").value.substr(0, 22)).toBe("0.01123595505617977528");
|
|
42
|
|
|
});
|
|
43
|
|
|
});
|
|
44
|
|
|
}); |