UNPKG

3.49 kBJavaScriptView Raw
1const algebra = require('algebra')
2
3const methodBinaryOperator = require('./features/methodBinaryOperator')
4const methodUnaryOperator = require('./features/methodUnaryOperator')
5const staticBinaryOperator = require('./features/staticBinaryOperator')
6const staticUnaryOperator = require('./features/staticUnaryOperator')
7
8const Cyclic = algebra.Cyclic
9
10const elements = ' abcdefghijklmnopqrstuvwyxz0123456789'
11
12const Alphanum = Cyclic(elements)
13
14describe('Cyclic', () => {
15 describe('zero', () => {
16 it('is static', () => {
17 Alphanum.zero.should.eql(' ')
18 })
19 })
20
21 describe('one', () => {
22 it('is static', () => {
23 Alphanum.one.should.eql('a')
24 })
25 })
26
27 describe('addition', () => {
28 const operator = 'addition'
29
30 it('is a static method', staticBinaryOperator(Alphanum, operator, 'a', 'b', 'c'))
31
32 it('is a class method', methodBinaryOperator(Alphanum, operator, 'a', 'b', 'c'))
33
34 it('accepts many arguments', () => {
35 const x = new Alphanum('b')
36 x.addition('a', 'a', 'a').data.should.eql('e')
37 })
38 })
39
40 describe('subtraction', () => {
41 const operator = 'subtraction'
42
43 it('is a static method', staticBinaryOperator(Alphanum, operator, '8', 'b', '6'))
44
45 it('is a class method', methodBinaryOperator(Alphanum, operator, 'f', 'd', 'b'))
46
47 it('accepts many arguments', () => {
48 const x = new Alphanum('e')
49 x.subtraction('e', 'a', 'b').data.should.eql('7')
50 })
51 })
52
53 describe('multiplication', () => {
54 const operator = 'multiplication'
55
56 it('is a static method', staticBinaryOperator(Alphanum, operator, 'a', 'b', 'b'))
57
58 it('is a class method', methodBinaryOperator(Alphanum, operator, 'c', 'c', 'i'))
59
60 it('accepts many arguments', () => {
61 const x = new Alphanum('c')
62 x.multiplication('0', 'u', 'e').data.should.eql('5')
63 })
64 })
65
66 describe('division', () => {
67 const operator = 'division'
68
69 it('is a static method', staticBinaryOperator(Alphanum, operator, 'e', 'n', 'c'))
70
71 it('is a class method', methodBinaryOperator(Alphanum, operator, 'r', 'o', 'p'))
72
73 it('accepts many arguments', () => {
74 const x = new Alphanum('y')
75 x.division('e', 'e').data.should.eql('8')
76 })
77 })
78
79 describe('equality', () => {
80 const operator = 'equality'
81
82 it('is a static method', staticBinaryOperator(Alphanum, operator, 'z', 'z', true))
83
84 it('is a class method', () => {
85 const x = new Alphanum('g')
86 x.equality('g').should.be.ok
87 })
88 })
89
90 describe('disequality', () => {
91 const operator = 'disequality'
92
93 it('is a static method', staticBinaryOperator(Alphanum, operator, 'a', ' ', true))
94
95 it('is a class method', () => {
96 const x = new Alphanum('e')
97 x.disequality('n').should.be.ok
98 })
99 })
100
101 describe('negation', () => {
102 const operator = 'negation'
103
104 it('is a static method', staticUnaryOperator(Alphanum, operator, 'c', '7'))
105
106 it('is a class method', methodUnaryOperator(Alphanum, operator, 'z', 'k'))
107
108 it('is an involution', () => {
109 const x = new Alphanum('d')
110 x.negation().negation().data.should.be.eql('d')
111 })
112 })
113
114 describe('inversion', () => {
115 const operator = 'inversion'
116
117 it('is a static method', staticUnaryOperator(Alphanum, operator, 'w', '2'))
118
119 it('is a class method', methodUnaryOperator(Alphanum, operator, 'y', 'q'))
120
121 it('is an involution', () => {
122 const x = new Alphanum('8')
123 x.inversion().inversion().data.should.be.eql('8')
124 })
125 })
126})