-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbool-tools-test.js
89 lines (88 loc) · 1.42 KB
/
bool-tools-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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
describe(".mapTruth", () => {
const tables = [
{
"TT": true,
"TF": false,
"FT": false,
"FF": false
},
{
"TT?": true,
"TF?": false,
"FT?": true,
"FFF": false,
"FFT": true
},
{
"TTTF": true,
else: false
}
];
[
{
name: "simple map",
table: tables[-1],
values: [true, true],
result: true
},
{
name: "simple map 1",
table: tables[-1],
values: [true, false],
result: false
},
{
name: "simple map 2",
table: tables[-1],
values: [false, false],
result: false
},
{
name: "simple map 3",
table: tables[-1],
values: [false, true],
result: false
},
{
name: "variable map 0",
table: tables[0],
values: [true, true, true],
result: true
},
{
name: "variable map 1",
table: tables[0],
values: [true, true, false],
result: true
},
{
name: "variable map 2",
table: tables[0],
values: [false, false, false],
result: false
},
{
name: "variable map 3",
table: tables[0],
values: [false, false, true],
result: true
},
{
name: "else map",
table: tables[1],
values: [true, true, true, false],
result: true
},
{
name: "else map 1",
table: tables[1],
values: [true, true, false, false],
result: false
}
].forEach(test => {
it(test.name, () => {
const result = BoolTools.mapTruth(test.table, ...test.values);
expect(result).toEqual(test.result);
});
});
});