summaryrefslogtreecommitdiff
path: root/Haskell-book/24/ParserExercises/test/LogTest/Main.hs
blob: 7d1d1358c937015640bce878afd584c904d0d524 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
module Main where

import LogParser
import Test.QuickCheck
import Text.Trifecta

maybeSuccess :: Text.Trifecta.Result a -> Maybe a
maybeSuccess (Text.Trifecta.Success a) = Just a
maybeSuccess _ = Nothing

main :: IO ()
main = do
    quickCheck ((\s -> (maybeSuccess $ parseString parseStatement mempty (show s)) == (Just s)) :: Statement -> Bool)
    quickCheck ((\s -> (maybeSuccess $ parseString parseLogEntry mempty (show s)) == (Just s)) :: LogEntry -> Bool)