-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
50 lines (35 loc) · 918 Bytes
/
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
/* eslint-disable indent */
var det = require('laplace-determinant')
var test = require('tape')
test('Basic usage', function (t) {
t.plan(6)
// order = 1
t.equal(det([10]), 10)
// order = 2
t.equal(det([1, 0,
0, 1]), 1)
t.equal(det([1, 1,
2, 1]), -1)
// order = 3
t.equal(det([1, 0, 0,
0, 1, 0,
0, 0, 1]), 1)
t.equal(det([0, 1, 0,
2, -1, 0,
0, 2, 1]), -2)
// order = 4
t.equal(det([1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1]), 1)
})
test('Custom field with Boolean algebra', function (t) {
t.plan(1)
var boole = {
addition: function (a, b) { return a && b },
multiplication: function (a, b) { return a || b },
negation: function (a) { return !a }
}
t.equal(det([true, false,
false, true], boole), true)
})