UNPKG

2.03 kBJavaScriptView Raw
1const algebra = require('algebra')
2
3const C = algebra.Complex
4
5const methodBinaryOperator = require('./features/methodBinaryOperator')
6const methodUnaryOperator = require('./features/methodUnaryOperator')
7const staticBinaryOperator = require('./features/staticBinaryOperator')
8const staticUnaryOperator = require('./features/staticUnaryOperator')
9
10describe('Complex', () => {
11 var operator
12
13 describe('zero', () => {
14 it('is static', () => {
15 C.zero.should.eql([0, 0])
16 })
17 })
18
19 describe('one', () => {
20 it('is static', () => {
21 C.one.should.eql([1, 0])
22 })
23 })
24
25 describe('addition', () => {
26 operator = 'addition'
27
28 it('is a static method', staticBinaryOperator(C, operator, [2, 1], [2, 3], [4, 4]))
29
30 it('is a class method', methodBinaryOperator(C, operator, [1, 2], [1, -1], [2, 1]))
31 })
32
33 describe('subtraction', () => {
34 operator = 'subtraction'
35
36 it('is a static method', staticBinaryOperator(C, operator, [2, 1], [2, 3], [0, -2]))
37
38 it('is a class method', methodBinaryOperator(C, operator, [0, 2], [1, -2], [-1, 4]))
39 })
40
41 describe('multiplication', () => {
42 operator = 'multiplication'
43
44 it('is a static method', staticBinaryOperator(C, operator, [2, 1], [2, -1], [5, 0]))
45
46 it('is a class method', methodBinaryOperator(C, operator, [1, 2], [-1, 2], [-5, 0]))
47 })
48
49 describe('division', () => {
50 operator = 'division'
51
52 it('is a static method', staticBinaryOperator(C, operator, [2, 4], [2, 0], [1, 2]))
53
54 it('is a class method', methodBinaryOperator(C, operator, [5, 0], [2, -1], [2, 1]))
55 })
56
57 describe('negation', () => {
58 operator = 'negation'
59
60 it('is a static method', staticUnaryOperator(C, operator, [-2, 1], [2, -1]))
61
62 it('is a class method', methodUnaryOperator(C, operator, [1, 8], [-1, -8]))
63 })
64
65 describe('conjugation', () => {
66 operator = 'conjugation'
67
68 it('is a static method', staticUnaryOperator(C, operator, [2, 1], [2, -1]))
69
70 it('is a class method', methodUnaryOperator(C, operator, [1, 7], [1, -7]))
71 })
72})