UNPKG

algebra

Version:

means completeness and balancing, from the Arabic word الجبر

73 lines (49 loc) 2.08 kB
/* eslint-env mocha */ const algebra = require('algebra') const C = algebra.Complex const methodBinaryOperator = require('./features/methodBinaryOperator') const methodUnaryOperator = require('./features/methodUnaryOperator') const staticBinaryOperator = require('./features/staticBinaryOperator') const staticUnaryOperator = require('./features/staticUnaryOperator') describe('Complex', () => { describe('zero', () => { it('is static', () => { C.zero.should.eql([0, 0]) }) }) describe('one', () => { it('is static', () => { C.one.should.eql([1, 0]) }) }) describe('addition', () => { const operator = 'addition' it('is a static method', staticBinaryOperator(C, operator, [2, 1], [2, 3], [4, 4])) it('is a class method', methodBinaryOperator(C, operator, [1, 2], [1, -1], [2, 1])) }) describe('subtraction', () => { const operator = 'subtraction' it('is a static method', staticBinaryOperator(C, operator, [2, 1], [2, 3], [0, -2])) it('is a class method', methodBinaryOperator(C, operator, [0, 2], [1, -2], [-1, 4])) }) describe('multiplication', () => { const operator = 'multiplication' it('is a static method', staticBinaryOperator(C, operator, [2, 1], [2, -1], [5, 0])) it('is a class method', methodBinaryOperator(C, operator, [1, 2], [-1, 2], [-5, 0])) }) describe('division', () => { const operator = 'division' it('is a static method', staticBinaryOperator(C, operator, [2, 4], [2, 0], [1, 2])) it('is a class method', methodBinaryOperator(C, operator, [5, 0], [2, -1], [2, 1])) }) describe('negation', () => { const operator = 'negation' it('is a static method', staticUnaryOperator(C, operator, [-2, 1], [2, -1])) it('is a class method', methodUnaryOperator(C, operator, [1, 8], [-1, -8])) }) describe('conjugation', () => { const operator = 'conjugation' it('is a static method', staticUnaryOperator(C, operator, [2, 1], [2, -1])) it('is a class method', methodUnaryOperator(C, operator, [1, 7], [1, -7])) }) })