From 92c9891946646f0f54a19b7699e128571fbdc4b3 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Tue, 8 Mar 2016 02:46:06 +0100 Subject: Add simple parser library. --- test/Spec.hs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'test/Spec.hs') diff --git a/test/Spec.hs b/test/Spec.hs index 0f46756..612fea6 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -2,19 +2,27 @@ 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 "Sorting Group 1" [ - testProperty "prop1" prop1, - testProperty "prop2" prop2 - ] + testGroup "Parsing" [ + testProperty "empty" prop_empty, + testProperty "correct_item" prop_correct, + testProperty "tooLong_item" prop_tooLong + ] ] -prop1 b = b == False - where types = (b :: Bool) +isRight (Right _) = True +isRight _ = False + +isLeft = not . isRight -prop2 i = i == 42 - where types = (i :: Int) +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) -- cgit v1.2.3