UNPKG

2.09 kBJavaScriptView Raw
1var algebra = require('algebra')
2
3var C = algebra.Complex
4
5var methodBinaryOperator = require('./features/methodBinaryOperator')
6var methodUnaryOperator = require('./features/methodUnaryOperator')
7var staticBinaryOperator = require('./features/staticBinaryOperator')
8var staticUnaryOperator = require('./features/staticUnaryOperator')
9
10describe('Complex', function () {
11 var operator
12
13 describe('zero', function () {
14 it('is static', function () {
15 C.zero.should.eql([0, 0])
16 })
17 })
18
19 describe('one', function () {
20 it('is static', function () {
21 C.one.should.eql([1, 0])
22 })
23 })
24
25 describe('addition', function () {
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', function () {
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', function () {
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', function () {
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', function () {
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', function () {
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})