diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-10 21:38:08 +0000 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-10 21:38:08 +0000 |
commit | f6dc3d1d5e5109c4196ad17ee69ccc7fc8b57b3b (patch) | |
tree | 9aeb04e2bf034fb83cbd5efd7ae472f9411996cd /spec | |
parent | 6ec3c805ea2cd629a75641530de30ab39a191409 (diff) | |
download | thermoprint-f6dc3d1d5e5109c4196ad17ee69ccc7fc8b57b3b.tar thermoprint-f6dc3d1d5e5109c4196ad17ee69ccc7fc8b57b3b.tar.gz thermoprint-f6dc3d1d5e5109c4196ad17ee69ccc7fc8b57b3b.tar.bz2 thermoprint-f6dc3d1d5e5109c4196ad17ee69ccc7fc8b57b3b.tar.xz thermoprint-f6dc3d1d5e5109c4196ad17ee69ccc7fc8b57b3b.zip |
Fixed issue: Ram usage explodes during tests
Diffstat (limited to 'spec')
-rw-r--r-- | spec/src/Thermoprint/Printout.hs | 8 | ||||
-rw-r--r-- | spec/test/Thermoprint/PrintoutSpec.hs | 6 | ||||
-rw-r--r-- | spec/thermoprint-spec.cabal | 1 | ||||
-rw-r--r-- | spec/thermoprint-spec.nix | 2 |
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 | ||
30 | import Test.QuickCheck.Arbitrary (Arbitrary(..), CoArbitrary, genericShrink) | 30 | import Test.QuickCheck.Arbitrary (Arbitrary(..), CoArbitrary, genericShrink) |
31 | import Test.QuickCheck.Modifiers (NonNegative(..)) | 31 | import Test.QuickCheck.Modifiers (NonNegative(..)) |
32 | import Test.QuickCheck.Gen (oneof, suchThat) | 32 | import Test.QuickCheck.Gen (oneof, suchThat, scale) |
33 | import Test.QuickCheck.Instances | 33 | import Test.QuickCheck.Instances |
34 | import Test.QuickCheck (forAll, Property) | 34 | import 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 | ||
200 | instance Arbitrary Line where | 200 | instance 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 | |||
207 | scale' = 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 | |||
9 | import Data.Aeson (fromJSON, ToJSON(..), Result(..)) | 9 | import Data.Aeson (fromJSON, ToJSON(..), Result(..)) |
10 | import Data.Function (on) | 10 | import Data.Function (on) |
11 | 11 | ||
12 | import Control.DeepSeq (($!!), force) | ||
13 | |||
14 | -- Equality via cotext on Block | 12 | -- Equality via cotext on Block |
15 | instance Eq Block where | 13 | instance Eq Block where |
16 | (==) = (==) `on` cotext | 14 | (==) = (==) `on` cotext |
@@ -20,7 +18,7 @@ deriving instance Eq Chunk | |||
20 | spec :: Spec | 18 | spec :: Spec |
21 | spec = do | 19 | spec = 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"; |