on master help sign in
Updated tests.
c9d4624Jasper Van der Jeugt
src/Text/Hakyll/Page.hs+6−2
@@ -58,14 +58,18 @@ getBody (Page page) = fromMaybe [] $ M.lookup "body" page
58
58
59-- | The default reader options for pandoc parsing.
59-- | The default reader options for pandoc parsing.
60readerOptions :: ParserState
60readerOptions :: ParserState
61−readerOptions = defaultParserState { stateSmart = True }
61+readerOptions = defaultParserState
62+ { -- The following option causes pandoc to read smart typography, a nice
63+ -- and free bonus.
64+ stateSmart = True
65+ }
62
66
63-- | The default writer options for pandoc rendering.
67-- | The default writer options for pandoc rendering.
64writerOptions :: WriterOptions
68writerOptions :: WriterOptions
65writerOptions = defaultWriterOptions
69writerOptions = defaultWriterOptions
66 { -- This option causes literate haskell to be written using '>' marks in
70 { -- This option causes literate haskell to be written using '>' marks in
67 -- html, which I think is a good default.
71 -- html, which I think is a good default.
68− , writerLiterateHaskell = True
72+ writerLiterateHaskell = True
69 }
73 }
70
74
71-- | Get a render function for a given extension.
75-- | Get a render function for a given extension.
tests/CompressCSS.hsdeleted−35
@@ -1,35 +0,0 @@
1−module CompressCSS
2− ( compressCSSGroup
3− ) where
4−
5−import qualified Data.Map as M
6−
7−import Data.Binary
8−import Test.Framework (testGroup)
9−import Test.Framework.Providers.HUnit
10−import Test.Framework.Providers.QuickCheck2
11−import Test.HUnit
12−
13−import Text.Hakyll.Internal.CompressCSS
14−
15−-- CompressCSS test group.
16−compressCSSGroup = testGroup "CompressCSS"
17− [ testProperty "prop_compressCSS_length" prop_compressCSS_length
18− , testCase "test_compressCSS_1" test_compressCSS_1
19− , testCase "test_compressCSS_2" test_compressCSS_2
20− , testCase "test_compressCSS_3" test_compressCSS_3
21− , testCase "test_compressCSS_4" test_compressCSS_4
22− ]
23−
24−-- CSS compression should always decrease the text length.
25−prop_compressCSS_length str = length str >= length (compressCSS str)
26−
27−-- Compress CSS test cases.
28−test_compressCSS_1 = compressCSS "a { \n color : red; }" @?= "a{color:red}"
29−test_compressCSS_2 = compressCSS "img {border :none;;;; }"
30− @?= "img{border:none}"
31−test_compressCSS_3 =
32− compressCSS "p {font-size : 90%;} h1 {color :white;;; }"
33− @?= "p{font-size:90%}h1{color:white}"
34−test_compressCSS_4 = compressCSS "a { /* /* red is pretty cool */ color: red; }"
35− @?= "a{color:red}"
tests/CompressCss.hsnew file+35
@@ -0,0 +1,35 @@
1+module CompressCss
2+ ( compressCssGroup
3+ ) where
4+
5+import qualified Data.Map as M
6+
7+import Data.Binary
8+import Test.Framework (testGroup)
9+import Test.Framework.Providers.HUnit
10+import Test.Framework.Providers.QuickCheck2
11+import Test.HUnit
12+
13+import Text.Hakyll.Internal.CompressCss
14+
15+-- CompressCss test group.
16+compressCssGroup = testGroup "CompressCss"
17+ [ testProperty "prop_compressCss_length" prop_compressCss_length
18+ , testCase "test_compressCss_1" test_compressCss_1
19+ , testCase "test_compressCss_2" test_compressCss_2
20+ , testCase "test_compressCss_3" test_compressCss_3
21+ , testCase "test_compressCss_4" test_compressCss_4
22+ ]
23+
24+-- Css compression should always decrease the text length.
25+prop_compressCss_length str = length str >= length (compressCss str)
26+
27+-- Compress Css test cases.
28+test_compressCss_1 = compressCss "a { \n color : red; }" @?= "a{color:red}"
29+test_compressCss_2 = compressCss "img {border :none;;;; }"
30+ @?= "img{border:none}"
31+test_compressCss_3 =
32+ compressCss "p {font-size : 90%;} h1 {color :white;;; }"
33+ @?= "p{font-size:90%}h1{color:white}"
34+test_compressCss_4 = compressCss "a { /* /* red is pretty cool */ color: red; }"
35+ @?= "a{color:red}"
tests/Main.hs+2−2
@@ -4,7 +4,7 @@ import Test.Framework (defaultMain, testGroup)
4import Test.Framework.Providers.HUnit
4import Test.Framework.Providers.HUnit
5import Test.Framework.Providers.QuickCheck2
5import Test.Framework.Providers.QuickCheck2
6
6
7−import CompressCSS
7+import CompressCss
8import Context
8import Context
9import File
9import File
10import Page
10import Page
@@ -12,7 +12,7 @@ import Regex
12import Template
12import Template
13import Util
13import Util
14
14
15−main = defaultMain [ compressCSSGroup
15+main = defaultMain [ compressCssGroup
16 , contextGroup
16 , contextGroup
17 , fileGroup
17 , fileGroup
18 , pageGroup
18 , pageGroup
tests/Util.hs+14−14
@@ -16,11 +16,11 @@ import Text.Hakyll.Util
16utilGroup = testGroup "Util"
16utilGroup = testGroup "Util"
17 [ testProperty "prop_trim_length" prop_trim_length
17 [ testProperty "prop_trim_length" prop_trim_length
18 , testProperty "prop_trim_id" prop_trim_id
18 , testProperty "prop_trim_id" prop_trim_id
19− , testProperty "prop_stripHTML_length" prop_stripHTML_length
19+ , testProperty "prop_stripHtml_length" prop_stripHtml_length
20− , testProperty "prop_stripHTML_id" prop_stripHTML_id
20+ , testProperty "prop_stripHtml_id" prop_stripHtml_id
21− , testCase "test_stripHTML_1" test_stripHTML_1
21+ , testCase "test_stripHtml_1" test_stripHtml_1
22− , testCase "test_stripHTML_2" test_stripHTML_2
22+ , testCase "test_stripHtml_2" test_stripHtml_2
23− , testCase "test_stripHTML_3" test_stripHTML_3
23+ , testCase "test_stripHtml_3" test_stripHtml_3
24 , testCase "test_link_1" test_link_1
24 , testCase "test_link_1" test_link_1
25 , testCase "test_link_2" test_link_2
25 , testCase "test_link_2" test_link_2
26 ]
26 ]
@@ -35,17 +35,17 @@ prop_trim_id str = (not $ null str) && isAlreadyTrimmed ==> str == (trim str)
35 isAlreadyTrimmed = (not $ isSpace $ head str) && (not $ isSpace $ last str)
35 isAlreadyTrimmed = (not $ isSpace $ head str) && (not $ isSpace $ last str)
36
36
37-- Check that a stripped string is shorter.
37-- Check that a stripped string is shorter.
38−prop_stripHTML_length str = length str >= length (stripHTML str)
38+prop_stripHtml_length str = length str >= length (stripHtml str)
39
39
40-- Check that strings without tags remain untouched.
40-- Check that strings without tags remain untouched.
41−prop_stripHTML_id str = (not $ any (`elem` ['>', '<']) str)
41+prop_stripHtml_id str = (not $ any (`elem` ['>', '<']) str)
42− ==> str == stripHTML str
42+ ==> str == stripHtml str
43−
43+
44−-- Strip HTML test cases.
44+-- Strip Html test cases.
45−test_stripHTML_1 = stripHTML "<b>text</b>" @?= "text"
45+test_stripHtml_1 = stripHtml "<b>text</b>" @?= "text"
46−test_stripHTML_2 = stripHTML "text" @?= "text"
46+test_stripHtml_2 = stripHtml "text" @?= "text"
47−test_stripHTML_3 =
47+test_stripHtml_3 =
48− stripHTML "<b>Hakyll</b>, a <i>website</i> generator<img src=\"foo.png\" />"
48+ stripHtml "<b>Hakyll</b>, a <i>website</i> generator<img src=\"foo.png\" />"
49 @?= "Hakyll, a website generator"
49 @?= "Hakyll, a website generator"
50
50
51-- Link test cases.
51-- Link test cases.