summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-04-01 12:27:27 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-04-01 12:27:27 +0200
commit057b7fa4851591309ed7de11d7d748779444d92b (patch)
tree3e701733215a62b0a77459e0f3a7e718ee40edc7 /src
parent417a9a92d856f7efae6b41d354aab87f575e4b9f (diff)
downloadhakyll-057b7fa4851591309ed7de11d7d748779444d92b.tar.gz
Moved Arbitrary Template instance to tests.
This way, the code for Text.Hakyll.Internal.Template is cleaner, and our library does not depend on QuickCheck anymore.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Hakyll/Internal/Template.hs36
1 files changed, 2 insertions, 34 deletions
diff --git a/src/Text/Hakyll/Internal/Template.hs b/src/Text/Hakyll/Internal/Template.hs
index 2a9b588..8b4d6c7 100644
--- a/src/Text/Hakyll/Internal/Template.hs
+++ b/src/Text/Hakyll/Internal/Template.hs
@@ -1,5 +1,5 @@
module Text.Hakyll.Internal.Template
- ( Template
+ ( Template (..)
, fromString
, readTemplate
, substitute
@@ -11,14 +11,11 @@ import qualified Data.Map as M
import Data.List (isPrefixOf)
import Data.Char (isAlphaNum)
import Data.Binary
-import Control.Monad (liftM, liftM2, replicateM)
-import Control.Applicative ((<$>))
+import Control.Monad (liftM, liftM2)
import Data.Maybe (fromMaybe)
import System.FilePath ((</>))
import Control.Monad.Reader (liftIO)
-import Test.QuickCheck
-
import Text.Hakyll.Context (Context)
import Text.Hakyll.HakyllMonad (Hakyll)
import Text.Hakyll.Internal.Cache
@@ -91,32 +88,3 @@ instance Binary Template where
2 -> liftM EscapeCharacter get
3 -> return End
_ -> error "Error reading template"
-
--- | Generate arbitrary templates from a given length.
-arbitraryTemplate :: Int -> Gen Template
-arbitraryTemplate 0 = return End
-arbitraryTemplate length' = oneof [ do chunk <- chunk'
- Chunk chunk <$> template'
- , do key <- key'
- Identifier key <$> template'
- , EscapeCharacter <$> template'
- ]
- where
- template' = arbitraryTemplate (length' - 1)
- -- Generate keys.
- key' = do l <- choose (5, 10)
- replicateM l $ choose ('a', 'z')
- -- Generate non-empty chunks.
- chunk' = do string <- arbitrary
- let sanitized = filter (/= '$') string
- return $ if null sanitized then "foo"
- else sanitized
-
--- | Make @Template@ testable.
-instance Arbitrary Template where
- arbitrary = choose (0, 20) >>= arbitraryTemplate
-
- shrink (Chunk chunk template) = [template, Chunk chunk End]
- shrink (Identifier key template) = [template, Identifier key End]
- shrink (EscapeCharacter template) = [template, EscapeCharacter End]
- shrink End = []