13 lines
485 B
JavaScript
13 lines
485 B
JavaScript
|
import assert from 'assert'
|
||
|
import math from '#nanomath'
|
||
|
|
||
|
describe('complex type operations', () => {
|
||
|
it('converts to number', () => {
|
||
|
assert.deepStrictEqual(math.complex(3), {re: 3, im: 0})
|
||
|
assert.deepStrictEqual(math.complex(NaN), {re: NaN, im: NaN})
|
||
|
assert.deepStrictEqual(math.complex(3, -1), {re: 3, im: -1})
|
||
|
assert.deepStrictEqual(math.complex(false, true), {re: false, im: true})
|
||
|
assert.throws(() => math.complex(3, false), RangeError)
|
||
|
})
|
||
|
})
|