deno.land / x / simplestatistic@v7.7.1 / test / median.test.js

median.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
/* eslint no-shadow: 0 */
const test = require("tap").test;const ss = require("../");
test("median", function (t) { t.test("can get the median of three numbers", function (t) { t.equal(ss.median([1, 2, 3]), 2); t.end(); });
t.test("can get the median of two numbers", function (t) { t.equal(ss.median([1, 2]), 1.5); t.equal(ss.medianSorted([1, 2]), 1.5); t.end(); });
t.test("can get the median of four numbers", function (t) { t.equal(ss.median([1, 2, 3, 4]), 2.5); t.end(); });
t.test("cannot calculate the median of an empty list", function (t) { t.throws(function () { ss.median([]); }); t.end(); });
t.test("sorts numbers numerically", function (t) { t.equal(ss.median([8, 9, 10]), 9); t.end(); });
t.test("does not change the sorting order of its input", function (t) { const x = [1, 0]; t.equal(ss.median(x), 0.5); t.equal(x[0], 1); t.equal(x[1], 0); t.end(); }); t.end();});
simplestatistic

Version Info

Tagged at
2 years ago