Skip to content

Commit dc4e674

Browse files
committed
feat(test): add a repro for 4648
1 parent ed37a9e commit dc4e674

File tree

1 file changed

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

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3036,6 +3036,21 @@ 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+
3046+
[ "module Testing where"
3047+
, "foo "
3048+
, " :: (" <> constraint <> ") =>"
3049+
, " -- This is a comment"
3050+
, " m ()"
3051+
, "foo = pure ()"
3052+
]
3053+
30393054
missingMonadConstraint constraint = T.unlines
30403055
[ "module Testing where"
30413056
, "f :: " <> constraint <> "m ()"
@@ -3079,6 +3094,11 @@ addFunctionConstraintTests = let
30793094
"Add `Eq b` to the context of the type signature for `eq`"
30803095
(incompleteConstraintSourceCodeWithNewlinesInTypeSignature "Eq a")
30813096
(incompleteConstraintSourceCodeWithNewlinesInTypeSignature "Eq a, Eq b")
3097+
, checkCodeAction
3098+
"preexisting constraint, with haddock comment in type signature"
3099+
"Add `Applicative m` to the context of the type signature for `foo`"
3100+
(incompleteConstraintSourceCodeWithCommentInTypeSignature "")
3101+
(incompleteConstraintSourceCodeWithCommentInTypeSignature "Applicative m")
30823102
, checkCodeAction
30833103
"missing Monad constraint"
30843104
"Add `Monad m` to the context of the type signature for `f`"

0 commit comments

Comments
 (0)