kuebiko/tests/units/common.js
2025-04-18 05:59:15 -05:00

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`)
)