more tests, cleanups

This commit is contained in:
Simon Michael 2009-03-15 04:19:50 +00:00
parent c4c94baeab
commit c1267ff17c

View File

@ -50,8 +50,8 @@ parseis :: (Show a, Eq a) => (Either ParseError a) -> a -> Assertion
parse `parseis` expected = either printParseError (`is` expected) parse parse `parseis` expected = either printParseError (`is` expected) parse
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- Tests for any function or topic. Mostly ordered by test name. -- | Tests for any function or topic. Mostly ordered by test name.
tests :: [Test]
tests = [ tests = [
"account directive" ~: "account directive" ~:
@ -110,7 +110,7 @@ tests = [
"balance report tests" ~: "balance report tests" ~:
let (opts,args) `gives` es = do let (opts,args) `gives` es = do
l <- sampleledgerwithopts [] args l <- sampleledgerwithopts opts args
showBalanceReport opts args l `is` unlines es showBalanceReport opts args l `is` unlines es
in TestList in TestList
[ [
@ -326,6 +326,18 @@ tests = [
[WeeklyOpt, Period "yearly"] `gives` Yearly [WeeklyOpt, Period "yearly"] `gives` Yearly
, ,
"isAccountNamePrefixOf" ~: do
"assets" `isAccountNamePrefixOf` "assets:bank" `is` True
"assets" `isAccountNamePrefixOf` "assets:bank:checking" `is` True
"my assets" `isAccountNamePrefixOf` "assets:bank" `is` False
,
"isSubAccountNameOf" ~: do
"assets:bank" `isSubAccountNameOf` "assets" `is` True
"assets:bank:checking" `isSubAccountNameOf` "assets" `is` False
"assets:bank" `isSubAccountNameOf` "my assets" `is` False
,
"default year" ~: do "default year" ~: do
rl <- rawledgerfromstring defaultyear_ledger_str rl <- rawledgerfromstring defaultyear_ledger_str
(edate $ head $ entries rl) `is` fromGregorian 2009 1 1 (edate $ head $ entries rl) `is` fromGregorian 2009 1 1