feat: Add a couple of ways to install generics safely. #18

Merged
glen merged 2 commits from safe_generic into main 2022-07-23 02:41:59 +00:00
2 changed files with 10 additions and 0 deletions
Showing only changes of commit 0fba6544b4 - Show all commits

View File

@ -0,0 +1,3 @@
export {subtract} from './subtract.mjs'
export * from '../number/add.mjs'
export * from '../number/negate.mjs'

View File

@ -6,6 +6,7 @@ import * as numberAdd from '../src/number/add.mjs'
import * as complex from '../src/complex/all.mjs'
import * as complexAdd from '../src/complex/add.mjs'
import * as complexNegate from '../src/complex/negate.mjs'
import * as concreteSubtract from '../src/generic/subtract.concrete.mjs'
import extendToComplex from '../src/complex/extendToComplex.mjs'
const bw = new PocomathInstance('backwards')
@ -55,4 +56,10 @@ describe('A custom instance', () => {
assert.strictEqual('subtract' in cherry, false)
assert.strictEqual('negate' in cherry, false)
})
it("can use bundles that are closed under dependency", () => {
const ok = new PocomathInstance('concrete')
ok.install(concreteSubtract)
assert.strictEqual(ok.subtract(7, 5), 2)
})
})