test: Make sure you can assemble in any order

This commit is contained in:
Glen Whitney 2022-03-25 02:03:20 -07:00
parent 32bc9ca515
commit 29653f25c4

21
test/custom.js Normal file
View File

@ -0,0 +1,21 @@
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)
})
})