diff options
author | Langston Barrett <langston.barrett@gmail.com> | 2016-07-07 15:20:27 +0100 |
---|---|---|
committer | Langston Barrett <langston.barrett@gmail.com> | 2016-07-07 16:19:15 +0100 |
commit | f5b2adc9a371345da9f2e9a19b67851afc248889 (patch) | |
tree | 72108bd5b03a15a389caa919514974d5939b6a32 /tests | |
parent | abc92ea4778ac25b7944b9f4c7f82eb95f0238c2 (diff) | |
download | stylish-haskell-f5b2adc9a371345da9f2e9a19b67851afc248889.tar.gz |
Add a set of default language extensions for parsing
See the comment for a detailed explanation.
Fixes jaspervdj/stylish-haskell#117
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Language/Haskell/Stylish/Parse/Tests.hs | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/tests/Language/Haskell/Stylish/Parse/Tests.hs b/tests/Language/Haskell/Stylish/Parse/Tests.hs index 87c0a51..1e6b992 100644 --- a/tests/Language/Haskell/Stylish/Parse/Tests.hs +++ b/tests/Language/Haskell/Stylish/Parse/Tests.hs @@ -16,12 +16,16 @@ import Language.Haskell.Stylish.Parse -------------------------------------------------------------------------------- tests :: Test tests = testGroup "Language.Haskell.Stylish.Parse" - [ testCase "UTF-8 Byte Order Mark" testBom - , testCase "Extra extensions" testExtraExtensions - , testCase "Multiline CPP" testMultilineCpp - , testCase "Haskell2010 extension" testHaskell2010 - , testCase "Shebang" testShebang - , testCase "ShebangExt" testShebangExt + [ testCase "UTF-8 Byte Order Mark" testBom + , testCase "Extra extensions" testExtraExtensions + , testCase "Multiline CPP" testMultilineCpp + , testCase "Haskell2010 extension" testHaskell2010 + , testCase "Shebang" testShebang + , testCase "ShebangExt" testShebangExt + , testCase "GADTs extension" testGADTs + , testCase "KindSignatures extension" testKindSignatures + , testCase "StandalonDeriving extension" testKindSignatures + , testCase "UnicodeSyntax extension" testUnicodeSyntax ] -------------------------------------------------------------------------------- @@ -77,6 +81,38 @@ testShebang = assert $ isRight $ parseModule [] Nothing $ unlines , "main = return ()" ] +-------------------------------------------------------------------------------- + +-- | These tests are for syntactic language extensions that should always be +-- enabled for parsing, even when the pragma is absent. + +testGADTs :: Assertion +testGADTs = assert $ isRight $ parseModule [] Nothing $ unlines + [ "module Main where" + , "data SafeList a b where" + , " Nil :: SafeList a Empty" + , " Cons:: a -> SafeList a b -> SafeList a NonEmpty" + ] + +testKindSignatures :: Assertion +testKindSignatures = assert $ isRight $ parseModule [] Nothing $ unlines + [ "module Main where" + , "data D :: * -> * -> * where" + , " D :: a -> b -> D a b" + ] + +testStandaloneDeriving :: Assertion +testStandaloneDeriving = assert $ isRight $ parseModule [] Nothing $ unlines + [ "module Main where" + , "deriving instance Show MyType" + ] + +testUnicodeSyntax :: Assertion +testUnicodeSyntax = assert $ isRight $ parseModule [] Nothing $ unlines + [ "module Main where" + , "monadic ∷ (Monad m) ⇒ m a → m a" + , "monadic = id" + ] -------------------------------------------------------------------------------- isRight :: Either a b -> Bool |