2022-08-03 18:27:40 +00:00
|
|
|
import assert from 'assert'
|
|
|
|
import math from '../../src/pocomath.mjs'
|
|
|
|
|
|
|
|
describe('tuple', () => {
|
|
|
|
it('can be created and provide its length', () => {
|
2022-08-04 15:23:14 +00:00
|
|
|
assert.strictEqual(math.length(math.tuple(3, 5.2, 2)), 3)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('does not allow unification by converting consecutive arguments', () => {
|
|
|
|
assert.throws(() => math.tuple(3, 5.2, 2n), /TypeError.*unif/)
|
|
|
|
// Hence, the order matters in a slightly unfortunate way,
|
|
|
|
// but I think being a little ragged in these edge cases is OK:
|
|
|
|
assert.throws(
|
|
|
|
() => math.tuple(3, 2n, math.complex(5.2)),
|
|
|
|
/TypeError.*unif/)
|
|
|
|
assert.deepStrictEqual(
|
|
|
|
math.tuple(3, math.complex(2n), 5.2),
|
|
|
|
{elts: [math.complex(3), math.complex(2n), math.complex(5.2)]})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('can be tested for zero', () => {
|
|
|
|
assert.strictEqual(math.isZero(math.tuple(0,1)), false)
|
|
|
|
assert.strictEqual(math.isZero(math.tuple(0n,0n,0n,0n)), true)
|
|
|
|
assert.strictEqual(math.isZero(math.tuple(0,0.001,0)), false)
|
|
|
|
assert.strictEqual(math.isZero(math.tuple(0,math.complex(0,0))), true)
|
2022-08-03 18:27:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
})
|