From 44e4f33ad94045e3a91734b90cea83fe8c37ba65 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 9 Jan 2016 23:27:00 +0000 Subject: Fixed another fencepost mistake due to TL.lines --- spec/src/Thermoprint/Printout.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spec/src/Thermoprint/Printout.hs b/spec/src/Thermoprint/Printout.hs index 442c2a3..23e950a 100644 --- a/spec/src/Thermoprint/Printout.hs +++ b/spec/src/Thermoprint/Printout.hs @@ -31,7 +31,7 @@ import Test.QuickCheck.Instances import Test.QuickCheck (forAll, Property) -import qualified Data.Text.Lazy as TL (lines, split, null, pack, filter, intercalate, map) +import qualified Data.Text.Lazy as TL (split, null, pack, filter, intercalate, map) import Data.Char (isSpace) import Data.Monoid (Monoid(..), (<>)) @@ -99,7 +99,7 @@ instance Monoid Line where text :: Text -> Either Block Line --- ^ Smart constructor for 'Line'/'Block' which maps word and line boundaries (as determined by 'isSpace' and 'TL.lines' respectively) to the structure of 'Block' and 'Line'. +-- ^ Smart constructor for 'Line'/'Block' which maps word and line boundaries (as determined by 'isSpace' and '(== '\n')' respectively) to the structure of 'Block' and 'Line'. -- -- Since we are unwilling to duplicate the list of chars from 'isSpace' we cannot reasonably determine a width for the various whitespace 'Char's. -- Thus they are all weighted equally as having width 1 `em`. @@ -111,7 +111,7 @@ text t = case splitLines t of splitLines :: Text -> [Block] splitLines t = map toBlock . groupBy ((==) `on` TL.null) - $ TL.lines t + $ TL.split (== '\n') t splitWords :: Text -> [Line] splitWords t = map toLine . groupBy ((==) `on` TL.null) @@ -148,9 +148,11 @@ prop_text :: Property prop_text = forAll (TL.map normSpace <$> arbitrary) $ \x -> (cotext . either id Line . text $ x) == x where normSpace c - | c == '\n' = '\n' + | isSpace c + , c `elem` keep = c | isSpace c = ' ' -- We have to do this because all whitespace gets interpreted as width 1 | otherwise = c + keep = [' ', '\n'] -- | We don't test 'Raw' 'Chunk's instance Arbitrary Chunk where -- cgit v1.2.3