forked from simple-statistics/simple-statistics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfactorial.test.js
35 lines (33 loc) · 909 Bytes
/
factorial.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
/* eslint no-shadow: 0 */
const test = require("tap").test;
const ss = require("../dist/simple-statistics.js");
test("factorial", function (t) {
t.test(
"cannot calculate the factorial of a number lower than zero",
function (t) {
t.throws(function () {
ss.factorial(-1);
});
t.end();
}
);
t.test("rejects floating-point inputs", function (t) {
t.throws(function () {
ss.factorial(0.5);
});
t.end();
});
t.test("can calculate 0! = 1", function (t) {
t.equal(ss.factorial(0), 1);
t.end();
});
t.test("can calculate 1! = 1", function (t) {
t.equal(ss.factorial(1), 1);
t.end();
});
t.test("can calculate 100! = 1", function (t) {
t.equal(ss.factorial(100), 9.33262154439441e157);
t.end();
});
t.end();
});