diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-10 00:30:18 +0000 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-10 00:30:18 +0000 |
commit | 0bb617ff93d242d20e9e63f44664f38a653898d4 (patch) | |
tree | e007e973bd670dec4169b2f070c4bccd5efb5886 | |
parent | 11a3a881157494508593bc2323fbc62b6ee04b5f (diff) | |
download | thermoprint-0bb617ff93d242d20e9e63f44664f38a653898d4.tar thermoprint-0bb617ff93d242d20e9e63f44664f38a653898d4.tar.gz thermoprint-0bb617ff93d242d20e9e63f44664f38a653898d4.tar.bz2 thermoprint-0bb617ff93d242d20e9e63f44664f38a653898d4.tar.xz thermoprint-0bb617ff93d242d20e9e63f44664f38a653898d4.zip |
reworked test harness for (partial) auto-detection
-rw-r--r-- | spec/Spec.hs | 8 | ||||
-rw-r--r-- | spec/src/Thermoprint/Printout.hs | 7 | ||||
-rw-r--r-- | spec/test/Spec.hs | 1 | ||||
-rw-r--r-- | spec/test/Thermoprint/PrintoutSpec.hs | 9 | ||||
-rw-r--r-- | spec/thermoprint-spec.cabal | 5 |
5 files changed, 18 insertions, 12 deletions
diff --git a/spec/Spec.hs b/spec/Spec.hs deleted file mode 100644 index 79f2983..0000000 --- a/spec/Spec.hs +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | import Test.Hspec | ||
2 | import Test.Hspec.QuickCheck | ||
3 | |||
4 | import qualified Thermoprint.Printout | ||
5 | |||
6 | main :: IO () | ||
7 | main = hspec $ do | ||
8 | prop "Thermoprint.Printout.prop_text" Thermoprint.Printout.prop_text | ||
diff --git a/spec/src/Thermoprint/Printout.hs b/spec/src/Thermoprint/Printout.hs index 7c6d5c0..32c403c 100644 --- a/spec/src/Thermoprint/Printout.hs +++ b/spec/src/Thermoprint/Printout.hs | |||
@@ -149,12 +149,13 @@ cotext (Line x) = cotext' x | |||
149 | cotext' (HSpace n) = TL.pack . genericReplicate n $ ' ' | 149 | cotext' (HSpace n) = TL.pack . genericReplicate n $ ' ' |
150 | cotext' (SpaceSep xs) = TL.intercalate " " . map cotext' . toList $ xs | 150 | cotext' (SpaceSep xs) = TL.intercalate " " . map cotext' . toList $ xs |
151 | 151 | ||
152 | prop_text :: Property | 152 | prop_text :: Text -> Bool |
153 | -- ^ prop> cotext . either id Line . `text` $ x = x | 153 | -- ^ prop> (`cotext` . either id Line . `text` $ x) == x |
154 | -- | 154 | -- |
155 | -- Where 'x' is restricted to those `TL.Text` which do not contain whitespace besides ' ' and '\n'. | 155 | -- Where 'x' is restricted to those `TL.Text` which do not contain whitespace besides ' ' and '\n'. |
156 | prop_text = forAll (TL.map normSpace <$> arbitrary) $ \x -> (cotext . either id Line . text $ x) == x | 156 | prop_text x = (cotext . either id Line . text $ x') == x' |
157 | where | 157 | where |
158 | x' = TL.map normSpace x | ||
158 | normSpace c | 159 | normSpace c |
159 | | isSpace c | 160 | | isSpace c |
160 | , c `elem` keep = c | 161 | , c `elem` keep = c |
diff --git a/spec/test/Spec.hs b/spec/test/Spec.hs new file mode 100644 index 0000000..a824f8c --- /dev/null +++ b/spec/test/Spec.hs | |||
@@ -0,0 +1 @@ | |||
{-# OPTIONS_GHC -F -pgmF hspec-discover #-} | |||
diff --git a/spec/test/Thermoprint/PrintoutSpec.hs b/spec/test/Thermoprint/PrintoutSpec.hs new file mode 100644 index 0000000..5a48496 --- /dev/null +++ b/spec/test/Thermoprint/PrintoutSpec.hs | |||
@@ -0,0 +1,9 @@ | |||
1 | module Thermoprint.PrintoutSpec (spec) where | ||
2 | |||
3 | import Test.Hspec | ||
4 | import Test.Hspec.QuickCheck (prop) | ||
5 | import Thermoprint.Printout | ||
6 | |||
7 | spec :: Spec | ||
8 | spec = do | ||
9 | prop "prop_text" prop_text | ||
diff --git a/spec/thermoprint-spec.cabal b/spec/thermoprint-spec.cabal index ba97420..c4599c8 100644 --- a/spec/thermoprint-spec.cabal +++ b/spec/thermoprint-spec.cabal | |||
@@ -38,7 +38,10 @@ library | |||
38 | 38 | ||
39 | Test-Suite tests | 39 | Test-Suite tests |
40 | type: exitcode-stdio-1.0 | 40 | type: exitcode-stdio-1.0 |
41 | hs-source-dirs: test | ||
41 | main-is: Spec.hs | 42 | main-is: Spec.hs |
42 | build-depends: base >=4.8.1 && <5 | 43 | build-depends: base >=4.8.1 && <5 |
43 | , thermoprint-spec -any | 44 | , thermoprint-spec -any |
44 | , hspec >=2.2.1 && <3 \ No newline at end of file | 45 | , hspec >=2.2.1 && <3 |
46 | , QuickCheck >=2.8.1 && <3 | ||
47 | , quickcheck-instances >=0.3.11 && <4 \ No newline at end of file | ||