picomath/test/_picomathInstance.js
Glen Whitney 536656bfe8 feat: Initial core of picomath
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.
2022-03-25 00:49:03 -07:00

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!
})
})