tests: Posting -> easytest
This commit is contained in:
parent
c5cd0dc648
commit
8d1506a4a4
@ -52,8 +52,7 @@ import Hledger.Utils.Test
|
||||
|
||||
tests_Hledger_Data = TestList
|
||||
[
|
||||
tests_Hledger_Data_Posting
|
||||
,tests_Hledger_Data_Timeclock
|
||||
tests_Hledger_Data_Timeclock
|
||||
,tests_Hledger_Data_Transaction
|
||||
]
|
||||
|
||||
@ -62,4 +61,5 @@ easytests_Data = tests "Data" [
|
||||
,easytests_Amount
|
||||
,easytests_Journal
|
||||
,easytests_Ledger
|
||||
,easytests_Posting
|
||||
]
|
||||
|
||||
@ -54,7 +54,7 @@ module Hledger.Data.Posting (
|
||||
showPosting,
|
||||
-- * misc.
|
||||
showComment,
|
||||
tests_Hledger_Data_Posting
|
||||
easytests_Posting
|
||||
)
|
||||
where
|
||||
import Data.List
|
||||
@ -69,7 +69,7 @@ import qualified Data.Text as T
|
||||
import Data.Time.Calendar
|
||||
import Safe
|
||||
|
||||
import Hledger.Utils
|
||||
import Hledger.Utils hiding (is)
|
||||
import Hledger.Data.Types
|
||||
import Hledger.Data.Amount
|
||||
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
|
||||
|
||||
|
||||
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` VirtualPosting
|
||||
accountNamePostingType "[a]" `is` BalancedVirtualPosting
|
||||
,accountNamePostingType "(a)" `is` VirtualPosting
|
||||
,accountNamePostingType "[a]" `is` BalancedVirtualPosting
|
||||
]
|
||||
|
||||
,"accountNameWithoutPostingType" ~: do
|
||||
,tests "accountNameWithoutPostingType" [
|
||||
accountNameWithoutPostingType "(a)" `is` "a"
|
||||
]
|
||||
|
||||
,"accountNameWithPostingType" ~: do
|
||||
,tests "accountNameWithPostingType" [
|
||||
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]"
|
||||
"" `joinAccountNames` "a" `is` "a"
|
||||
,"a" `joinAccountNames` "(b:c)" `is` "(a:b:c)"
|
||||
,"[a]" `joinAccountNames` "(b:c)" `is` "[a:b:c]"
|
||||
,"" `joinAccountNames` "a" `is` "a"
|
||||
]
|
||||
|
||||
,"concatAccountNames" ~: do
|
||||
,tests "concatAccountNames" [
|
||||
concatAccountNames [] `is` ""
|
||||
concatAccountNames ["a","(b)","[c:d]"] `is` "(a:b:c:d)"
|
||||
,concatAccountNames ["a","(b)","[c:d]"] `is` "(a:b:c:d)"
|
||||
]
|
||||
|
||||
]
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user