15 lines
433 B
JavaScript
15 lines
433 B
JavaScript
import { chain, curry } from 'izuna'
|
|
import { parse } from '../../src/index.js'
|
|
|
|
export const assertState = curry((expected, state) => {
|
|
assertEq(expected, state[0])
|
|
})
|
|
|
|
export const parseEq = curry((parser, input, expected) =>
|
|
chain(assertState(expected), parse(parser, input))
|
|
)
|
|
|
|
export const parseErr = curry((parser, input) =>
|
|
assert(parse(parser, input).isErr(), `expected an error but '${input}' parsed successfully`)
|
|
)
|
|
|