feat: Add a configuration for an instance that can be set at creation time
And use it to control whether the result of a complex operation where the imaginary part comes out to 0 will be coerced back to a number.
This commit is contained in:
parent
1c1ba91e48
commit
4213ade4ba
3 changed files with 14 additions and 1 deletions
|
@ -36,4 +36,14 @@ describe('Custom instances', () => {
|
|||
assert.strictEqual('subtract' in cherry, false)
|
||||
assert.strictEqual('negate' in cherry, false)
|
||||
})
|
||||
|
||||
const res = picoInstance('resolving', { resolveComplex: true })
|
||||
createNumbers(res)
|
||||
createComplex(res)
|
||||
|
||||
it("can be configured", () => {
|
||||
assert.strictEqual(res.add(res.complex(2,3), res.complex(2,-3)), 4)
|
||||
assert.deepStrictEqual(math.add(math.complex(2,3), math.complex(2,-3)),
|
||||
math.complex(4,0))
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue