From 418c39b759570777a259caec02e7b1421fa3c6e4 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Tue, 12 Feb 2013 14:06:22 +0900 Subject: [PATCH] adding tests. --- ghc-mod.cabal | 26 ++++++++++++++++++++++++++ test/Expectation.hs | 8 ++++++++ test/LangSpec.hs | 14 ++++++++++++++ test/ListSpec.hs | 14 ++++++++++++++ test/Spec.hs | 1 + 5 files changed, 63 insertions(+) create mode 100644 test/Expectation.hs create mode 100644 test/LangSpec.hs create mode 100644 test/ListSpec.hs create mode 100644 test/Spec.hs diff --git a/ghc-mod.cabal b/ghc-mod.cabal index 76c4194..6cd654c 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -62,6 +62,32 @@ Executable ghc-mod , time , transformers +Test-Suite spec + Main-Is: Spec.hs + Hs-Source-Dirs: test, . + Type: exitcode-stdio-1.0 + Other-Modules: Expectation + LangSpec + ListSpec + Build-Depends: base >= 4.0 && < 5 + , Cabal >= 1.10 + , containers + , convertible + , directory + , filepath + , ghc + , ghc-paths + , ghc-syb-utils + , hlint >= 1.7.1 + , io-choice + , old-time + , process + , regex-posix + , syb + , time + , transformers + , hspec + Source-Repository head Type: git Location: git://github.com/kazu-yamamoto/ghc-mod.git diff --git a/test/Expectation.hs b/test/Expectation.hs new file mode 100644 index 0000000..3fbf6aa --- /dev/null +++ b/test/Expectation.hs @@ -0,0 +1,8 @@ +module Expectation where + +import Test.Hspec + +shouldContain :: Eq a => [a] -> a -> Expectation +shouldContain containers element = do + let res = element `elem` containers + res `shouldBe` True diff --git a/test/LangSpec.hs b/test/LangSpec.hs new file mode 100644 index 0000000..c233615 --- /dev/null +++ b/test/LangSpec.hs @@ -0,0 +1,14 @@ +module LangSpec where + +import Control.Applicative +import Test.Hspec +import Expectation +import Lang +import Types + +spec :: Spec +spec = do + describe "listLanguages" $ do + it "lists up language extensions" $ do + modules <- lines <$> listLanguages defaultOptions + modules `shouldContain` "OverloadedStrings" diff --git a/test/ListSpec.hs b/test/ListSpec.hs new file mode 100644 index 0000000..ff9cce9 --- /dev/null +++ b/test/ListSpec.hs @@ -0,0 +1,14 @@ +module ListSpec where + +import Control.Applicative +import Test.Hspec +import Expectation +import List +import Types + +spec :: Spec +spec = do + describe "listModules" $ do + it "lists up module names" $ do + modules <- lines <$> listModules defaultOptions + modules `shouldContain` "Data.Map" diff --git a/test/Spec.hs b/test/Spec.hs new file mode 100644 index 0000000..a824f8c --- /dev/null +++ b/test/Spec.hs @@ -0,0 +1 @@ +{-# OPTIONS_GHC -F -pgmF hspec-discover #-}