diff options
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 |