From bbecb28caea63b3510f64af4b5f530019e5a6c53 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 3 Sep 2018 15:54:29 -0700 Subject: [PATCH] tests: Utils -> easytest --- hledger-lib/Hledger.hs | 2 +- hledger-lib/Hledger/Utils.hs | 7 ++++--- hledger-lib/Hledger/Utils/Text.hs | 23 +++++++++++++---------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/hledger-lib/Hledger.hs b/hledger-lib/Hledger.hs index 658dfc098..95bd487e9 100644 --- a/hledger-lib/Hledger.hs +++ b/hledger-lib/Hledger.hs @@ -18,10 +18,10 @@ tests_Hledger = TestList tests_Hledger_Data ,tests_Hledger_Query ,tests_Hledger_Reports - ,tests_Hledger_Utils ] easytests_Hledger = tests "Hledger" [ easytests_Data ,easytests_Read + ,easytests_Utils ] diff --git a/hledger-lib/Hledger/Utils.hs b/hledger-lib/Hledger/Utils.hs index dd7e33288..df43a9651 100644 --- a/hledger-lib/Hledger/Utils.hs +++ b/hledger-lib/Hledger/Utils.hs @@ -4,6 +4,7 @@ Standard imports and utilities which are useful everywhere, or needed low in the module hierarchy. This is the bottom of hledger's module graph. -} +{-# LANGUAGE OverloadedStrings #-} module Hledger.Utils (---- provide these frequently used modules - or not, for clearer api: -- module Control.Monad, @@ -216,6 +217,6 @@ sequence' ms = do mapM' :: Monad f => (a -> f b) -> [a] -> f [b] mapM' f = sequence' . map f -tests_Hledger_Utils = TestList [ - tests_Hledger_Utils_Text - ] +easytests_Utils = tests "Utils" [ + easytests_Text + ] diff --git a/hledger-lib/Hledger/Utils/Text.hs b/hledger-lib/Hledger/Utils/Text.hs index 53508d1df..4d7056acb 100644 --- a/hledger-lib/Hledger/Utils/Text.hs +++ b/hledger-lib/Hledger/Utils/Text.hs @@ -54,7 +54,8 @@ module Hledger.Utils.Text -- fitStringMulti, textPadLeftWide, textPadRightWide, - tests_Hledger_Utils_Text + -- -- * tests + easytests_Text ) where @@ -419,12 +420,14 @@ textWidth s = maximum $ map (T.foldr (\a b -> charWidth a + b) 0) $ T.lines s -- | otherwise -> 1 -tests_Hledger_Utils_Text = TestList [ - quoteIfSpaced "a'a" ~?= "a'a" - , quoteIfSpaced "a\"a" ~?= "a\"a" - , quoteIfSpaced "a a" ~?= "\"a a\"" - , quoteIfSpaced "mimi's cafe" ~?= "\"mimi's cafe\"" - , quoteIfSpaced "\"alex\" cafe" ~?= "\"\\\"alex\\\" cafe\"" - , quoteIfSpaced "le'shan's cafe" ~?= "\"le'shan's cafe\"" - , quoteIfSpaced "\"be'any's\" cafe" ~?= "\"\\\"be'any's\\\" cafe\"" - ] \ No newline at end of file +easytests_Text = tests "Text" [ + tests "quoteIfSpaced" [ + expectEq' "a'a" (quoteIfSpaced "a'a") + ,expectEq' "a\"a" (quoteIfSpaced "a\"a") + ,expectEq' "\"a a\"" (quoteIfSpaced "a a") + ,expectEq' "\"mimi's cafe\"" (quoteIfSpaced "mimi's cafe") + ,expectEq' "\"\\\"alex\\\" cafe\"" (quoteIfSpaced "\"alex\" cafe") + ,expectEq' "\"le'shan's cafe\"" (quoteIfSpaced "le'shan's cafe") + ,expectEq' "\"\\\"be'any's\\\" cafe\"" (quoteIfSpaced "\"be'any's\" cafe") + ] + ]