From 80f20bdad85cfc656bcac66237128560ec6f9b1b Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 15 Mar 2009 04:02:04 +0000 Subject: [PATCH] tests and bugfix for accountNameTreeFrom --- Ledger/AccountName.hs | 9 +-------- Tests.hs | 7 +++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Ledger/AccountName.hs b/Ledger/AccountName.hs index af342f3ce..6453338c0 100644 --- a/Ledger/AccountName.hs +++ b/Ledger/AccountName.hs @@ -60,13 +60,6 @@ subAccountNamesFrom accts a = filter (`isSubAccountNameOf` a) accts -- tree with boring accounts elided. This converts a list of -- AccountName to a tree (later we will convert that to a tree of -- 'Account'.) -accountNameTreeFrom_props = - [ - accountNameTreeFrom ["a"] == Node "top" [Node "a" []], - accountNameTreeFrom ["a","b"] == Node "top" [Node "a" [], Node "b" []], - accountNameTreeFrom ["a","a:b"] == Node "top" [Node "a" [Node "a:b" []]], - accountNameTreeFrom ["a:b"] == Node "top" [Node "a" [Node "a:b" []]] - ] accountNameTreeFrom :: [AccountName] -> Tree AccountName accountNameTreeFrom accts = Node "top" (accountsFrom (topAccountNames accts)) @@ -74,7 +67,7 @@ accountNameTreeFrom accts = accountsFrom :: [AccountName] -> [Tree AccountName] accountsFrom [] = [] accountsFrom as = [Node a (accountsFrom $ subs a) | a <- as] - subs = (subAccountNamesFrom accts) + subs = subAccountNamesFrom (expandAccountNames accts) -- | Elide an account name to fit in the specified width. -- From the ledger 2.6 news: diff --git a/Tests.hs b/Tests.hs index 9c8d718dd..0c39d13a3 100644 --- a/Tests.hs +++ b/Tests.hs @@ -95,6 +95,13 @@ tests = [ "liabilities","liabilities:credit cards","liabilities:credit cards:discover"] , + "accountNameTreeFrom" ~: do + accountNameTreeFrom ["a"] `is` Node "top" [Node "a" []] + accountNameTreeFrom ["a","b"] `is` Node "top" [Node "a" [], Node "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" []]]] + , + "amount arithmetic" ~: do let a1 = dollars 1.23 let a2 = Amount (comm "$") (-1.23) Nothing