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

geometric_mean.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
/* eslint no-shadow: 0 */
const test = require("tap").test;const ss = require("../");
test("geometric mean", function (t) { // From http://en.wikipedia.org/wiki/Geometric_mean t.test("can get the mean of two numbers", function (t) { t.equal(ss.geometricMean([2, 8]), 4); t.equal(ss.geometricMean([4, 1, 1 / 32]), 0.5); t.equal(Math.round(ss.geometricMean([2, 32, 1])), 4); t.end(); });
t.test("cannot calculate for empty lists", function (t) { t.throws(function () { ss.geometricMean([]); }); t.end(); });
t.test("cannot calculate for lists with negative numbers", function (t) { t.throws(function () { ss.geometricMean([-1]); }); t.end(); });
t.test("equals zero if array contains zero", function (t) { if (ss.geometricMean([0, 1, 2]) !== 0) { t.fail("geometric mean of array containing zero is not zero"); } t.end(); }); t.end();});
simplestatistic

Version Info

Tagged at
2 years ago