feat: Add return typing strategies and implement sqrt with them (#26)
All checks were successful
/ test (push) Successful in 17s
All checks were successful
/ test (push) Successful in 17s
Resolves #25 Reviewed-on: #26 Co-authored-by: Glen Whitney <glen@studioinfinity.org> Co-committed-by: Glen Whitney <glen@studioinfinity.org>
This commit is contained in:
parent
aad62df8ac
commit
0765ba7202
35 changed files with 1125 additions and 152 deletions
|
@ -1,11 +1,18 @@
|
|||
import assert from 'assert'
|
||||
import math from '#nanomath'
|
||||
import {ReturnTyping} from '#core/Type.js'
|
||||
|
||||
const {Complex, NumberT} = math.types
|
||||
|
||||
describe('generic arithmetic', () => {
|
||||
it('squares anything', () => {
|
||||
assert.strictEqual(math.square(7), 49)
|
||||
assert.strictEqual(
|
||||
math.square.resolve([math.types.NumberT]).returns,
|
||||
math.types.NumberT)
|
||||
const sq = math.square
|
||||
assert.strictEqual(sq(7), 49)
|
||||
assert.strictEqual(math.square.resolve([NumberT]).returns, 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))
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue