lib: update some journal parser tests (#812)

This commit is contained in:
Simon Michael 2018-08-04 15:55:00 +01:00
parent c67404c73d
commit cfaa0501e6

View File

@ -578,6 +578,7 @@ test_transactionp = TestCase $ do
ttags=[("ttag1","val1")], ttags=[("ttag1","val1")],
tpostings=[ tpostings=[
nullposting{ nullposting{
pdate=Just $ parsedate "2012/05/14",
pstatus=Cleared, pstatus=Cleared,
paccount="a", paccount="a",
pamount=Mixed [usd 1], pamount=Mixed [usd 1],
@ -601,12 +602,6 @@ test_transactionp = TestCase $ do
,"" ,""
] ]
assertBool "transactionp should not parse just a date" $
isLeft . runIdentity $ parseWithState mempty transactionp "2009/1/1\n"
assertBool "transactionp should not parse just a date and description" $
isLeft . runIdentity $ parseWithState mempty transactionp "2009/1/1 a\n"
let p = runIdentity $ parseWithState mempty transactionp "2009/1/1 a ;comment\n b 1\n" let p = runIdentity $ parseWithState mempty transactionp "2009/1/1 a ;comment\n b 1\n"
assertEqual "transactionp should not parse a following comment as part of the description" assertEqual "transactionp should not parse a following comment as part of the description"
(Right "a") (tdescription <$> p) (Right "a") (tdescription <$> p)
@ -690,17 +685,16 @@ test_postingp = TestCase $ do
" a 1 ; [2012/11/28]\n" `gives` " a 1 ; [2012/11/28]\n" `gives`
("a" `post` num 1){pcomment="[2012/11/28]\n" ("a" `post` num 1){pcomment="[2012/11/28]\n"
,ptags=[("date","2012/11/28")]
,pdate=parsedateM "2012/11/28"} ,pdate=parsedateM "2012/11/28"}
" a 1 ; a:a, [=2012/11/28]\n" `gives` " a 1 ; a:a, [=2012/11/28]\n" `gives`
("a" `post` num 1){pcomment="a:a, [=2012/11/28]\n" ("a" `post` num 1){pcomment="a:a, [=2012/11/28]\n"
,ptags=[("a","a"), ("date2","2012/11/28")] ,ptags=[("a","a")]
,pdate=Nothing} ,pdate=Nothing}
" a 1 ; a:a\n ; [2012/11/28=2012/11/29],b:b\n" `gives` " a 1 ; a:a\n ; [2012/11/28=2012/11/29],b:b\n" `gives`
("a" `post` num 1){pcomment="a:a\n[2012/11/28=2012/11/29],b:b\n" ("a" `post` num 1){pcomment="a:a\n[2012/11/28=2012/11/29],b:b\n"
,ptags=[("a","a"), ("date","2012/11/28"), ("date2","2012/11/29"), ("b","b")] ,ptags=[("a","a"), ("[2012/11/28=2012/11/29],b","b")] -- XXX ugly tag name parsed
,pdate=parsedateM "2012/11/28"} ,pdate=parsedateM "2012/11/28"}
assertBool "postingp parses a quoted commodity with numbers" assertBool "postingp parses a quoted commodity with numbers"