@@ -1934,6 +1934,28 @@ addFunctionConstraintTests = let
1934
1934
, " eq x y = x == y"
1935
1935
]
1936
1936
1937
+ missingConstraintWithForAllSourceCode :: T. Text -> T. Text
1938
+ missingConstraintWithForAllSourceCode constraint =
1939
+ T. unlines
1940
+ [ " {-# LANGUAGE ExplicitForAll #-}"
1941
+ , " module Testing where"
1942
+ , " "
1943
+ , " eq :: forall a. " <> constraint <> " a -> a -> Bool"
1944
+ , " eq x y = x == y"
1945
+ ]
1946
+
1947
+ incompleteConstraintWithForAllSourceCode :: T. Text -> T. Text
1948
+ incompleteConstraintWithForAllSourceCode constraint =
1949
+ T. unlines
1950
+ [ " {-# LANGUAGE ExplicitForAll #-}"
1951
+ , " module Testing where"
1952
+ , " "
1953
+ , " data Pair a b = Pair a b"
1954
+ , " "
1955
+ , " eq :: " <> constraint <> " => Pair a b -> Pair a b -> Bool"
1956
+ , " eq (Pair x y) (Pair x' y') = x == x' && y == y'"
1957
+ ]
1958
+
1937
1959
incompleteConstraintSourceCode :: T. Text -> T. Text
1938
1960
incompleteConstraintSourceCode constraint =
1939
1961
T. unlines
@@ -1982,7 +2004,7 @@ addFunctionConstraintTests = let
1982
2004
check actionTitle originalCode expectedCode = testSession (T. unpack actionTitle) $ do
1983
2005
doc <- createDoc " Testing.hs" " haskell" originalCode
1984
2006
_ <- waitForDiagnostics
1985
- actionsOrCommands <- getCodeActions doc (Range (Position 6 0 ) (Position 6 maxBound ))
2007
+ actionsOrCommands <- getCodeActions doc (Range (Position 0 0 ) (Position 6 maxBound ))
1986
2008
chosenAction <- liftIO $ pickActionWithTitle actionTitle actionsOrCommands
1987
2009
executeCodeAction chosenAction
1988
2010
modifiedCode <- documentContents doc
@@ -1993,6 +2015,10 @@ addFunctionConstraintTests = let
1993
2015
" Add `Eq a` to the context of the type signature for `eq`"
1994
2016
(missingConstraintSourceCode " " )
1995
2017
(missingConstraintSourceCode " Eq a => " )
2018
+ , check
2019
+ " Add `Eq a` to the context of the type signature for `eq`"
2020
+ (missingConstraintWithForAllSourceCode " " )
2021
+ (missingConstraintWithForAllSourceCode " Eq a => " )
1996
2022
, check
1997
2023
" Add `Eq b` to the context of the type signature for `eq`"
1998
2024
(incompleteConstraintSourceCode " Eq a" )
@@ -2001,6 +2027,10 @@ addFunctionConstraintTests = let
2001
2027
" Add `Eq c` to the context of the type signature for `eq`"
2002
2028
(incompleteConstraintSourceCode2 " (Eq a, Eq b)" )
2003
2029
(incompleteConstraintSourceCode2 " (Eq a, Eq b, Eq c)" )
2030
+ , check
2031
+ " Add `Eq b` to the context of the type signature for `eq`"
2032
+ (incompleteConstraintWithForAllSourceCode " Eq a" )
2033
+ (incompleteConstraintWithForAllSourceCode " (Eq a, Eq b)" )
2004
2034
, check
2005
2035
" Add `Eq b` to the context of the type signature for `eq`"
2006
2036
(incompleteConstraintSourceCodeWithExtraCharsInContext " ( Eq a )" )
0 commit comments