on master help sign in
Updated tests.
commitc9d4624a42c231ed200b69f1d6bf51c323febbbb authorJasper Van der Jeugt <jaspervdj@gmail.com> dateTue 16 Feb 2010, 19:18 (17 years ago) parent87e7e99
5 files changed+57−53
src/Text/Hakyll/Page.hs+6−2 tests/CompressCSS.hs−35 tests/CompressCss.hs+35 tests/Main.hs+2−2 tests/Util.hs+14−14
src/Text/Hakyll/Page.hs+6−2
@@ -58,14 +58,18 @@ getBody (Page page) = fromMaybe [] $ M.lookup "body" page
5858
5959-- | The default reader options for pandoc parsing.
6060readerOptions :: 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+ }
6266
6367-- | The default writer options for pandoc rendering.
6468writerOptions :: WriterOptions
6569writerOptions = defaultWriterOptions
6670 { -- This option causes literate haskell to be written using '>' marks in
6771 -- html, which I think is a good default.
68− , writerLiterateHaskell = True
72+ writerLiterateHaskell = True
6973 }
7074
7175-- | 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)
44import Test.Framework.Providers.HUnit
55import Test.Framework.Providers.QuickCheck2
66
7−import CompressCSS
7+import CompressCss
88import Context
99import File
1010import Page
@@ -12,7 +12,7 @@ import Regex
1212import Template
1313import Util
1414
15−main = defaultMain [ compressCSSGroup
15+main = defaultMain [ compressCssGroup
1616 , contextGroup
1717 , fileGroup
1818 , pageGroup
tests/Util.hs+14−14
@@ -16,11 +16,11 @@ import Text.Hakyll.Util
1616utilGroup = testGroup "Util"
1717 [ testProperty "prop_trim_length" prop_trim_length
1818 , testProperty "prop_trim_id" prop_trim_id
19− , testProperty "prop_stripHTML_length" prop_stripHTML_length
20− , testProperty "prop_stripHTML_id" prop_stripHTML_id
21− , testCase "test_stripHTML_1" test_stripHTML_1
22− , testCase "test_stripHTML_2" test_stripHTML_2
23− , testCase "test_stripHTML_3" test_stripHTML_3
19+ , testProperty "prop_stripHtml_length" prop_stripHtml_length
20+ , testProperty "prop_stripHtml_id" prop_stripHtml_id
21+ , testCase "test_stripHtml_1" test_stripHtml_1
22+ , testCase "test_stripHtml_2" test_stripHtml_2
23+ , testCase "test_stripHtml_3" test_stripHtml_3
2424 , testCase "test_link_1" test_link_1
2525 , testCase "test_link_2" test_link_2
2626 ]
@@ -35,17 +35,17 @@ prop_trim_id str = (not $ null str) && isAlreadyTrimmed ==> str == (trim str)
3535 isAlreadyTrimmed = (not $ isSpace $ head str) && (not $ isSpace $ last str)
3636
3737-- 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)
3939
4040-- Check that strings without tags remain untouched.
41−prop_stripHTML_id str = (not $ any (`elem` ['>', '<']) str)
42− ==> str == stripHTML str
43−
44−-- Strip HTML test cases.
45−test_stripHTML_1 = stripHTML "<b>text</b>" @?= "text"
46−test_stripHTML_2 = stripHTML "text" @?= "text"
47−test_stripHTML_3 =
48− stripHTML "<b>Hakyll</b>, a <i>website</i> generator<img src=\"foo.png\" />"
41+prop_stripHtml_id str = (not $ any (`elem` ['>', '<']) str)
42+ ==> str == stripHtml str
43+
44+-- Strip Html test cases.
45+test_stripHtml_1 = stripHtml "<b>text</b>" @?= "text"
46+test_stripHtml_2 = stripHtml "text" @?= "text"
47+test_stripHtml_3 =
48+ stripHtml "<b>Hakyll</b>, a <i>website</i> generator<img src=\"foo.png\" />"
4949 @?= "Hakyll, a website generator"
5050
5151-- Link test cases.