begin reviving journalreader unit tests
This commit is contained in:
parent
d1769d9d62
commit
ba6269981b
@ -239,7 +239,7 @@ samplejournal = readJournal' $ unlines
|
|||||||
tests_Hledger_Read = TestList $
|
tests_Hledger_Read = TestList $
|
||||||
tests_readJournal'
|
tests_readJournal'
|
||||||
++ [
|
++ [
|
||||||
-- tests_Hledger_Read_JournalReader,
|
tests_Hledger_Read_JournalReader,
|
||||||
tests_Hledger_Read_TimelogReader,
|
tests_Hledger_Read_TimelogReader,
|
||||||
tests_Hledger_Read_CsvReader,
|
tests_Hledger_Read_CsvReader,
|
||||||
|
|
||||||
|
|||||||
@ -40,8 +40,9 @@ module Hledger.Read.JournalReader (
|
|||||||
emptyorcommentlinep,
|
emptyorcommentlinep,
|
||||||
followingcommentp,
|
followingcommentp,
|
||||||
accountaliasp
|
accountaliasp
|
||||||
#ifdef TESTS
|
|
||||||
-- * Tests
|
-- * Tests
|
||||||
|
,tests_Hledger_Read_JournalReader
|
||||||
|
#ifdef TESTS
|
||||||
-- disabled by default, HTF not available on windows
|
-- disabled by default, HTF not available on windows
|
||||||
,htf_thisModulesTests
|
,htf_thisModulesTests
|
||||||
,htf_Hledger_Read_JournalReader_importedTests
|
,htf_Hledger_Read_JournalReader_importedTests
|
||||||
@ -60,6 +61,7 @@ import Data.Maybe
|
|||||||
import Data.Time.Calendar
|
import Data.Time.Calendar
|
||||||
import Data.Time.LocalTime
|
import Data.Time.LocalTime
|
||||||
import Safe (headDef, lastDef)
|
import Safe (headDef, lastDef)
|
||||||
|
import Test.HUnit
|
||||||
#ifdef TESTS
|
#ifdef TESTS
|
||||||
import Test.Framework
|
import Test.Framework
|
||||||
import Text.Parsec.Error
|
import Text.Parsec.Error
|
||||||
@ -426,6 +428,13 @@ test_transaction = do
|
|||||||
],
|
],
|
||||||
tpreceding_comment_lines=""
|
tpreceding_comment_lines=""
|
||||||
}
|
}
|
||||||
|
unlines [
|
||||||
|
"2015/1/1",
|
||||||
|
]
|
||||||
|
`gives`
|
||||||
|
nulltransaction{
|
||||||
|
tdate=parsedate "2015/01/01",
|
||||||
|
}
|
||||||
|
|
||||||
assertRight $ parseWithCtx nullctx transaction $ unlines
|
assertRight $ parseWithCtx nullctx transaction $ unlines
|
||||||
["2007/01/28 coopportunity"
|
["2007/01/28 coopportunity"
|
||||||
@ -895,29 +904,27 @@ numberp = do
|
|||||||
where
|
where
|
||||||
numeric = isNumber . headDef '_'
|
numeric = isNumber . headDef '_'
|
||||||
|
|
||||||
#ifdef TESTS
|
-- test_numberp = do
|
||||||
test_numberp = do
|
-- let s `is` n = assertParseEqual (parseWithCtx nullctx numberp s) n
|
||||||
let s `is` n = assertParseEqual' (parseWithCtx nullctx numberp s) n
|
-- assertFails = assertBool . isLeft . parseWithCtx nullctx numberp
|
||||||
assertFails = assertBool . isLeft . parseWithCtx nullctx numberp
|
-- assertFails ""
|
||||||
assertFails ""
|
-- "0" `is` (0, 0, '.', ',', [])
|
||||||
"0" `is` (0, 0, '.', ',', [])
|
-- "1" `is` (1, 0, '.', ',', [])
|
||||||
"1" `is` (1, 0, '.', ',', [])
|
-- "1.1" `is` (1.1, 1, '.', ',', [])
|
||||||
"1.1" `is` (1.1, 1, '.', ',', [])
|
-- "1,000.1" `is` (1000.1, 1, '.', ',', [3])
|
||||||
"1,000.1" `is` (1000.1, 1, '.', ',', [3])
|
-- "1.00.000,1" `is` (100000.1, 1, ',', '.', [3,2])
|
||||||
"1.00.000,1" `is` (100000.1, 1, ',', '.', [3,2])
|
-- "1,000,000" `is` (1000000, 0, '.', ',', [3,3])
|
||||||
"1,000,000" `is` (1000000, 0, '.', ',', [3,3])
|
-- "1." `is` (1, 0, '.', ',', [])
|
||||||
"1." `is` (1, 0, '.', ',', [])
|
-- "1," `is` (1, 0, ',', '.', [])
|
||||||
"1," `is` (1, 0, ',', '.', [])
|
-- ".1" `is` (0.1, 1, '.', ',', [])
|
||||||
".1" `is` (0.1, 1, '.', ',', [])
|
-- ",1" `is` (0.1, 1, ',', '.', [])
|
||||||
",1" `is` (0.1, 1, ',', '.', [])
|
-- assertFails "1,000.000,1"
|
||||||
assertFails "1,000.000,1"
|
-- assertFails "1.000,000.1"
|
||||||
assertFails "1.000,000.1"
|
-- assertFails "1,000.000.1"
|
||||||
assertFails "1,000.000.1"
|
-- assertFails "1,,1"
|
||||||
assertFails "1,,1"
|
-- assertFails "1..1"
|
||||||
assertFails "1..1"
|
-- assertFails ".1,"
|
||||||
assertFails ".1,"
|
-- assertFails ",1."
|
||||||
assertFails ",1."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
-- comment parsers
|
-- comment parsers
|
||||||
|
|
||||||
@ -1019,9 +1026,13 @@ dateValueFromTags ts = maybe Nothing (Just . snd) $ find ((=="date") . fst) ts
|
|||||||
date2ValueFromTags ts = maybe Nothing (Just . snd) $ find ((=="date2") . fst) ts
|
date2ValueFromTags ts = maybe Nothing (Just . snd) $ find ((=="date2") . fst) ts
|
||||||
|
|
||||||
|
|
||||||
|
tests_Hledger_Read_JournalReader = TestList $ concat [
|
||||||
|
-- test_numberp
|
||||||
|
]
|
||||||
|
|
||||||
{- old hunit tests
|
{- old hunit tests
|
||||||
|
|
||||||
test_Hledger_Read_JournalReader = TestList $ concat [
|
tests_Hledger_Read_JournalReader = TestList $ concat [
|
||||||
test_numberp,
|
test_numberp,
|
||||||
test_amountp,
|
test_amountp,
|
||||||
test_spaceandamountormissing,
|
test_spaceandamountormissing,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user