summaryrefslogtreecommitdiff
path: root/test/Spec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'test/Spec.hs')
-rw-r--r--test/Spec.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/Spec.hs b/test/Spec.hs
index 612fea6..4a90862 100644
--- a/test/Spec.hs
+++ b/test/Spec.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE OverloadedStrings #-}
import Test.Framework (defaultMain, testGroup)
import Test.Framework.Providers.QuickCheck2 (testProperty)
@@ -6,6 +7,7 @@ import K.NanoParsec
import qualified Data.Text as T
import Data.Text.Arbitrary (Text(..))
+import Control.Lens ((^?), _Right)
main :: IO ()
main = defaultMain tests
@@ -14,7 +16,8 @@ tests = [
testGroup "Parsing" [
testProperty "empty" prop_empty,
testProperty "correct_item" prop_correct,
- testProperty "tooLong_item" prop_tooLong
+ testProperty "tooLong_item" prop_tooLong,
+ testProperty "applicative" prop_applicative
]
]
@@ -26,3 +29,8 @@ 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)
+
+prop_applicative x = result == Just (x+1)
+ where x' :: Parser Integer
+ x' = unit x
+ result = runParser (pure (+1) <*> x') "" ^? _Right