DynFlags: Support British spelling of GeneralisedNewtypeDeriving
[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 "EmptyDataDeriving",
43 "NumericUnderscores",
44 "GeneralisedNewtypeDeriving"]
45
46 expectedCabalOnlyExtensions :: [String]
47 expectedCabalOnlyExtensions = ["Generics",
48 "ExtensibleRecords",
49 "RestrictedTypeSynonyms",
50 "HereDocuments",
51 "NewQualifiedOperators",
52 "XmlSyntax",
53 "RegularPatterns",
54 "SafeImports",
55 "Safe",
56 "Unsafe",
57 "Trustworthy"]