From b5adcb69d1cd26e613c5c56c85307050bb8297cf Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 20 Nov 2012 11:50:22 +0100 Subject: Update more tests --- tests/Hakyll/Core/Compiler/Tests.hs | 36 ------------------------ tests/Hakyll/Core/Dependencies/Tests.hs | 19 ++++++------- tests/Hakyll/Core/Util/Arrow/Tests.hs | 14 ---------- tests/Hakyll/Web/Urls/Relativize/Tests.hs | 46 +++++++++++++++++++------------ tests/Hakyll/Web/Urls/Tests.hs | 23 +++++++++++----- 5 files changed, 52 insertions(+), 86 deletions(-) delete mode 100644 tests/Hakyll/Core/Compiler/Tests.hs delete mode 100644 tests/Hakyll/Core/Util/Arrow/Tests.hs (limited to 'tests/Hakyll') diff --git a/tests/Hakyll/Core/Compiler/Tests.hs b/tests/Hakyll/Core/Compiler/Tests.hs deleted file mode 100644 index 7ea3e6f..0000000 --- a/tests/Hakyll/Core/Compiler/Tests.hs +++ /dev/null @@ -1,36 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -module Hakyll.Core.Compiler.Tests - ( tests - ) where - -import qualified Data.Map as M - -import Test.Framework (Test) -import Test.Framework.Providers.HUnit (testCase) -import qualified Test.HUnit as H - -import Hakyll.Core.Compiler -import Hakyll.Core.Resource.Provider.Dummy -import Hakyll.Core.Util.Arrow -import TestSuite.Util - -tests :: [Test] -tests = - [ testCase "byExtension" byExtensionTest - ] - -byExtensionTest :: H.Assertion -byExtensionTest = do - provider <- dummyResourceProvider $ M.empty - txt <- runCompilerJobTest compiler "foo.txt" provider uni - css <- runCompilerJobTest compiler "bar.css" provider uni - html <- runCompilerJobTest compiler "qux.html" provider uni - H.assertEqual "byExtension" "txt" txt - H.assertEqual "byExtension" "css" css - H.assertEqual "byExtension" "unknown" html - where - uni = ["foo.txt", "bar.css", "qux.html"] - compiler = byExtension (constA ("unknown" :: String)) - [ (".txt", constA "txt") - , (".css", constA "css") - ] diff --git a/tests/Hakyll/Core/Dependencies/Tests.hs b/tests/Hakyll/Core/Dependencies/Tests.hs index 22d606f..d6e3094 100644 --- a/tests/Hakyll/Core/Dependencies/Tests.hs +++ b/tests/Hakyll/Core/Dependencies/Tests.hs @@ -6,26 +6,23 @@ module Hakyll.Core.Dependencies.Tests -------------------------------------------------------------------------------- -import Data.List (delete) -import qualified Data.Map as M -import qualified Data.Set as S -import Test.Framework (Test, testGroup) -import Test.Framework.Providers.HUnit (testCase) -import Test.HUnit (Assertion, (@=?)) +import Data.List (delete) +import qualified Data.Map as M +import qualified Data.Set as S +import Test.Framework (Test, testGroup) +import Test.HUnit (Assertion, (@=?)) -------------------------------------------------------------------------------- import Hakyll.Core.Dependencies import Hakyll.Core.Identifier +import TestSuite.Util -------------------------------------------------------------------------------- tests :: Test -tests = testGroup "Hakyll.Core.Dependencies.Tests" - [ testCase "case01" case01 - , testCase "case02" case02 - , testCase "case03" case03 - ] +tests = testGroup "Hakyll.Core.Dependencies.Tests" $ + fromAssertions "analyze" [case01, case02, case03] -------------------------------------------------------------------------------- diff --git a/tests/Hakyll/Core/Util/Arrow/Tests.hs b/tests/Hakyll/Core/Util/Arrow/Tests.hs deleted file mode 100644 index c0c7eaa..0000000 --- a/tests/Hakyll/Core/Util/Arrow/Tests.hs +++ /dev/null @@ -1,14 +0,0 @@ -module Hakyll.Core.Util.Arrow.Tests - ( tests - ) where - -import Test.Framework (Test) -import Test.HUnit ((@=?)) - -import Hakyll.Core.Util.Arrow -import TestSuite.Util - -tests :: [Test] -tests = fromAssertions "sequenceA" - [ [8, 20, 1] @=? sequenceA [(+ 4), (* 5), signum] (4 :: Int) - ] diff --git a/tests/Hakyll/Web/Urls/Relativize/Tests.hs b/tests/Hakyll/Web/Urls/Relativize/Tests.hs index 465d266..e14a2a4 100644 --- a/tests/Hakyll/Web/Urls/Relativize/Tests.hs +++ b/tests/Hakyll/Web/Urls/Relativize/Tests.hs @@ -1,25 +1,35 @@ +-------------------------------------------------------------------------------- {-# LANGUAGE OverloadedStrings #-} module Hakyll.Web.Urls.Relativize.Tests ( tests ) where -import Test.Framework -import Test.HUnit hiding (Test) -import Hakyll.Web.Urls.Relativize -import TestSuite.Util +-------------------------------------------------------------------------------- +import Test.Framework (Test, testGroup) +import Test.HUnit ((@=?)) -tests :: [Test] -tests = fromAssertions "relativizeUrls" - [ "bar" @=? - relativizeUrls ".." "bar" - , "" @=? - relativizeUrls "../.." "" - , "Haskell" @=? - relativizeUrls "../.." "Haskell" - , "Haskell" @=? - relativizeUrls "../.." "Haskell" - , "" @=? - relativizeUrls "../.." - "" - ] + +-------------------------------------------------------------------------------- +import Hakyll.Web.Urls.Relativize +import TestSuite.Util + + +-------------------------------------------------------------------------------- +tests :: Test +tests = testGroup "Hakyll.Web.Urls.Relativize.Tests" $ + fromAssertions "relativizeUrls" + [ "bar" @=? + relativizeUrlsWith ".." "bar" + , "" @=? + relativizeUrlsWith "../.." "" + , "Haskell" @=? + relativizeUrlsWith "../.." + "Haskell" + , "Haskell" @=? + relativizeUrlsWith "../.." + "Haskell" + , "" @=? + relativizeUrlsWith "../.." + "" + ] diff --git a/tests/Hakyll/Web/Urls/Tests.hs b/tests/Hakyll/Web/Urls/Tests.hs index 72b6687..56a1838 100644 --- a/tests/Hakyll/Web/Urls/Tests.hs +++ b/tests/Hakyll/Web/Urls/Tests.hs @@ -1,17 +1,23 @@ +-------------------------------------------------------------------------------- module Hakyll.Web.Urls.Tests ( tests ) where -import Data.Char (toUpper) -import Test.Framework -import Test.HUnit hiding (Test) +-------------------------------------------------------------------------------- +import Data.Char (toUpper) +import Test.Framework (Test, testGroup) +import Test.HUnit (assert, (@=?)) -import Hakyll.Web.Urls -import TestSuite.Util -tests :: [Test] -tests = concat +-------------------------------------------------------------------------------- +import Hakyll.Web.Urls +import TestSuite.Util + + +-------------------------------------------------------------------------------- +tests :: Test +tests = testGroup "Hakyll.Web.Urls.Tests" $ concat [ fromAssertions "withUrls" [ "bar" @=? withUrls (map toUpper) "bar" @@ -26,17 +32,20 @@ tests = concat , "" @=? withUrls id "" ] + , fromAssertions "toUrl" [ "/foo/bar.html" @=? toUrl "foo/bar.html" , "/" @=? toUrl "/" , "/funny-pics.html" @=? toUrl "/funny-pics.html" ] + , fromAssertions "toSiteRoot" [ ".." @=? toSiteRoot "/foo/bar.html" , "." @=? toSiteRoot "index.html" , "." @=? toSiteRoot "/index.html" , "../.." @=? toSiteRoot "foo/bar/qux" ] + , fromAssertions "isExternal" [ assert (isExternal "http://reddit.com") , assert (isExternal "https://mail.google.com") -- cgit v1.2.3