import assert from 'assert' import math from '../picomath.js' describe('The default full picomath instance "math"', () => { it('performs basic arithmetic operations', () => { assert.strictEqual(math.subtract(16, math.add(3,4,2)), 7) assert.strictEqual(math.negate(math.number('8')), -8) }) it('can be extended', () => { math('add', [args => typeof args[0] === 'string', (...addends) => addends.reduce((x,y) => x+y, '')]) assert.strictEqual(math.add('Kilroy',' is here'), 'Kilroy is here') }) it('handles complex numbers', () => { assert.deepStrictEqual(math.complex(2,3), {re: 2, im: 3}) assert.deepStrictEqual( math.subtract(16, math.add(3, math.complex(0,4), 2)), math.complex(11, -4)) assert.deepStrictEqual(math.negate(math.complex(3, '8')).im, -8) }) it('does not double-define subtract', () => { assert.deepStrictEqual(math.subtract.imps.length, 1) }) })