picomath/test/custom.js

22 lines
798 B
JavaScript
Raw Normal View History

import assert from 'assert'
import math from '../picomath.js'
import picoInstance from '../picomathInstance.js'
import createNumber from '../number/all.js'
import createComplex from '../complex/all.js'
describe('Custom instances', () => {
it("doesn't matter what order you assemble", () => {
const bw = picoInstance('backwards')
createComplex(bw)
createNumber(bw)
assert.strictEqual(bw.subtract(16, bw.add(3,4,2)), 7)
assert.strictEqual(bw.negate(bw.number('8')), -8)
assert.deepStrictEqual(bw.complex(2,3), {re: 2, im: 3})
assert.deepStrictEqual(
bw.subtract(16, bw.add(3, bw.complex(0,4), 2)),
math.complex(11, -4)) // note both instances coexist
assert.deepStrictEqual(bw.negate(math.complex(3, '8')).im, -8)
})
})