Add ability to match fixed numbers

This commit is contained in:
2017-11-11 16:51:29 +03:00
parent bb244f47b2
commit 47c65c9b25
2 changed files with 87 additions and 13 deletions

@ -3,12 +3,15 @@ import Test.QuickCheck
import Control.Exception (evaluate)
import Data.Dates
import Lib (match)
import Lib
main :: IO ()
main = hspec $ do
describe "Cron pattern" $ do
it "createParts" $
length (createParts "* * * * * *") `shouldBe` 6
it "matches fixed time" $
let
pattern = "* * * * * *"
@ -23,8 +26,12 @@ main = hspec $ do
in
countMatches pattern dates `shouldBe` (60 :: Int)
-- it "matches exactly moment" $
-- match "0 0 11 10 2017" (DateTime 2017 10 11 0 0 0) `shouldBe` (True :: Bool)
it "matches exactly moment" $
let
date = (DateTime 2017 10 11 0 0 0)
pattern = "0 0 11 10 * 2017"
in
match pattern date `shouldBe` (True :: Bool)
countMatches :: String -> [DateTime] -> Int