lib: fix tests for zero amount style (#230, #276)

This commit is contained in:
Simon Michael 2015-09-02 16:38:45 -07:00
parent b770190942
commit 821f1b7120
3 changed files with 31 additions and 6 deletions

View File

@ -624,13 +624,13 @@ tests_Hledger_Data_Amount = TestList $
-- MixedAmount
,"adding mixed amounts, preserving minimum precision and a single commodity on zero" ~: do
,"adding mixed amounts to zero, the commodity and amount style are preserved" ~: do
(sum $ map (Mixed . (:[]))
[usd 1.25
,usd (-1) `withPrecision` 0
,usd (-1) `withPrecision` 3
,usd (-0.25)
])
`is` Mixed [usd 0 `withPrecision` 0]
`is` Mixed [usd 0 `withPrecision` 3]
,"adding mixed amounts with total prices" ~: do
(sum $ map (Mixed . (:[]))

View File

@ -170,7 +170,7 @@ tests_balanceReport =
showw (acct,amt) = (acct, showMixedAmountDebug amt)
assertEqual "items" (map showw eitems) (map showw aitems)
assertEqual "total" (showMixedAmountDebug etotal) (showMixedAmountDebug atotal)
usd0 = nullamt{acommodity="$"}
usd0 = usd 0
in [
"balanceReport with no args on null journal" ~: do

View File

@ -46,7 +46,7 @@ hledger -f - balance
0
>>>=0
# 4. a zero amount is always displayed as just "0", regardless of any commodity/decimal places/price (like ledger)
# 4. a single-commodity zero amount's commodity/decimal places/price is preserved, when possible
#
hledger -f- print --empty
<<<
@ -55,11 +55,36 @@ hledger -f- print --empty
b
>>>
2010/03/01 x
a 0
a 0 @ 3EUR
b 0
>>>=0
# 5.
# When preserving a zero amount's commodity, we should also preserve
# the amount style, such as where to place the symbol.
# https://github.com/simonmichael/hledger/issues/230
hledger -f- balance
<<<
D 1000,00€
1/1
a:b 0
1/2
a:1 4000,58
a:D -1000,58
e -3000
>>>
3000,00€ a
4000,58€ 1
-1000,58€ D
-3000,00€ e
--------------------
0
>>>= 0
# 5. mixed amounts with prices
# XXX
# hledger -f - print