diff options
author | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2016-03-08 02:46:06 +0100 |
---|---|---|
committer | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2016-03-11 05:21:50 +0100 |
commit | 92c9891946646f0f54a19b7699e128571fbdc4b3 (patch) | |
tree | a03963e95f787d083079bc6b41fc7876f68fe560 /test/Spec.hs | |
parent | d2729dc9c89f359347fdfe9dcc88cd3a8e258d04 (diff) |
Add simple parser library.
Diffstat (limited to 'test/Spec.hs')
-rw-r--r-- | test/Spec.hs | 24 |
1 files changed, 16 insertions, 8 deletions
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) |