Housekeeping for GHC 8
- Remove some CPP needed only because of GHC 7.4 (which is not supported now, yey) - Move CPP for GHC 8 to Gap module
This commit is contained in:
@@ -33,7 +33,11 @@ pkgOptions (x:y:xs) | x == "-package-id" = [name y] ++ pkgOptions xs
|
||||
| otherwise = pkgOptions (y:xs)
|
||||
where
|
||||
stripDash s = maybe s id $ (flip drop s . (+1) <$> findIndex (=='-') s)
|
||||
#if __GLASGOW_HASKELL__ >= 800
|
||||
name s = reverse $ stripDash $ reverse s
|
||||
#else
|
||||
name s = reverse $ stripDash $ stripDash $ reverse s
|
||||
#endif
|
||||
|
||||
idirOpts :: [(c, [String])] -> [(c, [String])]
|
||||
idirOpts = map (second $ map (drop 2) . filter ("-i"`isPrefixOf`))
|
||||
@@ -69,7 +73,7 @@ spec = do
|
||||
it "extracts build dependencies" $ do
|
||||
let tdir = "test/data/cabal-project"
|
||||
opts <- map gmcGhcOpts <$> runD' tdir getComponents
|
||||
let ghcOpts = head opts
|
||||
let ghcOpts:_ = opts
|
||||
pkgs = pkgOptions ghcOpts
|
||||
pkgs `shouldBe` ["Cabal","base","template-haskell"]
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ spec = do
|
||||
it "emits warnings generated in GHC's desugar stage" $ do
|
||||
withDirectory_ "test/data/check-missing-warnings" $ do
|
||||
res <- runD $ checkSyntax ["DesugarWarnings.hs"]
|
||||
res `shouldBe` "DesugarWarnings.hs:4:9:Warning: Pattern match(es) are non-exhaustive\NULIn a case alternative: Patterns not matched: _ : _\n"
|
||||
res `shouldSatisfy` ("DesugarWarnings.hs:4:9:Warning: Pattern match(es) are non-exhaustive\NULIn a case alternative: Patterns not matched:" `isPrefixOf`)
|
||||
#endif
|
||||
|
||||
it "works with cabal builtin preprocessors" $ do
|
||||
@@ -71,7 +71,9 @@ spec = do
|
||||
it "Uses the right qualification style" $ do
|
||||
withDirectory_ "test/data/nice-qualification" $ do
|
||||
res <- runD $ checkSyntax ["NiceQualification.hs"]
|
||||
#if __GLASGOW_HASKELL__ >= 708
|
||||
#if __GLASGOW_HASKELL__ >= 800
|
||||
res `shouldBe` "NiceQualification.hs:4:8:\8226 Couldn't match expected type \8216IO ()\8217 with actual type \8216[Char]\8217\NUL\8226 In the expression: \"wrong type\"\NUL In an equation for \8216main\8217: main = \"wrong type\"\n"
|
||||
#elif __GLASGOW_HASKELL__ >= 708
|
||||
res `shouldBe` "NiceQualification.hs:4:8:Couldn't match expected type \8216IO ()\8217 with actual type \8216[Char]\8217\NULIn the expression: \"wrong type\"\NULIn an equation for \8216main\8217: main = \"wrong type\"\n"
|
||||
#else
|
||||
res `shouldBe` "NiceQualification.hs:4:8:Couldn't match expected type `IO ()' with actual type `[Char]'\NULIn the expression: \"wrong type\"\NULIn an equation for `main': main = \"wrong type\"\n"
|
||||
|
||||
@@ -136,7 +136,7 @@ spec = do
|
||||
loadMappedFile "File.hs" "File_Redir_Lint.hs"
|
||||
types False "File.hs" 4 12
|
||||
res `shouldBe` "4 12 4 15 \"a -> a -> a\"\n4 12 4 17 \"a -> a\"\n4 12 4 19 \"a\"\n4 1 4 19 \"a -> a -> a\"\n"
|
||||
it "shows types of the expression with constraints for redirected files" $ do
|
||||
it "shows types of the expression with constraints for redirected files" $ do --
|
||||
let tdir = "test/data/file-mapping"
|
||||
res <- runD' tdir $ do
|
||||
loadMappedFile "File.hs" "File_Redir_Lint.hs"
|
||||
|
||||
@@ -9,6 +9,6 @@ import Prelude
|
||||
spec :: Spec
|
||||
spec = do
|
||||
describe "flags" $ do
|
||||
it "contains at least `-fno-warn-orphans'" $ do
|
||||
it "contains at least `-fprint-explicit-foralls" $ do
|
||||
f <- runD $ lines <$> flags
|
||||
f `shouldContain` ["-fno-warn-orphans"]
|
||||
f `shouldContain` ["-fprint-explicit-foralls"]
|
||||
|
||||
@@ -20,12 +20,21 @@ spec = do
|
||||
it "shows types of the expression and its outers" $ do
|
||||
let tdir = "test/data/ghc-mod-check"
|
||||
res <- runD' tdir $ types False "lib/Data/Foo.hs" 9 5
|
||||
#if __GLASGOW_HASKELL__ >= 800
|
||||
res `shouldBe` "9 5 11 40 \"Int -> t -> t -> t\"\n7 1 11 40 \"Int -> Integer\"\n"
|
||||
#else
|
||||
res `shouldBe` "9 5 11 40 \"Int -> a -> a -> a\"\n7 1 11 40 \"Int -> Integer\"\n"
|
||||
#endif
|
||||
|
||||
|
||||
it "shows types of the expression with constraints and its outers" $ do
|
||||
let tdir = "test/data/ghc-mod-check"
|
||||
res <- runD' tdir $ types True "lib/Data/Foo.hs" 9 5
|
||||
#if __GLASGOW_HASKELL__ >= 800
|
||||
res `shouldBe` "9 5 11 40 \"Num t => Int -> t -> t -> t\"\n7 1 11 40 \"Int -> Integer\"\n"
|
||||
#else
|
||||
res `shouldBe` "9 5 11 40 \"Num a => Int -> a -> a -> a\"\n7 1 11 40 \"Int -> Integer\"\n"
|
||||
#endif
|
||||
|
||||
it "works with a module using TemplateHaskell" $ do
|
||||
let tdir = "test/data/template-haskell"
|
||||
|
||||
@@ -23,16 +23,18 @@ spec = do
|
||||
|
||||
mv_ex :: MVar (Either SomeException ())
|
||||
<- newEmptyMVar
|
||||
mv_startup_barrier :: MVar () <- newEmptyMVar
|
||||
mv_startup_barrier :: MVar ()
|
||||
<- newEmptyMVar
|
||||
|
||||
_t1 <- forkOS $ do
|
||||
putMVar mv_startup_barrier ()
|
||||
-- wait (inside GhcModT) for t2 to receive the exception
|
||||
_ <- runD $ liftIO $ readMVar mv_ex
|
||||
_ <- runD $ liftIO $ do
|
||||
putMVar mv_startup_barrier ()
|
||||
readMVar mv_ex
|
||||
return ()
|
||||
|
||||
_t2 <- forkOS $ do
|
||||
readMVar mv_startup_barrier -- wait for t1 to start up
|
||||
readMVar mv_startup_barrier -- wait for t1 to be in GhcModT
|
||||
res <- try $ runD $ return ()
|
||||
res' <- evaluate res
|
||||
putMVar mv_ex res'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{-# LANGUAGE PatternSynonyms #-}
|
||||
|
||||
module A where
|
||||
|
||||
data SomeType a b = SomeType (a,b)
|
||||
|
||||
@@ -22,4 +22,6 @@ library
|
||||
build-depends: base
|
||||
-- hs-source-dirs:
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall
|
||||
ghc-options: -Wall
|
||||
if impl(ghc >= 8.0.1)
|
||||
ghc-options: -Wno-missing-pattern-synonym-signatures
|
||||
@@ -16,7 +16,7 @@ cabal-version: >=1.10
|
||||
library
|
||||
hs-source-dirs: src
|
||||
exposed-modules: Lib
|
||||
build-depends: base >= 4.7 && < 5
|
||||
build-depends: base
|
||||
default-language: Haskell2010
|
||||
|
||||
executable new-template-exe
|
||||
|
||||
Reference in New Issue
Block a user