Add weekend test
This commit is contained in:
parent
476c6c2bfb
commit
1b93fce200
1 changed files with 14 additions and 8 deletions
|
|
@ -55,19 +55,25 @@ prop_ParseComplicated a b c d e =
|
||||||
- BoolExpr properties
|
- BoolExpr properties
|
||||||
-}
|
-}
|
||||||
|
|
||||||
prop_ParseLeapYears :: Integer -> Property
|
prop_FindWeekends :: Integer -> Property
|
||||||
prop_ParseLeapYears a =
|
prop_FindWeekends a =
|
||||||
let formula = "((year%400 == 0) || ((year%4 == 0) && (year%100 != 0))) == isleapyear"
|
let formula = "(weekday == saturday || weekday == sunday) == isweekend"
|
||||||
|
in parseEvalBool formula (toDay a) === Just True
|
||||||
|
|
||||||
|
prop_FindLeapYears :: Integer -> Property
|
||||||
|
prop_FindLeapYears a =
|
||||||
|
let formula = "(year%400 == 0 || (year%4 == 0 && year%100 != 0)) == isleapyear"
|
||||||
in parseEvalBool formula (toDay a) === Just True
|
in parseEvalBool formula (toDay a) === Just True
|
||||||
|
|
||||||
testDateExpr :: SpecWith ()
|
testDateExpr :: SpecWith ()
|
||||||
testDateExpr = describe "Date expressions" $ do
|
testDateExpr = describe "Date expressions" $ do
|
||||||
describe "IntExpr" $ do
|
describe "IntExpr" $ do
|
||||||
it "parses integers" $ property prop_ParseInteger
|
it "parses integers" $ property prop_ParseInteger
|
||||||
it "parses addition and subtraction" $ property prop_ParseAddSub
|
it "evaluates addition and subtraction" $ property prop_ParseAddSub
|
||||||
it "parses multiplication and division" $ property prop_ParseMultDiv
|
it "evaluates multiplication and division" $ property prop_ParseMultDiv
|
||||||
it "parses a complicated equation" $ property prop_ParseComplicated
|
it "evaluates a complicated equation" $ property prop_ParseComplicated
|
||||||
describe "BoolExpr" $ do
|
describe "BoolExpr" $ do
|
||||||
it "parses \"true\"" $ parseEvalBool "true" anyDay `shouldBe` Just True
|
it "parses \"true\"" $ parseEvalBool "true" anyDay `shouldBe` Just True
|
||||||
it "parses \"false\"" $ parseEvalBool "false" anyDay `shouldBe` Just False
|
it "parses \"false\"" $ parseEvalBool "false" anyDay `shouldBe` Just False
|
||||||
it "parses leap years" $ property prop_ParseLeapYears
|
it "finds weekends" $ property prop_FindWeekends
|
||||||
|
it "finds leap years" $ property prop_FindLeapYears
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue