Add app and tests for formatting

This commit is contained in:
Anton Vakhrushev 2019-03-09 22:51:35 +03:00
parent e88d1b39ed
commit 8b1fd369fd
2 changed files with 5 additions and 5 deletions

View File

@ -34,4 +34,4 @@ test:
.PHONY: format
format:
${stack} .local/hfmt -w src/
${stack} .local/hfmt -w app/ src/ test/

View File

@ -17,19 +17,19 @@ spec =
it "matches fixed time" $
let ptn = "* * * * *"
date = DateTime 2017 10 11 0 0 0
in match ptn date `shouldBe` Just True
in match ptn date `shouldBe` Just True
it "matches all minutes" $
let ptn = "* * * * *"
dates = [DateTime 2017 10 11 0 i 0 | i <- [0 .. 59]]
in countMatches ptn dates `shouldBe` 60
in countMatches ptn dates `shouldBe` 60
it "matches exactly moment" $
let date = DateTime 2017 10 11 0 0 0
ptn = "0 0 11 10 *"
in match ptn date `shouldBe` Just True
in match ptn date `shouldBe` Just True
it "matches moment" $
let date = DateTime 2017 10 10 12 10 0
ptn = "* 12 * * *"
in match ptn date `shouldBe` Just True
in match ptn date `shouldBe` Just True
countMatches :: String -> [DateTime] -> Int
countMatches p xs = sum $ map (f p) xs