From 3f4edcce319c3dafd1d1309b281625beb854e8a7 Mon Sep 17 00:00:00 2001 From: Maxim Koltsov Date: Mon, 5 Oct 2020 01:53:26 +0300 Subject: Fix "group" import sort with multi-line imports When some import line spans multuple lines, e.g. when import list is long, stylish-haskell breaks a group at this line, leading to bad result. This commits makes sure that import groups are recognized solely by empty lines. --- .../Language/Haskell/Stylish/Step/Imports/Tests.hs | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs b/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs index bb56bab..fea3b78 100644 --- a/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs +++ b/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs @@ -59,6 +59,7 @@ tests = testGroup "Language.Haskell.Stylish.Step.Imports.Tests" , testCase "case 26 (issue 185)" case26 , testCase "case 27" case27 , testCase "case 28" case28 + , testCase "case 29" case29 ] @@ -911,3 +912,25 @@ case28 = expected @=? testSnippet (step (Just 80) $ fromImportAlign Global) inpu , "import Data.Set (empty, intersect)" , "import Data.Set (empty, nub)" ] + + +-------------------------------------------------------------------------------- +case29 :: Assertion +case29 = expected @=? testSnippet (step Nothing $ fromImportAlign Group) input' + where + -- Check that "Group" mode recognizes groups with multi-line imports + input' = Snippet + [ "import Foo (foo)" + , "import BarBar ( bar" + , " , kek)" + , "import Abcd ()" + , "" + , "import A (A)" + ] + expected = Snippet + [ "import Abcd ()" + , "import BarBar (bar, kek)" + , "import Foo (foo)" + , "" + , "import A (A)" + ] \ No newline at end of file -- cgit v1.2.3