deno.land / x / simplestatistics@v7.8.3 / test / sum.test.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* eslint no-shadow: 0 */
const test = require("tap").test;const ss = require("../dist/simple-statistics.js");
test("sum", function (t) { t.test("can get the sum of two numbers", function (t) { t.equal(ss.sum([1, 2]), 3); t.end(); });
t.test("the sum of no numbers is zero", function (t) { t.equal(ss.sum([]), 0); t.end(); });
t.test("returns NaN if a non-number is given", function (t) { t.ok(isNaN(ss.sum([1, null]))); t.ok(isNaN(ss.sum([null, 1]))); t.ok(isNaN(ss.sum([1, 2, null]))); t.ok(isNaN(ss.sum([1, 2, true]))); t.end(); }); t.end();});
test("sumSimple", function (t) { t.test("can get the sum of two numbers", function (t) { t.equal(ss.sumSimple([1, 2]), 3); t.end(); });
t.test("can get the sum of two numbers", function (t) { t.equal( ss.sumSimple([ 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7 ]), 15.299999999999999 ); t.equal( ss.sum([ 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7 ]), 15.3 ); t.end(); });
t.test("the sum of no numbers is zero", function (t) { t.equal(ss.sumSimple([]), 0); t.end(); });
t.test("same NaN behavior as sum", function (t) { t.ok(isNaN(ss.sumSimple([null]))); t.ok(isNaN(ss.sumSimple([1, 2, null]))); t.end(); }); t.end();});
simplestatistics

Version Info

Tagged at
a year ago