import assert from 'assert' import math from '#nanomath' import {ReturnType, ReturnTyping} from '#core/Type.js' const {Complex, NumberT} = math.types describe('generic arithmetic', () => { it('squares anything', () => { const sq = math.square assert.strictEqual(sq(7), 49) assert.strictEqual(ReturnType(math.square.resolve([NumberT])), NumberT) assert.deepStrictEqual(sq(math.complex(3, 4)), math.complex(-7, 24)) const eyes = math.complex(0, 2) assert.strictEqual(sq(eyes), -4) const sqFull = math.square.resolve(Complex(NumberT), ReturnTyping.full) assert.deepStrictEqual(sqFull(eyes), math.complex(-4, 0)) }) })