diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-19 11:55:22 +0000 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-19 11:55:22 +0000 |
| commit | a91f0984966ee64cefc44d28118dc7222c717c8c (patch) | |
| tree | d6ea9ee80578a3ec00ac4f75e537863894eaf86f /tp-bbcode | |
| parent | f35ac0a9e947118688363c27bc92f450896a6c32 (diff) | |
| download | thermoprint-a91f0984966ee64cefc44d28118dc7222c717c8c.tar thermoprint-a91f0984966ee64cefc44d28118dc7222c717c8c.tar.gz thermoprint-a91f0984966ee64cefc44d28118dc7222c717c8c.tar.bz2 thermoprint-a91f0984966ee64cefc44d28118dc7222c717c8c.tar.xz thermoprint-a91f0984966ee64cefc44d28118dc7222c717c8c.zip | |
Better tests for Printout.BBCode
Diffstat (limited to 'tp-bbcode')
| -rw-r--r-- | tp-bbcode/test/Thermoprint/Printout/BBCodeSpec.hs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tp-bbcode/test/Thermoprint/Printout/BBCodeSpec.hs b/tp-bbcode/test/Thermoprint/Printout/BBCodeSpec.hs index f3f1840..c10018f 100644 --- a/tp-bbcode/test/Thermoprint/Printout/BBCodeSpec.hs +++ b/tp-bbcode/test/Thermoprint/Printout/BBCodeSpec.hs | |||
| @@ -11,6 +11,9 @@ import Thermoprint.Printout.BBCode | |||
| 11 | import Thermoprint.Printout | 11 | import Thermoprint.Printout |
| 12 | 12 | ||
| 13 | import Data.Text (Text) | 13 | import Data.Text (Text) |
| 14 | import qualified Data.Text.Lazy as TL (pack) | ||
| 15 | |||
| 16 | import Data.String (IsString(..)) | ||
| 14 | 17 | ||
| 15 | import Control.Monad (zipWithM_) | 18 | import Control.Monad (zipWithM_) |
| 16 | import Data.Monoid ((<>)) | 19 | import Data.Monoid ((<>)) |
| @@ -22,6 +25,9 @@ instance Eq Block where | |||
| 22 | (==) = (==) `on` cotext | 25 | (==) = (==) `on` cotext |
| 23 | deriving instance Eq Chunk | 26 | deriving instance Eq Chunk |
| 24 | 27 | ||
| 28 | instance IsString Line where | ||
| 29 | fromString = (\(Right l) -> l) . text . TL.pack | ||
| 30 | |||
| 25 | spec :: Spec | 31 | spec :: Spec |
| 26 | spec = do | 32 | spec = do |
| 27 | zipWithM_ example [1..] examples | 33 | zipWithM_ example [1..] examples |
| @@ -34,9 +40,11 @@ pOut = pure . Seq.fromList . map Cooked | |||
| 34 | 40 | ||
| 35 | examples :: [(Text, Either BBCodeError [Block])] | 41 | examples :: [(Text, Either BBCodeError [Block])] |
| 36 | examples = [ ("Hello World!" | 42 | examples = [ ("Hello World!" |
| 37 | , Right [Line (JuxtaPos [word "Hello", HSpace 1, word "World!"])]) | 43 | , Right [Line (JuxtaPos ["Hello", HSpace 1, "World!"])]) |
| 38 | , ("Hello [hspace width=2/] World!" | 44 | , ("Hello [hspace width=2/] World!" |
| 39 | , Right [Line (JuxtaPos [word "Hello", HSpace 4, word "World!"])]) | 45 | , Right [Line (JuxtaPos ["Hello", HSpace 4, "World!"])]) |
| 46 | , ("Par1\n\nPar2\n\nPar3 Word2" | ||
| 47 | , Right [Line ("Par1"), Line ("Par2"), Line (JuxtaPos ["Par3", HSpace 1, "Word2"])]) | ||
| 48 | , ("Par1 [hspace=3/]\n\n[vspace=2/]Par2\n\nPar3 Word2" | ||
| 49 | , Right [Line (JuxtaPos ["Par1", HSpace 4]), NewlSep [VSpace 1, Line ("Par2")], Line (JuxtaPos ["Par3", HSpace 1, "Word2"])]) | ||
| 40 | ] | 50 | ] |
| 41 | where | ||
| 42 | word = (\(Right l) -> l) . text | ||
