From 29653f25c4b2016b7ad44950334b819d72cdbe96 Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Fri, 25 Mar 2022 02:03:20 -0700 Subject: [PATCH] test: Make sure you can assemble in any order --- test/custom.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/custom.js 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) + }) +})