import Test.Framework (defaultMain, testGroup) import Test.Framework.Providers.QuickCheck2 (testProperty) import Test.QuickCheck import K.NanoParsec import qualified Data.Text as T import Data.Text.Arbitrary (Text(..)) main :: IO () main = defaultMain tests tests = [ testGroup "Parsing" [ testProperty "empty" prop_empty, testProperty "correct_item" prop_correct, testProperty "tooLong_item" prop_tooLong ] ] isRight (Right _) = True isRight _ = False isLeft = not . isRight prop_empty t = T.null t ==> isLeft (runParser item t) prop_correct t = T.length t == 1 ==> isRight (runParser item t) prop_tooLong t = T.length t > 1 ==> isLeft (runParser item t)