1 {-# LANGUAGE OverloadedStrings #-}
5 import Control.Exception (evaluate)
8 import Data.Text (Text)
9 import Data.Hastext.Parsers.Occurrences (parse)
12 main = print "hspec $ do"
13 describe "Parser for occurrences" $ do
17 it "returns the result of one parsing" $ do
18 parse "internet" "internet" `shouldBe` Right ((txt, 1) :: (Text, Int))
20 -- | Context of Text should be toLower
21 it "returns the result of one parsing not case sensitive" $ do
22 let txtCase = "Internet"
23 parse txtCase "internet" `shouldBe` Right ((txtCase, 1) :: (Text, Int))
25 it "returns the result of one parsing after space" $ do
27 `shouldBe` Right ((txt, 1) :: (Text, Int))
29 it "returns the result of one parsing after chars" $ do
30 parse txt "l'internet"
31 `shouldBe` (Right ((txt, 1) :: (Text, Int)))
33 it "returns the result of multiple parsing" $ do
34 parse txt "internet internet of things"
35 `shouldBe` (Right ((txt, 2) :: (Text, Int)))
37 it "returns the result of multiple parsing separated by text" $ do
38 parse txt "internet in the internet of things"
39 `shouldBe` (Right ((txt, 2) :: (Text, Int)))
41 it "returns the result of multiple parsing separated by punctuation" $ do
42 parse txt "internet. In the internet of things, internet like; internet?"
43 `shouldBe` (Right ((txt, 4) :: (Text, Int)))