Skip to content

Commit 6c9d845

Browse files
committed
Merge pull request #1073 from gracjan/pr-indentation-more-tests
Add some tests for indentation
2 parents 322782e + fa932e9 commit 6c9d845

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

tests/haskell-indentation-tests.el

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,18 @@ fun = [ f | x ← xs
223223
(4 10)
224224
(5 0))
225225

226+
(hindent-test "6b \"let\" in do""
227+
fact n = do
228+
let g = 7
229+
z <- let x = 5
230+
in return (x + 4)"
231+
(1 0)
232+
(2 2)
233+
(3 2 6 8)
234+
(4 7)
235+
(5 2 10))
236+
237+
226238
(hindent-test "7a \"data\" after \"data\"""
227239
data ABC = ABC
228240
data DEF = DEF"
@@ -758,6 +770,18 @@ fact n =
758770
(4 0 2 4 6)
759771
(5 0 2 4 6))
760772

773+
(hindent-test "46b case expression with guards" "
774+
fact n = case n of
775+
n | n == 0 -> 1
776+
_ | n > 0
777+
, True == True -> n * fact (n - 1)"
778+
(1 0)
779+
(2 2)
780+
;; returns (0 2 2 6), to investigate
781+
(3 0 2 6)
782+
(4 4)
783+
(5 0 2 6))
784+
761785
(hindent-test "47a multiline strings" "
762786
fact n = \"\\
763787
\\a\""
@@ -777,6 +801,84 @@ fact n = \"\\
777801
(2 0 9)
778802
(3 6))
779803

804+
(hindent-test "48 functional dependencies" "
805+
class X a b | a -> b
806+
, b -> a where
807+
fun :: a -> b"
808+
(1 0)
809+
(2 12)
810+
(3 2)
811+
(4 0 2 9))
812+
813+
(hindent-test "49 data with GADT syntax" "
814+
data Term a where
815+
Lit :: Int -> Term Int
816+
Pair :: Term a -> Term b -> Term (a,b)"
817+
(1 0)
818+
(2 2)
819+
(3 0 2 9)
820+
(4 0 2 10))
821+
822+
(hindent-test "49b* data with GADT syntax and a deriving clause" "
823+
data G [a] b where
824+
G1 :: c -> G [Int] b
825+
deriving (Eq)"
826+
(1 0)
827+
(2 2)
828+
(3 0 2))
829+
830+
(hindent-test "50* standalone deriving" "
831+
data Name = Name String
832+
deriving instance Eq Name"
833+
(1 0)
834+
;; We accept position 2 here because we have just one
835+
;; look-ahead token so we do not see 'instance'
836+
;; following 'deriving'.
837+
(2 0 2))
838+
839+
(hindent-test "51 standalone deriving" "
840+
data family T a
841+
data instance T Int = T1 Int | T2 Bool
842+
newtype instance T Char = TC Bool"
843+
;; We check that indentation does not bail on 'instance'
844+
;; here, we do not really check if it is working
845+
;; correctly. Needs better test.
846+
(1 0)
847+
(2 0)
848+
(3 0)
849+
(4 0 2))
850+
851+
(hindent-test "52a* module simplest case two lines" "
852+
module A.B
853+
where"
854+
(1 0)
855+
(2 0)
856+
(3 0))
857+
858+
(hindent-test "52b module simplest case one line" "
859+
module A.B where"
860+
(1 0)
861+
(2 0))
862+
863+
(hindent-test "52c* module with exports" "
864+
module A.B
865+
( x
866+
, y
867+
)
868+
where"
869+
(1 0)
870+
(2 2)
871+
(3 2)
872+
(4 2)
873+
(5 0)
874+
(6 0))
875+
876+
(hindent-test "53 multiway if" "
877+
fun = if | guard1 -> expr1
878+
| guardN -> exprN"
879+
(1 0)
880+
(2 9)
881+
(3 0 11))
780882

781883
(defmacro with-temp-switch-to-buffer (&rest body)
782884
"Create a temporary buffer, use `switch-to-buffer' and evaluate BODY there like `progn'.

0 commit comments

Comments
 (0)