brittany/src-literatetests
Evan Rutledge Borden 7c1b731f1e First pass at sum types
This is a naive first pass at sum type support. This currently breaks 11
tests, some from comment misplacement, others in more exotic forms that
previously required high levels of context to be correctly laid out. The
solution for comment misplacement is probably trivial, but the highly
contextualized forms may need a bit more alchemy.

```
  1) data type declarations record no matching single line layout
       expected: Right
                 {-# LANGUAGE ScopedTypeVariables #-}
                 -- brittany { lconfig_allowSinglelineRecord: true }
                 data MyRecord = forall a . Show a => Bar
                   { foo :: abittoolongbutnotvery -> abittoolongbutnotvery
                   }

        but got: Right
                 {-# LANGUAGE ScopedTypeVariables #-}
                 -- brittany { lconfig_allowSinglelineRecord: true }
                 data MyRecord = forall a
                 . Show a =>
                   Bar
                     { foo :: abittoolongbutnotvery -> abittoolongbutnotvery
                     }

  2) data type declarations record forall constraint multiline
       expected: Right
                 {-# LANGUAGE ScopedTypeVariables #-}
                 data MyRecord
                   = forall a
                   . LooooooooooooooooooooongConstraint a =>
                     LoooooooooooongConstructor
                       { foo :: abittoolongbutnotvery -> abittoolongbutnotvery
                       }

        but got: Right
                 {-# LANGUAGE ScopedTypeVariables #-}
                 data MyRecord = forall a
                 . LooooooooooooooooooooongConstraint a =>
                   LoooooooooooongConstructor
                     { foo :: abittoolongbutnotvery -> abittoolongbutnotvery
                     }

  3) data type declarations record forall constraint multiline more
       expected: Right
                 {-# LANGUAGE ScopedTypeVariables #-}
                 data MyRecord
                   = forall a b
                   . ( Loooooooooooooooooooooooooooooooong a
                     , Loooooooooooooooooooooooooooooooong b
                     ) =>
                     MyConstructor
                       { a :: a
                       , b :: b
                       }

        but got: Right
                 {-# LANGUAGE ScopedTypeVariables #-}
                 data MyRecord = forall a b
                 . ( Loooooooooooooooooooooooooooooooong a
                   , Loooooooooooooooooooooooooooooooong b
                   ) =>
                   MyConstructor
                     { a :: a
                     , b :: b
                     }

  4) data type declarations plain with forall and constraint
       expected: Right
                 {-# LANGUAGE ScopedTypeVariables #-}
                 data MyStruct
                   = forall a b
                   . ( Loooooooooooooooooooooooooooooooong a
                     , Loooooooooooooooooooooooooooooooong b
                     ) =>
                     MyConstructor (ToBriDocM BriDocNumbered)
                                   (ToBriDocM BriDocNumbered)
                                   (ToBriDocM BriDocNumbered)

        but got: Right
                 {-# LANGUAGE ScopedTypeVariables #-}
                 data MyStruct = forall a b
                 . ( Loooooooooooooooooooooooooooooooong a
                   , Loooooooooooooooooooooooooooooooong b
                   ) =>
                   MyConstructor (ToBriDocM BriDocNumbered)
                                 (ToBriDocM BriDocNumbered)
                                 (ToBriDocM BriDocNumbered)

  5) data type declarations record with many features
       expected: Right
                 {-# LANGUAGE ScopedTypeVariables #-}
                 data MyRecord
                   = forall a b
                   . ( Loooooooooooooooooooooooooooooooong a
                     , Loooooooooooooooooooooooooooooooong b
                     ) =>
                     MyConstructor
                       { foo, foo2
                           :: loooooooooooooooooooooooooooooooong
                           -> loooooooooooooooooooooooooooooooong
                       , bar  :: a
                       , bazz :: b
                       }
                   deriving Show

        but got: Right
                 {-# LANGUAGE ScopedTypeVariables #-}
                 data MyRecord = forall a b
                 . ( Loooooooooooooooooooooooooooooooong a
                   , Loooooooooooooooooooooooooooooooong b
                   ) =>
                   MyConstructor
                     { foo, foo2
                         :: loooooooooooooooooooooooooooooooong
                         -> loooooooooooooooooooooooooooooooong
                     , bar  :: a
                     , bazz :: b
                     }
                   deriving Show

  6) data type declarations single record existential
       expected: Right
                 {-# LANGUAGE ExistentialQuantification #-}
                 data Foo = forall a . Show a => Bar
                   { foo :: a
                   }

        but got: Right
                 {-# LANGUAGE ExistentialQuantification #-}
                 data Foo = forall a
                 . Show a =>
                   Bar
                     { foo :: a
                     }

  7) data type declarations record multiple types existential
       expected: Right
                 {-# LANGUAGE ExistentialQuantification #-}
                 data Foo = forall a b . (Show a, Eq b) => Bar
                   { foo  :: a
                   , bars :: b
                   }

        but got: Right
                 {-# LANGUAGE ExistentialQuantification #-}
                 data Foo = forall a b
                 . (Show a, Eq b) =>
                   Bar
                     { foo  :: a
                     , bars :: b
                     }

  8) data type declarations record newline comment
       expected: Right
                 data MyRecord = MyRecord
                   { a :: Int
                     -- comment
                   , b :: Int
                   }

        but got: Right
                 data MyRecord = MyRecord
                   { a :: Int
                 -- comment
                   , b :: Int
                   }

  9) data type declarations comment before equal sign
       expected: Right
                 {-# LANGUAGE ExistentialQuantification #-}
                 data MyRecord
                   -- test comment
                   = forall a b
                   . ( Loooooooooooooooooooooooooooooooong a
                     , Loooooooooooooooooooooooooooooooong b
                     ) =>
                     MyConstructor a b

        but got: Right
                 {-# LANGUAGE ExistentialQuantification #-}
                 data MyRecord
                   -- test comment
                                = forall a b
                 . ( Loooooooooooooooooooooooooooooooong a
                   , Loooooooooooooooooooooooooooooooong b
                   ) =>
                   MyConstructor a b

  10) data type declarations large record with a comment
       expected: Right
                 data XIILqcacwiuNiu = XIILqcacwiuNiu
                   { oyyFtvbepgbOge_pebzVmuftEijwuj     :: Jgtoyuh HessJvNlo
                   , wloQsiskdoxJop_xatiKrwedOxtu       :: Jgtoyuh [Inotg]
                   , mmmJjcqtemyIyo_ovosDoreKeeoyamvove :: Jgtoyuh Eujo
                   , mbiIatelofxOzr_uluxNngiiMjah       :: Jgtoyuh HessJvNlo
                   , obxIskfcxpkIkb_uuviTuevcSkrgo      :: Jgtoyuh Int
                   , wqrAtuvuecoHwr_ilotNxbuPleo        :: Jgtoyuh Ufaxdeq
                   , lofAfuebdhpLuv_cnekPoyFxmg         :: Jgtoyuh Ufaxdeq
                   , ouoFugtawzvUpk_oupiLzptugy         :: Jgtoyuh Eujo
                   , iqiXjtziwogNsa_uiyvSunaTtgUsf3     :: Jgtoyuh Oaivn
                   , odbIriaqnojUlz_onotoWuunehIpuy     :: Jgtoyuh Eujo
                   , opjUxtkxzkiKse_luqjuZazt
                       :: Jgtoyuh [(Eujo, Int, Int, Int, Int, Int, NELUxro)]
                   -- , jcqRaqznxfhIpa_ywevMezmoYkutuwa        :: Jgtoyuh ()
                   , vayOmuasyphOfd_bcsVljmvt               :: Jgtoyuh Eujo
                   , rifArahilooRax_ufikecqdImsv            :: Jgtoyuh Oaivn
                   , raqKtopcpszDwb_oqocubasZuqjcryoDojGkw  :: Jgtoyuh Oaivn
                   , mluJiilpcijUtt_gaisklifVekfeyagRmfbyzz :: Jgtoyuh Oaivn
                   , oqhPaahjupaSmi_gamwwoovKyxznecvEayluc  :: Jgtoyuh Oaivn
                   , mazFubimwebZpa_itidehDodiDlboz         :: Jgtoyuh Vrep
                   , jeyOcuesexaYoy_vpqn                    :: Jgtoyuh ()
                   }

        but got: Right
                 data XIILqcacwiuNiu = XIILqcacwiuNiu
                   { oyyFtvbepgbOge_pebzVmuftEijwuj     :: Jgtoyuh HessJvNlo
                   , wloQsiskdoxJop_xatiKrwedOxtu       :: Jgtoyuh [Inotg]
                   , mmmJjcqtemyIyo_ovosDoreKeeoyamvove :: Jgtoyuh Eujo
                   , mbiIatelofxOzr_uluxNngiiMjah       :: Jgtoyuh HessJvNlo
                   , obxIskfcxpkIkb_uuviTuevcSkrgo      :: Jgtoyuh Int
                   , wqrAtuvuecoHwr_ilotNxbuPleo        :: Jgtoyuh Ufaxdeq
                   , lofAfuebdhpLuv_cnekPoyFxmg         :: Jgtoyuh Ufaxdeq
                   , ouoFugtawzvUpk_oupiLzptugy         :: Jgtoyuh Eujo
                   , iqiXjtziwogNsa_uiyvSunaTtgUsf3     :: Jgtoyuh Oaivn
                   , odbIriaqnojUlz_onotoWuunehIpuy     :: Jgtoyuh Eujo
                   , opjUxtkxzkiKse_luqjuZazt
                       :: Jgtoyuh [(Eujo, Int, Int, Int, Int, Int, NELUxro)]
                 -- , jcqRaqznxfhIpa_ywevMezmoYkutuwa        :: Jgtoyuh ()
                   , vayOmuasyphOfd_bcsVljmvt               :: Jgtoyuh Eujo
                   , rifArahilooRax_ufikecqdImsv            :: Jgtoyuh Oaivn
                   , raqKtopcpszDwb_oqocubasZuqjcryoDojGkw  :: Jgtoyuh Oaivn
                   , mluJiilpcijUtt_gaisklifVekfeyagRmfbyzz :: Jgtoyuh Oaivn
                   , oqhPaahjupaSmi_gamwwoovKyxznecvEayluc  :: Jgtoyuh Oaivn
                   , mazFubimwebZpa_itidehDodiDlboz         :: Jgtoyuh Vrep
                   , jeyOcuesexaYoy_vpqn                    :: Jgtoyuh ()
                   }

  11) data type declarations records in sum
       expected: Right
                 -- brittany {lconfig_indentPolicy: IndentPolicyLeft }
                 data Foo
                   = Bar
                     { foo :: Int -- hello
                     , bar :: Foo
                     -- how are you
                     }
                   | Baz
                   | Biz
                     { foo :: Int
                     , bar :: Foo
                     }

        but got: Right
                 -- brittany {lconfig_indentPolicy: IndentPolicyLeft }
                 data Foo
                   = Bar
                     { foo :: Int -- hello
                     , bar :: Foo
                 -- how are you
                     }
                   | Baz
                   | Biz
                     { foo :: Int
                     , bar :: Foo
                     }
```
2020-04-10 10:59:00 -05:00
..
10-tests.blt First pass at sum types 2020-04-10 10:59:00 -05:00
14-extensions.blt Disable one test-case for ghc-8.0 (unsupported syntax) 2020-03-22 22:44:13 +01:00
15-regressions.blt Fix comments in instance/type instances (#282) 2020-03-23 16:51:30 +01:00
16-pending.blt Split up littests input into multiple files 2017-10-02 20:53:56 +02:00
30-tests-context-free.blt Improve data decl layouting 2019-12-09 11:20:28 -07:00
40-indent-policy-multiple.blt Fix IndentPolicyMultiple for indentAmount>4 2018-05-01 23:21:09 +02:00
Main.hs Remove dependency on neat-interpolation 2020-02-04 16:14:38 +01:00