aboutsummaryrefslogtreecommitdiff
path: root/tp-bbcode
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-01-19 11:55:22 +0000
committerGregor Kleen <gkleen@yggdrasil.li>2016-01-19 11:55:22 +0000
commita91f0984966ee64cefc44d28118dc7222c717c8c (patch)
treed6ea9ee80578a3ec00ac4f75e537863894eaf86f /tp-bbcode
parentf35ac0a9e947118688363c27bc92f450896a6c32 (diff)
downloadthermoprint-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.hs16
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
11import Thermoprint.Printout 11import Thermoprint.Printout
12 12
13import Data.Text (Text) 13import Data.Text (Text)
14import qualified Data.Text.Lazy as TL (pack)
15
16import Data.String (IsString(..))
14 17
15import Control.Monad (zipWithM_) 18import Control.Monad (zipWithM_)
16import Data.Monoid ((<>)) 19import Data.Monoid ((<>))
@@ -22,6 +25,9 @@ instance Eq Block where
22 (==) = (==) `on` cotext 25 (==) = (==) `on` cotext
23deriving instance Eq Chunk 26deriving instance Eq Chunk
24 27
28instance IsString Line where
29 fromString = (\(Right l) -> l) . text . TL.pack
30
25spec :: Spec 31spec :: Spec
26spec = do 32spec = do
27 zipWithM_ example [1..] examples 33 zipWithM_ example [1..] examples
@@ -34,9 +40,11 @@ pOut = pure . Seq.fromList . map Cooked
34 40
35examples :: [(Text, Either BBCodeError [Block])] 41examples :: [(Text, Either BBCodeError [Block])]
36examples = [ ("Hello World!" 42examples = [ ("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