Skip to content

Commit 3a6874d

Browse files
committed
Add more tests for checking formatting
1 parent 4fe0f7d commit 3a6874d

10 files changed

+42
-8
lines changed

test/functional/Format.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ rangeTests :: TestTree
4242
rangeTests = testGroup "format range" [
4343
goldenVsStringDiff "works" goldenGitDiff "test/testdata/Format.formatted_range.hs" $ runSession hieCommand fullCaps "test/testdata" $ do
4444
doc <- openDoc "Format.hs" "haskell"
45-
formatRange doc (FormattingOptions 2 True) (Range (Position 1 0) (Position 3 10))
45+
formatRange doc (FormattingOptions 2 True) (Range (Position 5 0) (Position 7 10))
4646
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
4747
, goldenVsStringDiff "works with custom tab size" goldenGitDiff "test/testdata/Format.formatted_range_with_tabsize.hs" $ runSession hieCommand fullCaps "test/testdata" $ do
4848
doc <- openDoc "Format.hs" "haskell"
49-
formatRange doc (FormattingOptions 5 True) (Range (Position 4 0) (Position 7 19))
49+
formatRange doc (FormattingOptions 5 True) (Range (Position 8 0) (Position 11 19))
5050
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
5151
]
5252

test/testdata/Format.brittany.formatted.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
module Format where
2+
import Data.List
3+
4+
import Prelude
5+
import Data.Int
26
foo :: Int -> Int
37
foo 3 = 2
48
foo x = x

test/testdata/Format.brittany_post_floskell.formatted.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
module Format where
22

3+
import Data.List
4+
import Prelude
5+
import Data.Int
6+
37
foo :: Int -> Int
48
foo 3 = 2
59
foo x = x

test/testdata/Format.floskell.formatted.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
module Format where
22

3+
import Data.List
4+
import Prelude
5+
import Data.Int
6+
37
foo :: Int -> Int
48
foo 3 = 2
59
foo x = x

test/testdata/Format.formatted_document.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
module Format where
22

3+
import Data.Int
4+
import Data.List
5+
import Prelude
6+
37
foo :: Int -> Int
48
foo 3 = 2
59
foo x = x
10+
611
bar :: String -> IO String
712
bar s = do
813
x <- return "hello"
914
return "asdf"
1015

1116
data Baz = Baz {a :: Int, b :: String}
12-

test/testdata/Format.formatted_document_with_tabsize.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
module Format where
22

3+
import Data.Int
4+
import Data.List
5+
import Prelude
6+
37
foo :: Int -> Int
48
foo 3 = 2
59
foo x = x
10+
611
bar :: String -> IO String
712
bar s = do
813
x <- return "hello"
914
return "asdf"
1015

1116
data Baz = Baz {a :: Int, b :: String}
12-

test/testdata/Format.formatted_range.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
module Format where
1+
module Format where
2+
import Data.List
23

4+
import Prelude
5+
import Data.Int
36
foo :: Int -> Int
47
foo 3 = 2
58
foo x = x
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
module Format where
2+
import Data.List
3+
4+
import Prelude
5+
import Data.Int
26
foo :: Int -> Int
37
foo 3 = 2
4-
foo x = x
8+
foo x = x
59
bar :: String -> IO String
610
bar s = do
711
x <- return "hello"
812
return "asdf"
913

10-
1114
data Baz = Baz { a :: Int, b :: String }
1215

test/testdata/Format.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
module Format where
2+
import Data.List
3+
4+
import Prelude
5+
import Data.Int
26
foo :: Int -> Int
37
foo 3 = 2
48
foo x = x

test/testdata/Format.ormolu.formatted.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
module Format where
22

3+
import Data.Int
4+
import Data.List
5+
import Prelude
6+
37
foo :: Int -> Int
48
foo 3 = 2
59
foo x = x
10+
611
bar :: String -> IO String
712
bar s = do
813
x <- return "hello"
914
return "asdf"
1015

1116
data Baz = Baz {a :: Int, b :: String}
12-

0 commit comments

Comments
 (0)