diff --git a/test/custom.js b/test/custom.js new file mode 100644 index 0000000..3ac22e9 --- /dev/null +++ b/test/custom.js @@ -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) + }) +})