diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-09 23:27:00 +0000 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-09 23:27:00 +0000 |
commit | 44e4f33ad94045e3a91734b90cea83fe8c37ba65 (patch) | |
tree | 1d97d9b213d98e886ed340d59f8042eeda02d7b2 /spec/src | |
parent | b72960db52c182710db4aa9be783439a74beadca (diff) | |
download | thermoprint-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')
-rw-r--r-- | spec/src/Thermoprint/Printout.hs | 10 |
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 | |||
31 | import Test.QuickCheck (forAll, Property) | 31 | import Test.QuickCheck (forAll, Property) |
32 | 32 | ||
33 | 33 | ||
34 | import qualified Data.Text.Lazy as TL (lines, split, null, pack, filter, intercalate, map) | 34 | import qualified Data.Text.Lazy as TL (split, null, pack, filter, intercalate, map) |
35 | import Data.Char (isSpace) | 35 | import Data.Char (isSpace) |
36 | 36 | ||
37 | import Data.Monoid (Monoid(..), (<>)) | 37 | import Data.Monoid (Monoid(..), (<>)) |
@@ -99,7 +99,7 @@ instance Monoid Line where | |||
99 | 99 | ||
100 | 100 | ||
101 | text :: Text -> Either Block Line | 101 | text :: 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 | |||
148 | prop_text = forAll (TL.map normSpace <$> arbitrary) $ \x -> (cotext . either id Line . text $ x) == x | 148 | prop_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 |
156 | instance Arbitrary Chunk where | 158 | instance Arbitrary Chunk where |