25 lines
883 B
JavaScript
25 lines
883 B
JavaScript
|
import assert from 'assert'
|
||
|
import {BooleanT} from '../BooleanT.js'
|
||
|
import math from '#nanomath'
|
||
|
|
||
|
describe('BooleanT Type', () => {
|
||
|
it('correctly recognizes booleans', () => {
|
||
|
assert(BooleanT.test(true))
|
||
|
assert(BooleanT.test(false))
|
||
|
assert(!BooleanT.test(null))
|
||
|
assert(!BooleanT.test(1))
|
||
|
})
|
||
|
it('autoconverts to number type', () => {
|
||
|
assert.strictEqual(math.abs(false), 0)
|
||
|
assert.strictEqual(math.absquare(true), 1)
|
||
|
assert.strictEqual(math.add(true, true), 2)
|
||
|
assert.strictEqual(math.divide(false, true), 0)
|
||
|
assert.strictEqual(math.cbrt(true), 1)
|
||
|
assert.strictEqual(math.invert(true), 1)
|
||
|
assert.strictEqual(math.multiply(false, false), 0)
|
||
|
assert.strictEqual(math.negate(false), -0)
|
||
|
assert.strictEqual(math.subtract(false, true), -1)
|
||
|
assert.strictEqual(math.quotient(true, true), 1)
|
||
|
})
|
||
|
})
|