This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "heist".
The branch, master has been updated
via 977cff1d55aa4a9eb99755b140013c283181557c (commit)
via 65071519df44b8a1c904fdfdcf12d6c7b796375a (commit)
via 6abd0182367d0539880d531e391685c5f8f5f989 (commit)
via b4ba099792f673e41a577a75791cfe630e0a0d31 (commit)
via e7b6252be2941d1e4090097d5d34d63c638519c0 (commit)
from 7034ab926efe575da6752daf76f7b74d9c942cdb (commit)
Summary of changes:
src/Text/Templating/Heist/Types.hs | 2 +-
test/suite/Text/Templating/Heist/Tests.hs | 61 ++++++++++++++++++++++++----
2 files changed, 53 insertions(+), 10 deletions(-)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 977cff1d55aa4a9eb99755b140013c283181557c
Merge: 7034ab9 6507151
Author: Mighty Byte <[email protected]>
Date: Tue Oct 26 12:29:41 2010 -0400
Merge branch 'testfix' of http://github.com/wlangstroth/heist
commit 65071519df44b8a1c904fdfdcf12d6c7b796375a
Author: stwill <[email protected]>
Date: Sun Oct 24 18:12:45 2010 -0400
added a markdown text test (coverage for pandocBS), spelling
diff --git a/src/Text/Templating/Heist/Types.hs
b/src/Text/Templating/Heist/Types.hs
index 2737980..941dcbb 100644
--- a/src/Text/Templating/Heist/Types.hs
+++ b/src/Text/Templating/Heist/Types.hs
@@ -9,7 +9,7 @@
{-|
This module contains the core Heist data types. TemplateMonad intentionally
-does not expose any of it's functionality via MonadState or MonadReader
+does not expose any of its functionality via MonadState or MonadReader
functions. We define passthrough instances for the most common types of
monads. These instances allow the user to use TemplateMonad in a monad stack
without needing calls to `lift`.
diff --git a/test/suite/Text/Templating/Heist/Tests.hs
b/test/suite/Text/Templating/Heist/Tests.hs
index f52dd22..8908643 100644
--- a/test/suite/Text/Templating/Heist/Tests.hs
+++ b/test/suite/Text/Templating/Heist/Tests.hs
@@ -31,6 +31,7 @@ import Text.Templating.Heist.Internal
import Text.Templating.Heist.Types
import Text.Templating.Heist.Splices.Apply
import Text.Templating.Heist.Splices.Ignore
+import Text.Templating.Heist.Splices.Markdown
import Text.XML.Expat.Cursor
import Text.XML.Expat.Format
import qualified Text.XML.Expat.Tree as X
@@ -51,6 +52,7 @@ tests = [ testProperty "heist/simpleBind"
simpleBindTest
, testCase "heist/attributeSubstitution" attrSubstTest
, testCase "heist/bindAttribute" bindAttrTest
, testCase "heist/markdown" markdownTest
+ , testCase "heist/markdownText" markdownTextTest
, testCase "heist/apply" applyTest
, testCase "heist/ignore" ignoreTest
]
@@ -203,12 +205,18 @@ bindAttrTest = do
------------------------------------------------------------------------------
+htmlExpected :: ByteString
+htmlExpected = "<div class=\"markdown\"><p>This <em>is</em> a test.</p></div>"
+
+
+------------------------------------------------------------------------------
+-- | Markdown test on a file
markdownTest :: H.Assertion
markdownTest = do
ets <- loadT "templates"
let ts = either (error "Error loading templates") id ets
- check ts "<div class=\"markdown\"><p>This <em>is</em> a test.</p></div>"
+ check ts htmlExpected
where
check ts str = do
@@ -218,11 +226,22 @@ markdownTest = do
------------------------------------------------------------------------------
+-- | Markdown test on supplied text
+markdownTextTest :: H.Assertion
+markdownTextTest = do
+ result <- evalTemplateMonad markdownSplice
+ (X.Text "This *is* a test.") emptyTemplateState
+ H.assertEqual "Markdown text" htmlExpected
+ (B.filter (/= '\n') $ formatList' result)
+
+
+------------------------------------------------------------------------------
applyTest :: H.Assertion
applyTest = do
let es = emptyTemplateState :: TemplateState IO
res <- evalTemplateMonad applyImpl
(X.Element "apply" [("template", "nonexistant")] []) es
+
H.assertEqual "apply nothing" [] res
commit 6abd0182367d0539880d531e391685c5f8f5f989
Author: stwill <[email protected]>
Date: Fri Oct 22 16:29:29 2010 -0400
added hasTemplate test
diff --git a/test/suite/Text/Templating/Heist/Tests.hs
b/test/suite/Text/Templating/Heist/Tests.hs
index 86ce320..f52dd22 100644
--- a/test/suite/Text/Templating/Heist/Tests.hs
+++ b/test/suite/Text/Templating/Heist/Tests.hs
@@ -42,6 +42,7 @@ tests = [ testProperty "heist/simpleBind"
simpleBindTest
, testProperty "heist/simpleApply" simpleApplyTest
, testCase "heist/stateMonoid" monoidTest
, testCase "heist/templateAdd" addTest
+ , testCase "heist/hasTemplate" hasTemplateTest
, testCase "heist/getDoc" getDocTest
, testCase "heist/load" loadTest
, testCase "heist/fsLoad" fsLoadTest
@@ -102,6 +103,15 @@ addTest = do
------------------------------------------------------------------------------
+hasTemplateTest :: H.Assertion
+hasTemplateTest = do
+ ets <- loadT "templates"
+ let tm = either (error "Error loading templates") _templateMap ets
+ let ts = setTemplates tm emptyTemplateState :: TemplateState IO
+ H.assertBool "hasTemplate ts" (hasTemplate "index" ts)
+
+
+------------------------------------------------------------------------------
getDocTest :: H.Assertion
getDocTest = do
d <- getDoc "bkteoar"
commit b4ba099792f673e41a577a75791cfe630e0a0d31
Author: stwill <[email protected]>
Date: Fri Oct 22 12:18:37 2010 -0400
Tests.hs: added a test for the <ignore> tag
diff --git a/test/suite/Text/Templating/Heist/Tests.hs
b/test/suite/Text/Templating/Heist/Tests.hs
index d541716..86ce320 100644
--- a/test/suite/Text/Templating/Heist/Tests.hs
+++ b/test/suite/Text/Templating/Heist/Tests.hs
@@ -30,6 +30,7 @@ import Text.Templating.Heist
import Text.Templating.Heist.Internal
import Text.Templating.Heist.Types
import Text.Templating.Heist.Splices.Apply
+import Text.Templating.Heist.Splices.Ignore
import Text.XML.Expat.Cursor
import Text.XML.Expat.Format
import qualified Text.XML.Expat.Tree as X
@@ -50,6 +51,7 @@ tests = [ testProperty "heist/simpleBind"
simpleBindTest
, testCase "heist/bindAttribute" bindAttrTest
, testCase "heist/markdown" markdownTest
, testCase "heist/apply" applyTest
+ , testCase "heist/ignore" ignoreTest
]
@@ -180,6 +182,7 @@ bindAttrTest = do
ets <- loadT "templates"
let ts = either (error "Error loading templates") id ets
check ts "<div id=\"zzzzz\""
+
where
check ts str = do
res <- renderTemplate ts "bind-attrs"
@@ -214,6 +217,16 @@ applyTest = do
------------------------------------------------------------------------------
+ignoreTest :: H.Assertion
+ignoreTest = do
+ let es = emptyTemplateState :: TemplateState IO
+ res <- evalTemplateMonad ignoreImpl
+ (X.Element "ignore" [("tag", "ignorable")]
+ [X.Text "This should be ignored"]) es
+ H.assertEqual "<ignore> tag" [] res
+
+
+------------------------------------------------------------------------------
-- Utility functions
isLeft :: Either a b -> Bool
@@ -279,7 +292,7 @@ insertAt elems n list = maybe [] (toForest . root) $
------------------------------------------------------------------------------
move :: Insert ()
-move = modify (\x -> x-1)
+move = modify (\x -> x - 1)
------------------------------------------------------------------------------
@@ -360,8 +373,8 @@ instance Arbitrary Bind where
kids <- liftM (take 3) arbitrary
doc <- liftM (take 5) arbitrary
let s = insSize doc
- loc <- choose (0, s-1)
- loc2 <- choose (0, s-loc-1)
+ loc <- choose (0, s - 1)
+ loc2 <- choose (0, s - loc - 1)
return $ Bind name kids doc loc loc2
shrink (Bind e [c] (_:ds) p r) = [Bind e [c] ds p r]
shrink (Bind e (_:cs) d p r) = [Bind e cs d p r]
@@ -438,7 +451,7 @@ instance Arbitrary Apply where
caller <- liftM (take 5) arbitrary
callee <- liftM (take 1) $ listOf $ limitedDepth 3
let s = insSize caller
- loc <- choose (0, s-1)
+ loc <- choose (0, s - 1)
return $ Apply name caller callee kids loc
@@ -458,6 +471,7 @@ calcResult :: (MonadIO m) => Apply -> m [Node]
calcResult apply@(Apply name _ callee _ _) =
evalTemplateMonad (runNodeList $ buildApplyCaller apply)
(X.Text "") ts
+
where ts = setTemplates (Map.singleton [unName name]
(InternalTemplate Nothing callee))
emptyTemplateState
commit e7b6252be2941d1e4090097d5d34d63c638519c0
Author: stwill <[email protected]>
Date: Fri Oct 22 12:07:33 2010 -0400
Tests.hs: should be 'expected', 'actual' in assertEqual
diff --git a/test/suite/Text/Templating/Heist/Tests.hs
b/test/suite/Text/Templating/Heist/Tests.hs
index e0a985a..d541716 100644
--- a/test/suite/Text/Templating/Heist/Tests.hs
+++ b/test/suite/Text/Templating/Heist/Tests.hs
@@ -188,13 +188,13 @@ bindAttrTest = do
H.assertBool ("attr subst bar") $
B.null $ snd $ B.breakSubstring "$(bar)" $ fromJust res
-
+
------------------------------------------------------------------------------
markdownTest :: H.Assertion
markdownTest = do
ets <- loadT "templates"
let ts = either (error "Error loading templates") id ets
-
+
check ts "<div class=\"markdown\"><p>This <em>is</em> a test.</p></div>"
where
@@ -210,8 +210,8 @@ applyTest = do
let es = emptyTemplateState :: TemplateState IO
res <- evalTemplateMonad applyImpl
(X.Element "apply" [("template", "nonexistant")] []) es
- H.assertEqual "apply nothing" res []
-
+ H.assertEqual "apply nothing" [] res
+
------------------------------------------------------------------------------
-- Utility functions
-----------------------------------------------------------------------
hooks/post-receive
--
heist
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap