more balance report test updates

This commit is contained in:
Simon Michael 2009-03-15 11:10:36 +00:00
parent 5fb256b582
commit 82885b3773

View File

@ -73,6 +73,14 @@ $ hledger -f sample.ledger balance o
$-1
@
@
$ hledger -f sample.ledger balance --depth 1
$-1 assets
$2 expenses
$-2 income
$1 liabilities
@
-}
-- other test tools:
-- http://hackage.haskell.org/cgi-bin/hackage-scripts/package/test-framework
@ -210,7 +218,7 @@ tests = [
," $1 liabilities:debts"
]
,"balance report level can also be limited with --depth" ~:
,"balance report can be limited with --depth" ~:
([Depth "1"], []) `gives`
[" $-1 assets"
," $2 expenses"
@ -230,7 +238,7 @@ tests = [
,"balance report with account pattern o and --depth 1" ~:
([Depth "1"], ["o"]) `gives`
[" $1 expenses:food"
[" $1 expenses"
," $-2 income"
,"--------------------"
," $-1"
@ -242,7 +250,7 @@ tests = [
," $1 bank:saving"
," $-2 cash"
," $-1 income:salary"
," $1 liabilities"
," $1 liabilities:debts"
,"--------------------"
," $-1"
]
@ -250,16 +258,22 @@ tests = [
,"balance report with account pattern e" ~:
([], ["e"]) `gives`
[" $-1 assets"
," $1 bank:saving"
," $-2 cash"
," $2 expenses"
," $1 food"
," $1 supplies"
," $-2 income"
," $-1 gifts"
," $-1 salary"
," $1 liabilities:debts"
]
,"balance report with unmatched parent of two matched subaccounts" ~:
([], ["cash","saving"]) `gives`
[" $1 assets:bank:saving"
," $-2 assets:cash"
[" $-1 assets"
," $1 bank:saving"
," $-2 cash"
,"--------------------"
," $-1"
]
@ -274,8 +288,12 @@ tests = [
,"balance report with negative account pattern" ~:
([], ["not:assets"]) `gives`
[" $2 expenses"
," $1 food"
," $1 supplies"
," $-2 income"
," $1 liabilities"
," $-1 gifts"
," $-1 salary"
," $1 liabilities:debts"
,"--------------------"
," $1"
]
@ -285,7 +303,7 @@ tests = [
,"balance report negative patterns affect totals" ~:
([], ["expenses","not:food"]) `gives`
[" $1 expenses"
[" $1 expenses:supplies"
,"--------------------"
," $1"
]
@ -314,8 +332,8 @@ tests = [
canonicaliseAmounts True rl -- enable cost basis adjustment
showBalanceReport [] [] l `is`
unlines
[" $500 a"
," $-500 c"
[" $500 a:b"
," $-500 c:d"
]
,"balance report elides zero-balance root account(s)" ~: do
@ -325,11 +343,10 @@ tests = [
," test:a 1"
," test:b"
])
showBalanceReport [] [] l `is` ""
showBalanceReport [SubTotal] [] l `is`
showBalanceReport [] [] l `is`
unlines
[" 1 test:a"
," -1 test:b"
[" 1 test:a"
," -1 test:b"
]
]
@ -358,26 +375,6 @@ tests = [
Right e' -> (tamount $ last $ etransactions e')
Left _ -> error "should not happen")
,"balancereportacctnames" ~:
let gives (opt,pats) e = do
l <- sampleledger
let t = pruneZeroBalanceLeaves $ ledgerAccountTree 999 l
balancereportacctnames l (opt=="-s") pats t `is` e
in TestList
[
"balancereportacctnames 0" ~: ("-s",[]) `gives` ["assets","assets:bank","assets:bank:checking","assets:bank:saving",
"assets:cash","expenses","expenses:food","expenses:supplies","income",
"income:gifts","income:salary","liabilities","liabilities:debts"]
,"balancereportacctnames 1" ~: ("", []) `gives` ["assets","expenses","income","liabilities"]
,"balancereportacctnames 2" ~: ("", ["assets"]) `gives` ["assets"]
,"balancereportacctnames 3" ~: ("", ["as"]) `gives` ["assets","assets:cash"]
,"balancereportacctnames 4" ~: ("", ["assets:cash"]) `gives` ["assets:cash"]
,"balancereportacctnames 5" ~: ("", ["^assets"]) `gives` ["expenses","income","liabilities"]
,"balancereportacctnames 6" ~: ("", ["^e"]) `gives` []
,"balancereportacctnames 7" ~: ("-s",["assets"]) `gives` ["assets","assets:bank","assets:bank:checking","assets:bank:saving","assets:cash"]
,"balancereportacctnames 8" ~: ("-s",["^e"]) `gives` []
]
,"cacheLedger" ~: do
(length $ Map.keys $ accountmap $ cacheLedger [] rawledger7) `is` 15