MCPcopy Create free account
hub / github.com/ccxt/ccxt / testPrecise

Function testPrecise

ts/src/test/base/test.precise.ts:8–190  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6
7
8function testPrecise () {
9
10 const w = '-1.123e-6';
11 const x = '0.00000002';
12 const y = '69696900000';
13 const z = '0';
14 const a = '1e8';
15
16 assert (Precise.stringMul (x, y) === '1393.938');
17 assert (Precise.stringMul (y, x) === '1393.938');
18 assert (Precise.stringAdd (x, y) === '69696900000.00000002');
19 assert (Precise.stringAdd (y, x) === '69696900000.00000002');
20 assert (Precise.stringSub (x, y) === '-69696899999.99999998');
21 assert (Precise.stringSub (y, x) === '69696899999.99999998');
22 assert (Precise.stringDiv (x, y, 1) === '0');
23 assert (Precise.stringDiv (x, y) === '0');
24 assert (Precise.stringDiv (x, y, 19) === '0.0000000000000000002');
25 assert (Precise.stringDiv (x, y, 20) === '0.00000000000000000028');
26 assert (Precise.stringDiv (x, y, 21) === '0.000000000000000000286');
27 assert (Precise.stringDiv (x, y, 22) === '0.0000000000000000002869');
28 assert (Precise.stringDiv (y, x) === '3484845000000000000');
29
30 assert (Precise.stringMul (x, w) === '-0.00000000000002246');
31 assert (Precise.stringMul (w, x) === '-0.00000000000002246');
32 assert (Precise.stringAdd (x, w) === '-0.000001103');
33 assert (Precise.stringAdd (w, x) === '-0.000001103');
34 assert (Precise.stringSub (x, w) === '0.000001143');
35 assert (Precise.stringSub (w, x) === '-0.000001143');
36 assert (Precise.stringDiv (x, w) === '-0.017809439002671415');
37 assert (Precise.stringDiv (w, x) === '-56.15');
38
39 assert (Precise.stringMul (z, w) === '0');
40 assert (Precise.stringMul (z, x) === '0');
41 assert (Precise.stringMul (z, y) === '0');
42 assert (Precise.stringMul (w, z) === '0');
43 assert (Precise.stringMul (x, z) === '0');
44 assert (Precise.stringMul (y, z) === '0');
45 assert (Precise.stringAdd (z, w) === '-0.000001123');
46 assert (Precise.stringAdd (z, x) === '0.00000002');
47 assert (Precise.stringAdd (z, y) === '69696900000');
48 assert (Precise.stringAdd (w, z) === '-0.000001123');
49 assert (Precise.stringAdd (x, z) === '0.00000002');
50 assert (Precise.stringAdd (y, z) === '69696900000');
51
52 assert (Precise.stringMul (x, a) === '2');
53 assert (Precise.stringMul (a, x) === '2');
54 assert (Precise.stringMul (y, a) === '6969690000000000000');
55 assert (Precise.stringMul (a, y) === '6969690000000000000');
56 assert (Precise.stringDiv (y, a) === '696.969');
57 assert (Precise.stringDiv (y, a, -1) === '690');
58 assert (Precise.stringDiv (y, a, 0) === '696');
59 assert (Precise.stringDiv (y, a, 1) === '696.9');
60 assert (Precise.stringDiv (y, a, 2) === '696.96');
61 assert (Precise.stringDiv (a, y) === '0.001434784043479695');
62
63 assert (Precise.stringAbs ('0') === '0');
64 assert (Precise.stringAbs ('-0') === '0');
65 assert (Precise.stringAbs ('-500.1') === '500.1');

Callers 1

baseTestsInitFunction · 0.70

Calls 15

assertFunction · 0.50
stringMulMethod · 0.45
stringAddMethod · 0.45
stringSubMethod · 0.45
stringDivMethod · 0.45
stringAbsMethod · 0.45
stringNegMethod · 0.45
stringModMethod · 0.45
stringEqualsMethod · 0.45
stringMinMethod · 0.45
stringMaxMethod · 0.45
stringGtMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…