tests and bugfix for accountNameTreeFrom
This commit is contained in:
		
							parent
							
								
									2dac5754c7
								
							
						
					
					
						commit
						80f20bdad8
					
				| @ -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: | ||||
|  | ||||
							
								
								
									
										7
									
								
								Tests.hs
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								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 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user