Using Cradle.

This commit is contained in:
Kazu Yamamoto
2013-03-02 16:14:55 +09:00
parent f43af4be29
commit a393f8a971
10 changed files with 62 additions and 101 deletions

View File

@@ -1,23 +0,0 @@
module CabalSpec where
import Control.Applicative
import System.Directory
import Test.Hspec
import Cabal
import Expectation
spec :: Spec
spec = do
describe "getDirs" $ do
it "obtains two directories and a cabal file" $ do
len <- length <$> getCurrentDirectory
withDirectory "test/data/subdir1/subdir2" $ do
(x,y,z) <- getDirs
(drop len x, drop len y, drop len z) `shouldBe` ("/test/data/subdir1/subdir2","/test/data","/test/data/cabalapi.cabal")
describe "getDirs" $ do
it "obtains two directories and a cabal file" $ do
len <- length <$> getCurrentDirectory
withDirectory "test/data/subdir1/subdir2" $ do
(x,y,z,w) <- fromCabal []
(x, map (drop len) y, z, w) `shouldBe` (["-XHaskell98"],["/test/data","/test/data/subdir1/subdir2"],["Cabal","base","containers","convertible","directory","filepath","ghc","ghc-paths","ghc-syb-utils","hlint","hspec","io-choice","old-time","process","regex-posix","syb","time","transformers"], [])

View File

@@ -1,8 +1,9 @@
module CheckSpec where
import Test.Hspec
import Check
import Cradle
import Expectation
import Test.Hspec
import Types
spec :: Spec
@@ -10,5 +11,6 @@ spec = do
describe "checkSyntax" $ do
it "can check even if an executable depends on its library" $ do
withDirectory "test/data/ghc-mod-check" $ do
res <- checkSyntax defaultOptions "main.hs"
cradle <- findCradle Nothing
res <- checkSyntax defaultOptions cradle "main.hs"
res `shouldBe` "main.hs:5:1:Warning: Top-level binding with no type signature: main :: IO ()\NUL\n"

View File

@@ -1,8 +1,9 @@
module InfoSpec where
import Test.Hspec
import Cradle
import Expectation
import Info
import Test.Hspec
import Types
spec :: Spec
@@ -10,5 +11,6 @@ spec = do
describe "typeExpr" $ do
it "shows types of the expression and its outers" $ do
withDirectory "test/data/ghc-mod-check" $ do
res <- typeExpr defaultOptions "Data.Foo" 9 5 "Data/Foo.hs"
cradle <- findCradle Nothing
res <- typeExpr defaultOptions cradle "Data.Foo" 9 5 "Data/Foo.hs"
res `shouldBe` "9 5 11 40 \"Int -> a -> a -> a\"\n7 1 11 40 \"Int -> Integer\"\n"