26 lines
562 B
JavaScript
26 lines
562 B
JavaScript
import { it, assertEq } from 'folktest'
|
|
import { Some, None } from '../../src/option.js'
|
|
import { prove } from './monad.js'
|
|
|
|
const id = x => () => x
|
|
export const Tests = [
|
|
it('some should pass monadic laws', () => {
|
|
prove(
|
|
Some,
|
|
Some(1),
|
|
1,
|
|
x => Some(x + 1),
|
|
x => Some(x * 2)
|
|
)
|
|
}),
|
|
|
|
it('should not bind none', () => {
|
|
const opt = Some(1)
|
|
.bind(id(None))
|
|
.bind(id(Some(1)))
|
|
.map(x => x + 1)
|
|
|
|
assertEq(opt, None)
|
|
}),
|
|
]
|
|
|