Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
soenkehahn committed Mar 28, 2016
1 parent 9ba2d6b commit 44d3587
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
3 changes: 2 additions & 1 deletion dead-code-detection.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ executable dead-code-detection

test-suite spec
type: exitcode-stdio-1.0
main-is: Spec.hs
main-is: Main.hs
hs-source-dirs:
test
, src
Expand Down Expand Up @@ -81,6 +81,7 @@ test-suite spec
GraphSpec
Helper
RunSpec
Spec
Ast
Ast.UsedNames
Files
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ executables:

tests:
spec:
main: Spec.hs
main: Main.hs
source-dirs:
- test
- src
Expand Down
27 changes: 27 additions & 0 deletions test/Ast/UsedNamesSpec.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

module Ast.UsedNamesSpec where

import Control.Exception
import Data.Foldable
import Data.List
import Test.Hspec

import Ast.UsedNames

spec :: Spec
spec = do
let errs :: [(String, ())]
errs =
("errorNyiData", errorNyiData ()) :
("errorNyiOutputable", errorNyiOutputable ()) :
[]
forM_ errs $ \ (name, err) -> do
describe name $ do
it "explains that this is not yet implemented" $ do
seq err (return ()) `shouldThrow` \ (ErrorCall message) ->
"not yet implemented" `isInfixOf` message

it "points to the issue tracker" $ do
seq err (return ()) `shouldThrow` \ (ErrorCall message) ->
"https://github.com/soenkehahn/dead-code-detection/issues" `isInfixOf`
message
12 changes: 12 additions & 0 deletions test/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

module Main where

import GHC (runGhc)
import GHC.Paths (libdir)

import qualified Spec

main :: IO ()
main = do
runGhc (Just libdir) (return ())
Spec.main
2 changes: 1 addition & 1 deletion test/Spec.hs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
{-# OPTIONS_GHC -F -pgmF hspec-discover -optF --module-name=Spec #-}

0 comments on commit 44d3587

Please sign in to comment.