aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-01-10 21:38:08 +0000
committerGregor Kleen <gkleen@yggdrasil.li>2016-01-10 21:38:08 +0000
commitf6dc3d1d5e5109c4196ad17ee69ccc7fc8b57b3b (patch)
tree9aeb04e2bf034fb83cbd5efd7ae472f9411996cd
parent6ec3c805ea2cd629a75641530de30ab39a191409 (diff)
downloadthermoprint-f6dc3d1.tar
thermoprint-f6dc3d1.tar.gz
thermoprint-f6dc3d1.tar.bz2
thermoprint-f6dc3d1.tar.xz
thermoprint-f6dc3d1.zip
Fixed issue: Ram usage explodes during tests
-rw-r--r--spec/src/Thermoprint/Printout.hs8
-rw-r--r--spec/test/Thermoprint/PrintoutSpec.hs6
-rw-r--r--spec/thermoprint-spec.cabal1
-rw-r--r--spec/thermoprint-spec.nix2
4 files changed, 9 insertions, 8 deletions
diff --git a/spec/src/Thermoprint/Printout.hs b/spec/src/Thermoprint/Printout.hs
index d9d9902..23a5ec1 100644
--- a/spec/src/Thermoprint/Printout.hs
+++ b/spec/src/Thermoprint/Printout.hs
@@ -29,7 +29,7 @@ import Data.Aeson.Types (typeMismatch)
29 29
30import Test.QuickCheck.Arbitrary (Arbitrary(..), CoArbitrary, genericShrink) 30import Test.QuickCheck.Arbitrary (Arbitrary(..), CoArbitrary, genericShrink)
31import Test.QuickCheck.Modifiers (NonNegative(..)) 31import Test.QuickCheck.Modifiers (NonNegative(..))
32import Test.QuickCheck.Gen (oneof, suchThat) 32import Test.QuickCheck.Gen (oneof, suchThat, scale)
33import Test.QuickCheck.Instances 33import Test.QuickCheck.Instances
34import Test.QuickCheck (forAll, Property) 34import Test.QuickCheck (forAll, Property)
35 35
@@ -194,12 +194,14 @@ instance Arbitrary Block where
194 shrink = genericShrink 194 shrink = genericShrink
195 arbitrary = oneof [ Line <$> arbitrary 195 arbitrary = oneof [ Line <$> arbitrary
196 , VSpace . getNonNegative <$> arbitrary 196 , VSpace . getNonNegative <$> arbitrary
197 , NewlSep <$> arbitrary 197 , NewlSep <$> scale' arbitrary
198 ] 198 ]
199 199
200instance Arbitrary Line where 200instance Arbitrary Line where
201 shrink = genericShrink 201 shrink = genericShrink
202 arbitrary = oneof [ Word . TL.filter (not . isSpace) <$> arbitrary -- 'isSpace '\n' == True' 202 arbitrary = oneof [ Word . TL.filter (not . isSpace) <$> arbitrary -- 'isSpace '\n' == True'
203 , HSpace . getNonNegative <$> arbitrary 203 , HSpace . getNonNegative <$> arbitrary
204 , SpaceSep <$> arbitrary 204 , SpaceSep <$> scale' arbitrary
205 ] 205 ]
206
207scale' = scale (round . sqrt . fromInteger . toInteger)
diff --git a/spec/test/Thermoprint/PrintoutSpec.hs b/spec/test/Thermoprint/PrintoutSpec.hs
index b92d76a..7ba3656 100644
--- a/spec/test/Thermoprint/PrintoutSpec.hs
+++ b/spec/test/Thermoprint/PrintoutSpec.hs
@@ -9,8 +9,6 @@ import Thermoprint.Printout
9import Data.Aeson (fromJSON, ToJSON(..), Result(..)) 9import Data.Aeson (fromJSON, ToJSON(..), Result(..))
10import Data.Function (on) 10import Data.Function (on)
11 11
12import Control.DeepSeq (($!!), force)
13
14-- Equality via cotext on Block 12-- Equality via cotext on Block
15instance Eq Block where 13instance Eq Block where
16 (==) = (==) `on` cotext 14 (==) = (==) `on` cotext
@@ -20,7 +18,7 @@ deriving instance Eq Chunk
20spec :: Spec 18spec :: Spec
21spec = do 19spec = do
22 prop "prop_text" prop_text 20 prop "prop_text" prop_text
23 prop "json" prop_json 21 parallel $ prop "json" prop_json
24 where 22 where
25 prop_json :: Printout -> Bool 23 prop_json :: Printout -> Bool
26 prop_json p = force $ (== Success p) . fromJSON . toJSON $!! p 24 prop_json p = (== Success p) . fromJSON . toJSON $ p
diff --git a/spec/thermoprint-spec.cabal b/spec/thermoprint-spec.cabal
index 426244e..f7227ca 100644
--- a/spec/thermoprint-spec.cabal
+++ b/spec/thermoprint-spec.cabal
@@ -45,6 +45,7 @@ Test-Suite tests
45 type: exitcode-stdio-1.0 45 type: exitcode-stdio-1.0
46 hs-source-dirs: test 46 hs-source-dirs: test
47 main-is: Spec.hs 47 main-is: Spec.hs
48 ghc-options: -threaded -with-rtsopts=-N
48 build-depends: base >=4.8.1 && <5 49 build-depends: base >=4.8.1 && <5
49 , thermoprint-spec -any 50 , thermoprint-spec -any
50 , hspec >=2.2.1 && <3 51 , hspec >=2.2.1 && <3
diff --git a/spec/thermoprint-spec.nix b/spec/thermoprint-spec.nix
index ea903ba..2da5d86 100644
--- a/spec/thermoprint-spec.nix
+++ b/spec/thermoprint-spec.nix
@@ -12,7 +12,7 @@ mkDerivation {
12 text 12 text
13 ]; 13 ];
14 testHaskellDepends = [ 14 testHaskellDepends = [
15 base hspec QuickCheck quickcheck-instances 15 aeson base hspec QuickCheck quickcheck-instances
16 ]; 16 ];
17 homepage = "http://dirty-haskell.org/tags/thermoprint.html"; 17 homepage = "http://dirty-haskell.org/tags/thermoprint.html";
18 description = "A specification of the API and the payload datatypes and associated utilities"; 18 description = "A specification of the API and the payload datatypes and associated utilities";