From 75d9fe614dca572aa1d7cfa53553e9c103eb2dd0 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 25 Jan 2017 15:54:54 +0100 Subject: Cleanup test suite --- server/test/Thermoprint/Server/Printer/GenericSpec.hs | 7 +------ server/thermoprint-server.cabal | 2 +- server/thermoprint-server.nix | 2 +- spec/src/Thermoprint/Printout.hs | 11 ++++++++--- spec/thermoprint-spec.cabal | 2 +- spec/thermoprint-spec.nix | 2 +- tp-bbcode/src/Thermoprint/Printout/BBCode/Inverse.hs | 6 ++++++ tp-bbcode/thermoprint-bbcode.cabal | 2 +- tp-bbcode/thermoprint-bbcode.nix | 2 +- 9 files changed, 21 insertions(+), 15 deletions(-) diff --git a/server/test/Thermoprint/Server/Printer/GenericSpec.hs b/server/test/Thermoprint/Server/Printer/GenericSpec.hs index 80096b0..e535754 100644 --- a/server/test/Thermoprint/Server/Printer/GenericSpec.hs +++ b/server/test/Thermoprint/Server/Printer/GenericSpec.hs @@ -29,8 +29,6 @@ import Data.Word import Data.Sequence (Seq) import qualified Data.Sequence as Seq -import Debug.Trace - instance IsString Line where fromString = (\(Right l) -> l) . text . TL.pack @@ -40,7 +38,7 @@ spec = do zipWithM_ example [1..] examples where example n (s, ts) = let str = show s - in specify str $ traceDump (mkPrintout . Printout . fmap (Paragraph . Seq.singleton) . fmap Cooked $ s) == ts + in specify str $ (mkPrintout . Printout . fmap (Paragraph . Seq.singleton) . fmap Cooked $ s) == ts final, initial :: L.ByteString initial = esc [64] <> esc [64] @@ -52,9 +50,6 @@ esc = L.BS.pack . (27:) p :: L.ByteString -> L.ByteString p = (<> final) . (initial <>) -traceDump :: L.ByteString -> L.ByteString -traceDump bs = traceShow (map (\b -> (b, (toEnum $ fromEnum b) :: Char)) $ L.BS.unpack bs) bs - examples :: [(Seq Block, L.ByteString)] examples = [ ( [Line (JuxtaPos ["Hello", HSpace 1, "World!"])] , p "Hello World!") diff --git a/server/thermoprint-server.cabal b/server/thermoprint-server.cabal index c80351b..eae3754 100644 --- a/server/thermoprint-server.cabal +++ b/server/thermoprint-server.cabal @@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: thermoprint-server -version: 2.0.1 +version: 2.0.2 synopsis: Server for thermoprint-spec -- description: homepage: http://dirty-haskell.org/tags/thermoprint.html diff --git a/server/thermoprint-server.nix b/server/thermoprint-server.nix index 71a4211..41e645a 100644 --- a/server/thermoprint-server.nix +++ b/server/thermoprint-server.nix @@ -9,7 +9,7 @@ }: mkDerivation { pname = "thermoprint-server"; - version = "2.0.1"; + version = "2.0.2"; src = ./.; isLibrary = true; isExecutable = true; diff --git a/spec/src/Thermoprint/Printout.hs b/spec/src/Thermoprint/Printout.hs index 752ccb5..53b6a3e 100644 --- a/spec/src/Thermoprint/Printout.hs +++ b/spec/src/Thermoprint/Printout.hs @@ -37,7 +37,7 @@ import Data.Proxy (Proxy(..)) import Test.QuickCheck.Arbitrary (Arbitrary(..), CoArbitrary, genericShrink) import Test.QuickCheck.Modifiers (NonNegative(..)) -import Test.QuickCheck.Gen (oneof, scale) +import Test.QuickCheck.Gen (oneof, scale, elements) import Test.QuickCheck.Instances import Test.QuickCheck (forAll, Property) @@ -242,10 +242,14 @@ data MarkupMode = Bold | Underline | DoubleHeight | DoubleWidth - deriving (Generic, NFData, Show, Arbitrary, CoArbitrary, FromJSON, ToJSON - , Eq, Ord, Enum + deriving (Generic, NFData, Show, FromJSON, ToJSON + , Eq, Ord, Enum, Bounded ) +instance Arbitrary MarkupMode where + arbitrary = elements [minBound..maxBound] +instance CoArbitrary MarkupMode + -- | We don't test 'Raw' 'Chunk's instance Arbitrary Chunk where shrink = genericShrink @@ -262,6 +266,7 @@ instance Arbitrary Line where shrink = genericShrink arbitrary = oneof [ Word . TL.filter (not . isSpace) <$> arbitrary -- 'isSpace '\n' == True' , HSpace . getNonNegative <$> arbitrary + , Markup <$> arbitrary <*> arbitrary , JuxtaPos <$> scale' arbitrary ] diff --git a/spec/thermoprint-spec.cabal b/spec/thermoprint-spec.cabal index d4ecda6..138a06e 100644 --- a/spec/thermoprint-spec.cabal +++ b/spec/thermoprint-spec.cabal @@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: thermoprint-spec -version: 5.0.0 +version: 5.0.1 synopsis: A specification of the API and the payload datatypes and associated utilities -- description: homepage: http://dirty-haskell.org/tags/thermoprint.html diff --git a/spec/thermoprint-spec.nix b/spec/thermoprint-spec.nix index 1a1611c..a3093de 100644 --- a/spec/thermoprint-spec.nix +++ b/spec/thermoprint-spec.nix @@ -4,7 +4,7 @@ }: mkDerivation { pname = "thermoprint-spec"; - version = "5.0.0"; + version = "5.0.1"; src = ./.; libraryHaskellDepends = [ aeson base base64-bytestring bytestring Cabal cabal-test-quickcheck diff --git a/tp-bbcode/src/Thermoprint/Printout/BBCode/Inverse.hs b/tp-bbcode/src/Thermoprint/Printout/BBCode/Inverse.hs index 8e15417..e356d09 100644 --- a/tp-bbcode/src/Thermoprint/Printout/BBCode/Inverse.hs +++ b/tp-bbcode/src/Thermoprint/Printout/BBCode/Inverse.hs @@ -49,5 +49,11 @@ handleLine = flip handleLine' T.empty | " " `T.isSuffixOf` p = "[hspace=" <> T.pack (show i) <> "/]" | i <= 2 = T.pack $ genericReplicate i ' ' | otherwise = " [hspace=" <> T.pack (show $ i - 2) <> "/] " + handleLine' (Markup ms l) _ = "[markup " <> foldMap markup ms <> "]" <> handleLine' l T.empty <> "[/markup]" + where + markup Bold = "bold=true" + markup Underline = "underline=true" + markup DoubleHeight = "doubleHeight=true" + markup DoubleWidth = "doubleWidth=true" handleLine' (JuxtaPos ls) p = foldl (\p l -> p <> handleLine' l p) "" ls handleLine' (Line -> b) _ = LT.toStrict $ cotext b diff --git a/tp-bbcode/thermoprint-bbcode.cabal b/tp-bbcode/thermoprint-bbcode.cabal index b476753..89ed326 100644 --- a/tp-bbcode/thermoprint-bbcode.cabal +++ b/tp-bbcode/thermoprint-bbcode.cabal @@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: thermoprint-bbcode -version: 2.0.0 +version: 2.0.1 synopsis: Parse bbcode for use in thermoprint -- description: homepage: http://dirty-haskell.org/tags/thermoprint.html diff --git a/tp-bbcode/thermoprint-bbcode.nix b/tp-bbcode/thermoprint-bbcode.nix index 27c3f60..3c698f1 100644 --- a/tp-bbcode/thermoprint-bbcode.nix +++ b/tp-bbcode/thermoprint-bbcode.nix @@ -4,7 +4,7 @@ }: mkDerivation { pname = "thermoprint-bbcode"; - version = "2.0.0"; + version = "2.0.1"; src = ./.; libraryHaskellDepends = [ base bbcode bytestring case-insensitive containers text -- cgit v1.2.3