Files
ghc-mod/test/Expectation.hs

21 lines
730 B
Haskell
Raw Normal View History

2013-02-12 14:06:22 +09:00
module Expectation where
import Test.Hspec
2013-02-12 16:24:33 +09:00
import System.Directory
import Control.Exception as E
2013-02-12 14:06:22 +09:00
shouldContain :: Eq a => [a] -> a -> Expectation
shouldContain containers element = do
let res = element `elem` containers
res `shouldBe` True
2013-02-12 16:24:33 +09:00
2013-03-05 10:22:33 +09:00
withDirectory_ :: FilePath -> IO a -> IO a
withDirectory_ dir action = bracket getCurrentDirectory
2013-03-05 10:44:17 +09:00
setCurrentDirectory
(\_ -> setCurrentDirectory dir >> action)
2013-03-05 10:22:33 +09:00
withDirectory :: FilePath -> (FilePath -> IO a) -> IO a
withDirectory dir action = bracket getCurrentDirectory
setCurrentDirectory
(\d -> setCurrentDirectory dir >> action d)