1
1
mirror of https://github.com/google/ormolu.git synced 2024-12-05 05:18:44 +03:00
ormolu/tests/Ormolu/Parser/LanguagePragmaSpec.hs
waddlaw ae40a33507 Sort language pragmas and fix their placement in modules
The approach we take here is parsing of language pragmas on creation of
comment stream and then pretty-printing them in a separate block.
2019-07-05 20:03:31 +02:00

23 lines
725 B
Haskell

module Ormolu.Parser.LanguagePragmaSpec (spec) where
import Ormolu.Parser.LanguagePragma
import Test.Hspec
import qualified Data.Set as S
spec :: Spec
spec = do
describe "parseLanguagePragma" $ do
stdTest "{-# LANGUAGE Foo #-}" (Just ["Foo"])
stdTest "{-# language Foo #-}" (Just ["Foo"])
stdTest "{-# lAngUAGe Foo #-}" (Just ["Foo"])
stdTest "{-# LANGUAGE Foo, Bar #-}" (Just ["Bar", "Foo"])
stdTest "{-# LANGUAGE Foo Bar #-}" Nothing
stdTest "{-# BOO Foo #-}" Nothing
stdTest "something" Nothing
stdTest "{-# LANGUAGE foo, Bar #-}" Nothing
stdTest :: String -> Maybe [String] -> Spec
stdTest input result = it input $
(S.toAscList <$> parseLanguagePragma input) `shouldBe`
result