refactor
This commit is contained in:
parent
eedf0b211a
commit
903bf23afd
26
Tests.hs
26
Tests.hs
@ -107,29 +107,6 @@ tests = TestList [
|
|||||||
accountNameTreeFrom ["a","a:b"] `is` Node "top" [Node "a" [Node "a:b" []]]
|
accountNameTreeFrom ["a","a:b"] `is` Node "top" [Node "a" [Node "a:b" []]]
|
||||||
accountNameTreeFrom ["a:b:c"] `is` Node "top" [Node "a" [Node "a:b" [Node "a:b:c" []]]]
|
accountNameTreeFrom ["a:b:c"] `is` Node "top" [Node "a" [Node "a:b" [Node "a:b:c" []]]]
|
||||||
|
|
||||||
,"amount arithmetic" ~: do
|
|
||||||
let a1 = dollars 1.23
|
|
||||||
let a2 = Amount (comm "$") (-1.23) Nothing
|
|
||||||
let a3 = Amount (comm "$") (-1.23) Nothing
|
|
||||||
(a1 + a2) `is` Amount (comm "$") 0 Nothing
|
|
||||||
(a1 + a3) `is` Amount (comm "$") 0 Nothing
|
|
||||||
(a2 + a3) `is` Amount (comm "$") (-2.46) Nothing
|
|
||||||
(a3 + a3) `is` Amount (comm "$") (-2.46) Nothing
|
|
||||||
sum [a2,a3] `is` Amount (comm "$") (-2.46) Nothing
|
|
||||||
sum [a3,a3] `is` Amount (comm "$") (-2.46) Nothing
|
|
||||||
sum [a1,a2,a3,-a3] `is` Amount (comm "$") 0 Nothing
|
|
||||||
let dollar0 = dollar{precision=0}
|
|
||||||
(sum [Amount dollar 1.25 Nothing, Amount dollar0 (-1) Nothing, Amount dollar (-0.25) Nothing])
|
|
||||||
`is` (Amount dollar 0 Nothing)
|
|
||||||
|
|
||||||
,"mixed amount arithmetic" ~: do
|
|
||||||
let dollar0 = dollar{precision=0}
|
|
||||||
(sum $ map (Mixed . (\a -> [a]))
|
|
||||||
[Amount dollar 1.25 Nothing,
|
|
||||||
Amount dollar0 (-1) Nothing,
|
|
||||||
Amount dollar (-0.25) Nothing])
|
|
||||||
`is` Mixed [Amount dollar 0 Nothing]
|
|
||||||
|
|
||||||
,"balance report tests" ~:
|
,"balance report tests" ~:
|
||||||
let (opts,args) `gives` es = do
|
let (opts,args) `gives` es = do
|
||||||
l <- sampleledgerwithopts opts args
|
l <- sampleledgerwithopts opts args
|
||||||
@ -653,9 +630,6 @@ tests = TestList [
|
|||||||
|
|
||||||
,"show hours" ~: show (hours 1) ~?= "1.0h"
|
,"show hours" ~: show (hours 1) ~?= "1.0h"
|
||||||
|
|
||||||
,"showMixedAmount" ~: do
|
|
||||||
showMixedAmount (Mixed []) ~?= "0"
|
|
||||||
|
|
||||||
,"someamount" ~: do
|
,"someamount" ~: do
|
||||||
let -- | compare a parse result with a MixedAmount, showing the debug representation for clarity
|
let -- | compare a parse result with a MixedAmount, showing the debug representation for clarity
|
||||||
assertMixedAmountParse parseresult mixedamount =
|
assertMixedAmountParse parseresult mixedamount =
|
||||||
|
|||||||
@ -43,9 +43,9 @@ tests_Ledger = TestList
|
|||||||
[
|
[
|
||||||
-- Ledger.Account.tests_Account
|
-- Ledger.Account.tests_Account
|
||||||
-- ,Ledger.AccountName.tests_AccountName
|
-- ,Ledger.AccountName.tests_AccountName
|
||||||
-- ,Ledger.Amount.tests_Amount
|
Ledger.Amount.tests_Amount
|
||||||
-- ,Ledger.Commodity.tests_Commodity
|
-- ,Ledger.Commodity.tests_Commodity
|
||||||
Ledger.Dates.tests_Dates
|
,Ledger.Dates.tests_Dates
|
||||||
-- ,Ledger.IO.tests_IO
|
-- ,Ledger.IO.tests_IO
|
||||||
,Ledger.Transaction.tests_Transaction
|
,Ledger.Transaction.tests_Transaction
|
||||||
-- ,Ledger.Ledger.tests_Ledger
|
-- ,Ledger.Ledger.tests_Ledger
|
||||||
|
|||||||
@ -261,3 +261,34 @@ nullmixedamt = Mixed []
|
|||||||
missingamt :: MixedAmount
|
missingamt :: MixedAmount
|
||||||
missingamt = Mixed [Amount Commodity {symbol="AUTO",side=L,spaced=False,comma=False,precision=0} 0 Nothing]
|
missingamt = Mixed [Amount Commodity {symbol="AUTO",side=L,spaced=False,comma=False,precision=0} 0 Nothing]
|
||||||
|
|
||||||
|
|
||||||
|
tests_Amount = TestList [
|
||||||
|
|
||||||
|
"showMixedAmount" ~: do
|
||||||
|
showMixedAmount (Mixed []) ~?= "0"
|
||||||
|
|
||||||
|
,"amount arithmetic" ~: do
|
||||||
|
let a1 = dollars 1.23
|
||||||
|
let a2 = Amount (comm "$") (-1.23) Nothing
|
||||||
|
let a3 = Amount (comm "$") (-1.23) Nothing
|
||||||
|
(a1 + a2) `is` Amount (comm "$") 0 Nothing
|
||||||
|
(a1 + a3) `is` Amount (comm "$") 0 Nothing
|
||||||
|
(a2 + a3) `is` Amount (comm "$") (-2.46) Nothing
|
||||||
|
(a3 + a3) `is` Amount (comm "$") (-2.46) Nothing
|
||||||
|
sum [a2,a3] `is` Amount (comm "$") (-2.46) Nothing
|
||||||
|
sum [a3,a3] `is` Amount (comm "$") (-2.46) Nothing
|
||||||
|
sum [a1,a2,a3,-a3] `is` Amount (comm "$") 0 Nothing
|
||||||
|
let dollar0 = dollar{precision=0}
|
||||||
|
(sum [Amount dollar 1.25 Nothing, Amount dollar0 (-1) Nothing, Amount dollar (-0.25) Nothing])
|
||||||
|
`is` (Amount dollar 0 Nothing)
|
||||||
|
|
||||||
|
,"mixed amount arithmetic" ~: do
|
||||||
|
let dollar0 = dollar{precision=0}
|
||||||
|
(sum $ map (Mixed . (\a -> [a]))
|
||||||
|
[Amount dollar 1.25 Nothing,
|
||||||
|
Amount dollar0 (-1) Nothing,
|
||||||
|
Amount dollar (-0.25) Nothing])
|
||||||
|
`is` Mixed [Amount dollar 0 Nothing]
|
||||||
|
|
||||||
|
|
||||||
|
]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user