Glen Whitney
536656bfe8
Implements a totally simplistic "poortf" mutable typed function and a picomath instance generator, as well as the very beginnings of a number type and one generic function and a default full picomath instance. Also provides some tests which serve as usage examples.
14 lines
459 B
JavaScript
14 lines
459 B
JavaScript
import assert from 'assert'
|
|
import picomathInstance from '../picomathInstance.js'
|
|
|
|
describe('picomath core', () => {
|
|
it('creates an instance that can define TFs', () => {
|
|
const pmath = picomathInstance('pmath')
|
|
pmath('add', [() => true, (a,b) => a+b])
|
|
assert.strictEqual(pmath.add(2,2), 4)
|
|
assert.strictEqual(pmath.add('Kilroy', 17), 'Kilroy17')
|
|
assert.strictEqual(pmath.add(1), NaN)
|
|
// I guess + never throws!
|
|
})
|
|
})
|