diff --git a/Makefile b/Makefile index a85238f01..226e4d3f6 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # hledger project makefile # optional features described in MANUAL, comment out if you don't have the libs -OPTFLAGS=-DCHART -DVTY -DWEB +OPTFLAGS= #-DCHART -DVTY -DWEB #OPTFLAGS=-DCHART -DVTY -DWEBHAPPSTACK # command to run during "make ci" diff --git a/Tests.hs b/Tests.hs index 616f62f15..92b2b17a8 100644 --- a/Tests.hs +++ b/Tests.hs @@ -437,10 +437,10 @@ tests = TestList [ assertBool "ledgerFile parsing an empty file should give an empty ledger" $ null $ jtxns r ,"ledgerHistoricalPrice" ~: - assertParse (parseWithCtx emptyCtx ledgerHistoricalPrice price1_str) price1 + assertParseEqual (parseWithCtx emptyCtx ledgerHistoricalPrice price1_str) price1 ,"ledgerTransaction" ~: do - assertParse (parseWithCtx emptyCtx ledgerTransaction entry1_str) entry1 + assertParseEqual (parseWithCtx emptyCtx ledgerTransaction entry1_str) entry1 assertBool "ledgerTransaction should not parse just a date" $ isLeft $ parseWithCtx emptyCtx ledgerTransaction "2009/1/1\n" assertBool "ledgerTransaction should require some postings" @@ -456,7 +456,7 @@ tests = TestList [ assertBool "ledgeraccountname rejects an empty trailing component" (isLeft $ parsewith ledgeraccountname "a:b:") ,"ledgerposting" ~: - assertParse (parseWithCtx emptyCtx ledgerposting rawposting1_str) rawposting1 + assertParseEqual (parseWithCtx emptyCtx ledgerposting rawposting1_str) rawposting1 ,"normaliseMixedAmount" ~: do normaliseMixedAmount (Mixed []) ~?= Mixed [nullamt] @@ -842,8 +842,8 @@ tests = TestList [ -- ] ,"postingamount" ~: do - assertParse (parseWithCtx emptyCtx postingamount " $47.18") (Mixed [dollars 47.18]) - assertParse (parseWithCtx emptyCtx postingamount " $1.") + assertParseEqual (parseWithCtx emptyCtx postingamount " $47.18") (Mixed [dollars 47.18]) + assertParseEqual (parseWithCtx emptyCtx postingamount " $1.") (Mixed [Amount Commodity {symbol="$",side=L,spaced=False,comma=False,precision=0} 1 Nothing]) ] diff --git a/hledger-lib/Ledger/Utils.hs b/hledger-lib/Ledger/Utils.hs index d3a342cf0..5d79d0eba 100644 --- a/hledger-lib/Ledger/Utils.hs +++ b/hledger-lib/Ledger/Utils.hs @@ -290,9 +290,13 @@ tfilter _ t = t is :: (Eq a, Show a) => a -> a -> Assertion a `is` e = assertEqual "" e a --- | Assert a parse result is some expected value, or print a parse error. -assertParse :: (Show a, Eq a) => (Either ParseError a) -> a -> Assertion -assertParse parse expected = either (assertFailure.show) (`is` expected) parse +-- | Assert a parse result is successful, printing the parse error on failure. +assertParse :: (Either ParseError a) -> Assertion +assertParse parse = either (assertFailure.show) (const (return ())) parse + +-- | Assert a parse result is some expected value, printing the parse error on failure. +assertParseEqual :: (Show a, Eq a) => (Either ParseError a) -> a -> Assertion +assertParseEqual parse expected = either (assertFailure.show) (`is` expected) parse printParseError :: (Show a) => a -> IO () printParseError e = do putStr "parse error at "; print e