Fix linting hints
This commit is contained in:
@ -8,13 +8,12 @@ main :: IO ()
|
||||
main = hspec spec
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
describe "Constraint" $ do
|
||||
it "can be created from number" $
|
||||
makeRangeFromNumber 10 `shouldBe` Constraint 10 10
|
||||
spec = describe "Constraint" $ do
|
||||
it "can be created from number" $
|
||||
makeRangeFromNumber 10 `shouldBe` Constraint 10 10
|
||||
|
||||
it "validate number" $
|
||||
10 `inRange` (Constraint 0 10) `shouldBe` True
|
||||
it "validate number" $
|
||||
10 `inRange` Constraint 0 10 `shouldBe` True
|
||||
|
||||
it "validate number" $
|
||||
10 `inRange` (Constraint 15 20) `shouldBe` False
|
||||
it "validate number" $
|
||||
10 `inRange` Constraint 15 20 `shouldBe` False
|
||||
|
@ -7,16 +7,15 @@ main :: IO ()
|
||||
main = hspec spec
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
describe "Splitting" $ do
|
||||
it "can process empty string" $
|
||||
wordsWhen (== '-') "" `shouldBe` []
|
||||
spec = describe "Splitting" $ do
|
||||
it "can process empty string" $
|
||||
wordsWhen (== '-') "" `shouldBe` []
|
||||
|
||||
it "can process only one word" $
|
||||
wordsWhen (== '-') "10" `shouldBe` ["10"]
|
||||
it "can process only one word" $
|
||||
wordsWhen (== '-') "10" `shouldBe` ["10"]
|
||||
|
||||
it "can separated by '-'" $
|
||||
wordsWhen (== '-') "10-20" `shouldBe` ["10", "20"]
|
||||
it "can separated by '-'" $
|
||||
wordsWhen (== '-') "10-20" `shouldBe` ["10", "20"]
|
||||
|
||||
it "can be separated by ','" $
|
||||
wordsWhen (== ',') "10,20,30" `shouldBe` ["10", "20", "30"]
|
||||
it "can be separated by ','" $
|
||||
wordsWhen (== ',') "10,20,30" `shouldBe` ["10", "20", "30"]
|
||||
|
@ -17,29 +17,27 @@ spec = do
|
||||
|
||||
it "matches fixed time" $
|
||||
let
|
||||
pattern = "* * * * * *"
|
||||
ptn = "* * * * * *"
|
||||
date = DateTime 2017 10 11 0 0 0
|
||||
in
|
||||
match pattern date `shouldBe` True
|
||||
match ptn date `shouldBe` True
|
||||
|
||||
it "matches all minutes" $
|
||||
let
|
||||
pattern = "* * * * * *"
|
||||
ptn = "* * * * * *"
|
||||
dates = [DateTime 2017 10 11 0 i 0 | i <- [0..59]]
|
||||
in
|
||||
countMatches pattern dates `shouldBe` 60
|
||||
countMatches ptn dates `shouldBe` 60
|
||||
|
||||
it "matches exactly moment" $
|
||||
let
|
||||
date = (DateTime 2017 10 11 0 0 0)
|
||||
pattern = "0 0 11 10 * 2017"
|
||||
date = DateTime 2017 10 11 0 0 0
|
||||
ptn = "0 0 11 10 * 2017"
|
||||
in
|
||||
match pattern date `shouldBe` True
|
||||
match ptn date `shouldBe` True
|
||||
|
||||
|
||||
countMatches :: String -> [DateTime] -> Int
|
||||
countMatches p xs = sum $ map (f p) xs
|
||||
where
|
||||
f x d = case match x d of
|
||||
True -> 1
|
||||
False -> 0
|
||||
f x d = if match x d then 1 else 0
|
||||
|
Reference in New Issue
Block a user