Add InjectiveTypeFamilies language extension
[ghc.git] / testsuite / tests / driver / T4437.hs
1 -- | A test for ensuring that GHC's supporting language extensions remains in
2 -- sync with Cabal's own extension list.
3 --
4 -- If you have ended up here due to a test failure, please see
5 -- Note [Adding a language extension] in compiler/main/DynFlags.hs.
6
7 module Main (main) where
8
9 import Control.Monad
10 import Data.List
11 import DynFlags
12 import Language.Haskell.Extension
13
14 main :: IO ()
15 main = do
16 let ghcExtensions = map flagSpecName xFlags
17 cabalExtensions = map show [ toEnum 0 :: KnownExtension .. ]
18 ghcOnlyExtensions = ghcExtensions \\ cabalExtensions
19 cabalOnlyExtensions = cabalExtensions \\ ghcExtensions
20 check "GHC-only flags" expectedGhcOnlyExtensions ghcOnlyExtensions
21 check "Cabal-only flags" expectedCabalOnlyExtensions cabalOnlyExtensions
22
23 check :: String -> [String] -> [String] -> IO ()
24 check title expected got
25 = do let unexpected = got \\ expected
26 missing = expected \\ got
27 showProblems problemType problems
28 = unless (null problems) $
29 do putStrLn (title ++ ": " ++ problemType)
30 putStrLn "-----"
31 mapM_ putStrLn problems
32 putStrLn "-----"
33 putStrLn ""
34 showProblems "Unexpected flags" unexpected
35 showProblems "Missing flags" missing
36
37 -- See Note [Adding a language extension] in compiler/main/DynFlags.hs.
38 expectedGhcOnlyExtensions :: [String]
39 expectedGhcOnlyExtensions = ["RelaxedLayout",
40 "AlternativeLayoutRule",
41 "AlternativeLayoutRuleTransitional",
42 "InjectiveTypeFamilies"]
43
44 expectedCabalOnlyExtensions :: [String]
45 expectedCabalOnlyExtensions = ["Generics",
46 "ExtensibleRecords",
47 "RestrictedTypeSynonyms",
48 "HereDocuments",
49 "NewQualifiedOperators",
50 "XmlSyntax",
51 "RegularPatterns",
52 "SafeImports",
53 "Safe",
54 "Unsafe",
55 "Trustworthy"]