aboutsummaryrefslogtreecommitdiff
path: root/spec/src/Thermoprint/Printout.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-01-09 23:27:00 +0000
committerGregor Kleen <gkleen@yggdrasil.li>2016-01-09 23:27:00 +0000
commit44e4f33ad94045e3a91734b90cea83fe8c37ba65 (patch)
tree1d97d9b213d98e886ed340d59f8042eeda02d7b2 /spec/src/Thermoprint/Printout.hs
parentb72960db52c182710db4aa9be783439a74beadca (diff)
downloadthermoprint-44e4f33ad94045e3a91734b90cea83fe8c37ba65.tar
thermoprint-44e4f33ad94045e3a91734b90cea83fe8c37ba65.tar.gz
thermoprint-44e4f33ad94045e3a91734b90cea83fe8c37ba65.tar.bz2
thermoprint-44e4f33ad94045e3a91734b90cea83fe8c37ba65.tar.xz
thermoprint-44e4f33ad94045e3a91734b90cea83fe8c37ba65.zip
Fixed another fencepost mistake due to TL.lines
Diffstat (limited to 'spec/src/Thermoprint/Printout.hs')
-rw-r--r--spec/src/Thermoprint/Printout.hs10
1 files 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
31import Test.QuickCheck (forAll, Property) 31import Test.QuickCheck (forAll, Property)
32 32
33 33
34import qualified Data.Text.Lazy as TL (lines, split, null, pack, filter, intercalate, map) 34import qualified Data.Text.Lazy as TL (split, null, pack, filter, intercalate, map)
35import Data.Char (isSpace) 35import Data.Char (isSpace)
36 36
37import Data.Monoid (Monoid(..), (<>)) 37import Data.Monoid (Monoid(..), (<>))
@@ -99,7 +99,7 @@ instance Monoid Line where
99 99
100 100
101text :: Text -> Either Block Line 101text :: Text -> Either Block Line
102-- ^ 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'. 102-- ^ 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'.
103-- 103--
104-- Since we are unwilling to duplicate the list of chars from 'isSpace' we cannot reasonably determine a width for the various whitespace 'Char's. 104-- Since we are unwilling to duplicate the list of chars from 'isSpace' we cannot reasonably determine a width for the various whitespace 'Char's.
105-- Thus they are all weighted equally as having width 1 `em`. 105-- Thus they are all weighted equally as having width 1 `em`.
@@ -111,7 +111,7 @@ text t = case splitLines t of
111 splitLines :: Text -> [Block] 111 splitLines :: Text -> [Block]
112 splitLines t = map toBlock 112 splitLines t = map toBlock
113 . groupBy ((==) `on` TL.null) 113 . groupBy ((==) `on` TL.null)
114 $ TL.lines t 114 $ TL.split (== '\n') t
115 splitWords :: Text -> [Line] 115 splitWords :: Text -> [Line]
116 splitWords t = map toLine 116 splitWords t = map toLine
117 . groupBy ((==) `on` TL.null) 117 . groupBy ((==) `on` TL.null)
@@ -148,9 +148,11 @@ prop_text :: Property
148prop_text = forAll (TL.map normSpace <$> arbitrary) $ \x -> (cotext . either id Line . text $ x) == x 148prop_text = forAll (TL.map normSpace <$> arbitrary) $ \x -> (cotext . either id Line . text $ x) == x
149 where 149 where
150 normSpace c 150 normSpace c
151 | c == '\n' = '\n' 151 | isSpace c
152 , c `elem` keep = c
152 | isSpace c = ' ' -- We have to do this because all whitespace gets interpreted as width 1 153 | isSpace c = ' ' -- We have to do this because all whitespace gets interpreted as width 1
153 | otherwise = c 154 | otherwise = c
155 keep = [' ', '\n']
154 156
155-- | We don't test 'Raw' 'Chunk's 157-- | We don't test 'Raw' 'Chunk's
156instance Arbitrary Chunk where 158instance Arbitrary Chunk where