tests: Posting -> easytest

This commit is contained in:
Simon Michael 2018-09-04 10:26:22 -07:00
parent c5cd0dc648
commit 8d1506a4a4
2 changed files with 26 additions and 16 deletions

View File

@ -52,8 +52,7 @@ import Hledger.Utils.Test
tests_Hledger_Data = TestList tests_Hledger_Data = TestList
[ [
tests_Hledger_Data_Posting tests_Hledger_Data_Timeclock
,tests_Hledger_Data_Timeclock
,tests_Hledger_Data_Transaction ,tests_Hledger_Data_Transaction
] ]
@ -62,4 +61,5 @@ easytests_Data = tests "Data" [
,easytests_Amount ,easytests_Amount
,easytests_Journal ,easytests_Journal
,easytests_Ledger ,easytests_Ledger
,easytests_Posting
] ]

View File

@ -54,7 +54,7 @@ module Hledger.Data.Posting (
showPosting, showPosting,
-- * misc. -- * misc.
showComment, showComment,
tests_Hledger_Data_Posting easytests_Posting
) )
where where
import Data.List import Data.List
@ -69,7 +69,7 @@ import qualified Data.Text as T
import Data.Time.Calendar import Data.Time.Calendar
import Safe import Safe
import Hledger.Utils import Hledger.Utils hiding (is)
import Hledger.Data.Types import Hledger.Data.Types
import Hledger.Data.Amount import Hledger.Data.Amount
import Hledger.Data.AccountName import Hledger.Data.AccountName
@ -291,28 +291,38 @@ aliasReplace (BasicAlias old new) a
aliasReplace (RegexAlias re repl) a = T.pack $ regexReplaceCIMemo re repl $ T.unpack a -- XXX aliasReplace (RegexAlias re repl) a = T.pack $ regexReplaceCIMemo re repl $ T.unpack a -- XXX
tests_Hledger_Data_Posting = TestList [ -- tests
"accountNamePostingType" ~: do is :: (Eq a, Show a, HasCallStack) => a -> a -> Test ()
is = flip expectEq'
easytests_Posting = tests "Posting" [
tests "accountNamePostingType" [
accountNamePostingType "a" `is` RegularPosting accountNamePostingType "a" `is` RegularPosting
accountNamePostingType "(a)" `is` VirtualPosting ,accountNamePostingType "(a)" `is` VirtualPosting
accountNamePostingType "[a]" `is` BalancedVirtualPosting ,accountNamePostingType "[a]" `is` BalancedVirtualPosting
]
,"accountNameWithoutPostingType" ~: do ,tests "accountNameWithoutPostingType" [
accountNameWithoutPostingType "(a)" `is` "a" accountNameWithoutPostingType "(a)" `is` "a"
]
,"accountNameWithPostingType" ~: do ,tests "accountNameWithPostingType" [
accountNameWithPostingType VirtualPosting "[a]" `is` "(a)" accountNameWithPostingType VirtualPosting "[a]" `is` "(a)"
]
,"joinAccountNames" ~: do ,tests "joinAccountNames" [
"a" `joinAccountNames` "b:c" `is` "a:b:c" "a" `joinAccountNames` "b:c" `is` "a:b:c"
"a" `joinAccountNames` "(b:c)" `is` "(a:b:c)" ,"a" `joinAccountNames` "(b:c)" `is` "(a:b:c)"
"[a]" `joinAccountNames` "(b:c)" `is` "[a:b:c]" ,"[a]" `joinAccountNames` "(b:c)" `is` "[a:b:c]"
"" `joinAccountNames` "a" `is` "a" ,"" `joinAccountNames` "a" `is` "a"
]
,"concatAccountNames" ~: do ,tests "concatAccountNames" [
concatAccountNames [] `is` "" concatAccountNames [] `is` ""
concatAccountNames ["a","(b)","[c:d]"] `is` "(a:b:c:d)" ,concatAccountNames ["a","(b)","[c:d]"] `is` "(a:b:c:d)"
]
] ]