feat(Types): Improve type spec and ignore signatures that use unknown type

This commit is contained in:
Glen Whitney 2022-07-24 12:52:05 -07:00
parent 890752a1e7
commit 358f68fbbd
7 changed files with 129 additions and 70 deletions

View file

@ -18,10 +18,18 @@ describe('The default full pocomath instance "math"', () => {
})
it('can be extended', () => {
math.install({'add': {
'...string': () => addends => addends.reduce((x,y) => x+y, '')
}})
assert.strictEqual(math.add('Kilroy',' is here'), 'Kilroy is here')
math.install({
add: {
'...stringK': () => addends => addends.reduce((x,y) => x+y, '')
},
Types: {
stringK: {
test: s => typeof s === 'string' && s.charAt(0) === 'K',
before: ['string']
}
}
})
assert.strictEqual(math.add('Kilroy','K is here'), 'KilroyK is here')
})
it('handles complex numbers', () => {