adding tests.

This commit is contained in:
Kazu Yamamoto 2013-02-12 14:06:22 +09:00
parent e42a7e8bcb
commit 418c39b759
5 changed files with 63 additions and 0 deletions

View File

@ -62,6 +62,32 @@ Executable ghc-mod
, time , time
, transformers , 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 Source-Repository head
Type: git Type: git
Location: git://github.com/kazu-yamamoto/ghc-mod.git Location: git://github.com/kazu-yamamoto/ghc-mod.git

8
test/Expectation.hs Normal file
View File

@ -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

14
test/LangSpec.hs Normal file
View File

@ -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"

14
test/ListSpec.hs Normal file
View File

@ -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"

1
test/Spec.hs Normal file
View File

@ -0,0 +1 @@
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}