Add ability to match fixed numbers
This commit is contained in:
13
test/Spec.hs
13
test/Spec.hs
@ -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
|
||||
|
Reference in New Issue
Block a user