Skip to content

Commit 24493db

Browse files
committed
feat(test): add a repro for 4648
1 parent 29b2ecb commit 24493db

File tree

1 file changed

+25
-0
lines changed
  • plugins/hls-refactor-plugin/test

1 file changed

+25
-0
lines changed

plugins/hls-refactor-plugin/test/Main.hs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3036,6 +3036,26 @@ addFunctionConstraintTests = let
30363036
, "eq (Pair x y) (Pair x' y') = x == x' && y == y'"
30373037
]
30383038

3039+
-- See https://github.com/haskell/haskell-language-server/issues/4648
3040+
-- When haddock comment appears after the =>, code action was introducing the
3041+
-- new constraint in the comment
3042+
incompleteConstraintSourceCodeWithCommentInTypeSignature :: T.Text -> T.Text
3043+
incompleteConstraintSourceCodeWithCommentInTypeSignature constraint =
3044+
T.unlines
3045+
[ "module Testing where"
3046+
, "data Pair a b = Pair a b"
3047+
, "eq "
3048+
, " :: (" <> constraint <> ")"
3049+
, " =>"
3050+
, " -- This is the first argument"
3051+
, " Pair a b ->"
3052+
, " -- And this is the second"
3053+
, " Pair a b ->"
3054+
, " -- And this is the result"
3055+
, " Bool"
3056+
, "eq (Pair x y) (Pair x' y') = x == x' && y == y'"
3057+
]
3058+
30393059
missingMonadConstraint constraint = T.unlines
30403060
[ "module Testing where"
30413061
, "f :: " <> constraint <> "m ()"
@@ -3079,6 +3099,11 @@ addFunctionConstraintTests = let
30793099
"Add `Eq b` to the context of the type signature for `eq`"
30803100
(incompleteConstraintSourceCodeWithNewlinesInTypeSignature "Eq a")
30813101
(incompleteConstraintSourceCodeWithNewlinesInTypeSignature "Eq a, Eq b")
3102+
, checkCodeAction
3103+
"preexisting constraint, with haddock comment in type signature"
3104+
"Add `Eq b` to the context of the type signature for `eq`"
3105+
(incompleteConstraintSourceCodeWithCommentInTypeSignature "Eq a")
3106+
(incompleteConstraintSourceCodeWithCommentInTypeSignature "Eq a, Eq b")
30823107
, checkCodeAction
30833108
"missing Monad constraint"
30843109
"Add `Monad m` to the context of the type signature for `f`"

0 commit comments

Comments
 (0)