summaryrefslogtreecommitdiff
path: root/test/Spec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'test/Spec.hs')
-rw-r--r--test/Spec.hs24
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)