packages feed

mdoc-0.1.0.0: test/Mdoc/Test/Parse.hs

-- |
--
-- Module      : Mdoc.Test.Parse
-- Copyright   : (c) 2026 Patrick Brisbin
-- License     : AGPL-3
-- Maintainer  : pbrisbin@gmail.com
-- Stability   : experimental
-- Portability : POSIX
module Mdoc.Test.Parse
  ( parseTest
  ) where

import Mdoc.Prelude

import Mdoc.Parse
import Test.Hspec

parseTest
  :: (Eq a, HasCallStack, Show a) => Parser a -> [Text] -> a -> Expectation
parseTest p input expected = do
  case runParser p "<test>" (mconcat $ map (<> "\n") input) of
    Left err -> expectationFailure $ "Unexpected ParseError:\n" <> errorBundlePretty err
    Right actual -> actual `shouldBe` expected