@@ -2784,13 +2784,39 @@ removeRedundantConstraintsTests = let
2784
2784
, " in h"
2785
2785
]
2786
2786
2787
- typeSignatureMultipleLines :: T. Text
2788
- typeSignatureMultipleLines = T. unlines $ header <>
2789
- [ " foo :: (Num a, Eq a, Monoid a)"
2790
- , " => a -> Bool"
2791
- , " foo x = x == 1"
2787
+ typeSignatureLined1 = T. unlines $ header <>
2788
+ [ " foo :: Eq a =>"
2789
+ , " a -> Bool"
2790
+ , " foo _ = True"
2792
2791
]
2793
2792
2793
+ typeSignatureLined2 = T. unlines $ header <>
2794
+ [ " foo :: (Eq a, Show a)"
2795
+ , " => a -> Bool"
2796
+ , " foo _ = True"
2797
+ ]
2798
+
2799
+ typeSignatureOneLine = T. unlines $ header <>
2800
+ [ " foo :: a -> Bool"
2801
+ , " foo _ = True"
2802
+ ]
2803
+
2804
+ typeSignatureLined3 = T. unlines $ header <>
2805
+ [ " foo :: ( Eq a"
2806
+ , " , Show a"
2807
+ , " )"
2808
+ , " => a -> Bool"
2809
+ , " foo x = x == x"
2810
+ ]
2811
+
2812
+ typeSignatureLined3' = T. unlines $ header <>
2813
+ [ " foo :: ( Eq a"
2814
+ , " )"
2815
+ , " => a -> Bool"
2816
+ , " foo x = x == x"
2817
+ ]
2818
+
2819
+
2794
2820
check :: T. Text -> T. Text -> T. Text -> TestTree
2795
2821
check actionTitle originalCode expectedCode = testSession (T. unpack actionTitle) $ do
2796
2822
doc <- createDoc " Testing.hs" " haskell" originalCode
@@ -2801,13 +2827,6 @@ removeRedundantConstraintsTests = let
2801
2827
modifiedCode <- documentContents doc
2802
2828
liftIO $ expectedCode @=? modifiedCode
2803
2829
2804
- checkPeculiarFormatting :: String -> T. Text -> TestTree
2805
- checkPeculiarFormatting title code = testSession title $ do
2806
- doc <- createDoc " Testing.hs" " haskell" code
2807
- _ <- waitForDiagnostics
2808
- actionsOrCommands <- getAllCodeActions doc
2809
- liftIO $ assertBool " Found some actions" (null actionsOrCommands)
2810
-
2811
2830
in testGroup " remove redundant function constraints"
2812
2831
[ check
2813
2832
" Remove redundant constraint `Eq a` from the context of the type signature for `foo`"
@@ -2845,9 +2864,18 @@ removeRedundantConstraintsTests = let
2845
2864
" Remove redundant constraints `(Monoid a, Show a)` from the context of the type signature for `foo`"
2846
2865
(typeSignatureSpaces $ Just " Monoid a, Show a" )
2847
2866
(typeSignatureSpaces Nothing )
2848
- , checkPeculiarFormatting
2849
- " should do nothing when constraints contain line feeds"
2850
- typeSignatureMultipleLines
2867
+ , check
2868
+ " Remove redundant constraint `Eq a` from the context of the type signature for `foo`"
2869
+ typeSignatureLined1
2870
+ typeSignatureOneLine
2871
+ , check
2872
+ " Remove redundant constraints `(Eq a, Show a)` from the context of the type signature for `foo`"
2873
+ typeSignatureLined2
2874
+ typeSignatureOneLine
2875
+ , check
2876
+ " Remove redundant constraint `Show a` from the context of the type signature for `foo`"
2877
+ typeSignatureLined3
2878
+ typeSignatureLined3'
2851
2879
]
2852
2880
2853
2881
addSigActionTests :: TestTree
0 commit comments