All checks were successful
/ test (pull_request) Successful in 19s
Also adds implicit conversion configuration option to Type constructor, and institutes a numbers-only bundle, and supports argument matching with implicit conversions. Still need to test that a behavior that invokes implicit conversion ends up with the conversion operation as a dependency (and so regenerates itself if the conversion changes).
19 lines
565 B
JavaScript
19 lines
565 B
JavaScript
import assert from 'assert'
|
|
import {NumberT} from '../NumberT.js'
|
|
import {BooleanT} from '#boolean/BooleanT.js'
|
|
import math from '#nanomath'
|
|
|
|
describe('NumberT Type', () => {
|
|
it('correctly recognizes numbers', () => {
|
|
assert(NumberT.test(3))
|
|
assert(NumberT.test(NaN))
|
|
assert(NumberT.test(Infinity))
|
|
assert(!NumberT.test("3"))
|
|
})
|
|
|
|
it('can convert from BooleanT to NumberT', () => {
|
|
const cnvBtoN = NumberT.from.get(BooleanT)(math)
|
|
assert.strictEqual(cnvBtoN(true), 1)
|
|
assert.strictEqual(cnvBtoN(false), 0)
|
|
})
|
|
})
|