Refactor CPP slightly, Add test-cases

pull/222/head^2
Lennart Spitzner 2019-06-05 20:11:01 +02:00
parent 8551600377
commit f9d70cf546
2 changed files with 51 additions and 2 deletions

View File

@ -531,6 +531,45 @@ func = if cond
-- test -- test
abc abc
#test nonempty-case-short
func = case x of
False -> False
True -> True
#test nonempty-case-long
func =
case
lakjsdlajsdljasdlkjasldjasldjasldjalsdjlaskjd
lakjsdlajsdljasdlkjasldjasldjasldjalsdjlaskjd
of
False -> False
True -> True
#test nonempty-case-long-do
func = do
case
lakjsdlajsdljasdlkjasldjasldjasldjalsdjlaskjd
lakjsdlajsdljasdlkjasldjasldjasldjalsdjlaskjd
of
False -> False
True -> True
#test empty-case-short
func = case x of {}
#test empty-case-long
func =
case
lakjsdlajsdljasdlkjasldjasldjasldjalsdjlaskjd
lakjsdlajsdljasdlkjasldjasldjasldjalsdjlaskjd
of {}
#test empty-case-long-do
func = do
case
lakjsdlajsdljasdlkjasldjasldjasldjalsdjlaskjd
lakjsdlajsdljasdlkjasldjasldjasldjalsdjlaskjd
of {}
############################################################################### ###############################################################################
############################################################################### ###############################################################################

View File

@ -136,6 +136,8 @@ layoutExpr lexpr@(L _ expr) = do
#if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */ #if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */
HsLamCase _ XMatchGroup{} -> HsLamCase _ XMatchGroup{} ->
error "brittany internal error: HsLamCase XMatchGroup" error "brittany internal error: HsLamCase XMatchGroup"
#endif
#if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */
HsLamCase _ (MG _ (L _ []) _) -> do HsLamCase _ (MG _ (L _ []) _) -> do
#elif MIN_VERSION_ghc(8,2,0) /* ghc-8.2 8.4*/ #elif MIN_VERSION_ghc(8,2,0) /* ghc-8.2 8.4*/
HsLamCase (MG (L _ []) _ _ _) -> do HsLamCase (MG (L _ []) _ _ _) -> do
@ -529,18 +531,26 @@ layoutExpr lexpr@(L _ expr) = do
#if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */ #if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */
HsCase _ _ XMatchGroup{} -> HsCase _ _ XMatchGroup{} ->
error "brittany internal error: HsCase XMatchGroup" error "brittany internal error: HsCase XMatchGroup"
#endif
#if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */
HsCase _ cExp (MG _ (L _ []) _) -> do HsCase _ cExp (MG _ (L _ []) _) -> do
#else #else
HsCase cExp (MG (L _ []) _ _ _) -> do HsCase cExp (MG (L _ []) _ _ _) -> do
#endif #endif
cExpDoc <- docSharedWrapper layoutExpr cExp cExpDoc <- docSharedWrapper layoutExpr cExp
docSetParSpacing docAlt
$ docAddBaseY BrIndentRegular [ docAddBaseY BrIndentRegular
$ docSeq $ docSeq
[ appSep $ docLit $ Text.pack "case" [ appSep $ docLit $ Text.pack "case"
, appSep $ docForceSingleline cExpDoc , appSep $ docForceSingleline cExpDoc
, docLit $ Text.pack "of {}" , docLit $ Text.pack "of {}"
] ]
, docPar
( docAddBaseY BrIndentRegular
$ docPar (docLit $ Text.pack "case") cExpDoc
)
(docLit $ Text.pack "of {}")
]
#if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */ #if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */
HsCase _ cExp (MG _ lmatches@(L _ matches) _) -> do HsCase _ cExp (MG _ lmatches@(L _ matches) _) -> do
#else #else