@@ -1006,7 +1006,10 @@ suggestImportTests = testGroup "suggest import actions"
1006
1006
, test False [] " f = quickCheck" [] " import Test.QuickCheck (quickCheck)"
1007
1007
]
1008
1008
, testGroup " want suggestion"
1009
- [ test True [] " f = nonEmpty" [] " import Data.List.NonEmpty (nonEmpty)"
1009
+ [ test True [] " f = foo" [] " import Foo (foo)"
1010
+ , test True [] " f = Bar" [] " import Bar (Bar(Bar))"
1011
+ , test True [] " f :: Bar" [] " import Bar (Bar)"
1012
+ , test True [] " f = nonEmpty" [] " import Data.List.NonEmpty (nonEmpty)"
1010
1013
, test True [] " f = (:|)" [] " import Data.List.NonEmpty (NonEmpty((:|)))"
1011
1014
, test True [] " f :: Natural" [" f = undefined" ] " import Numeric.Natural (Natural)"
1012
1015
, test True [] " f :: NonEmpty ()" [" f = () :| []" ] " import Data.List.NonEmpty (NonEmpty)"
@@ -1028,12 +1031,13 @@ suggestImportTests = testGroup "suggest import actions"
1028
1031
]
1029
1032
]
1030
1033
where
1031
- test wanted imps def other newImp = testSession' (T. unpack def) $ \ dir -> do
1034
+ test wanted imps def other newImp = testSessionWithExtraFiles " hover " (T. unpack def) $ \ dir -> do
1032
1035
let before = T. unlines $ " module A where" : [" import " <> x | x <- imps] ++ def : other
1033
1036
after = T. unlines $ " module A where" : [" import " <> x | x <- imps] ++ [newImp] ++ def : other
1034
- cradle = " cradle: {direct: {arguments: [-hide-all-packages, -package, base, -package, text, -package-env, -]}}"
1037
+ cradle = " cradle: {direct: {arguments: [-hide-all-packages, -package, base, -package, text, -package-env, -, A, Bar, Foo, GotoHover ]}}"
1035
1038
liftIO $ writeFileUTF8 (dir </> " hie.yaml" ) cradle
1036
1039
doc <- createDoc " Test.hs" " haskell" before
1040
+ void (skipManyTill anyMessage message :: Session WorkDoneProgressEndNotification )
1037
1041
_diags <- waitForDiagnostics
1038
1042
let defLine = length imps + 1
1039
1043
range = Range (Position defLine 0 ) (Position defLine maxBound )
@@ -1672,8 +1676,8 @@ exportUnusedTests = testGroup "export unused actions"
1672
1676
Nothing -- codeaction should not be available
1673
1677
, testSession " not top-level" $ template
1674
1678
(T. unlines
1675
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1676
- , " {-# OPTIONS_GHC -Wunused-binds #-}"
1679
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1680
+ , " {-# OPTIONS_GHC -Wunused-binds #-}"
1677
1681
, " module A (foo,bar) where"
1678
1682
, " foo = ()"
1679
1683
, " where bar = ()"
@@ -1708,26 +1712,26 @@ exportUnusedTests = testGroup "export unused actions"
1708
1712
(R 3 0 3 3 )
1709
1713
" Export ‘foo’"
1710
1714
(Just $ T. unlines
1711
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1715
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1712
1716
, " module A ("
1713
1717
, " foo) where"
1714
1718
, " foo = id" ])
1715
1719
, testSession " single line explicit exports" $ template
1716
1720
(T. unlines
1717
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1721
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1718
1722
, " module A (foo) where"
1719
1723
, " foo = id"
1720
1724
, " bar = foo" ])
1721
1725
(R 3 0 3 3 )
1722
1726
" Export ‘bar’"
1723
1727
(Just $ T. unlines
1724
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1728
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1725
1729
, " module A (foo,bar) where"
1726
1730
, " foo = id"
1727
1731
, " bar = foo" ])
1728
1732
, testSession " multi line explicit exports" $ template
1729
1733
(T. unlines
1730
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1734
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1731
1735
, " module A"
1732
1736
, " ("
1733
1737
, " foo) where"
@@ -1736,15 +1740,15 @@ exportUnusedTests = testGroup "export unused actions"
1736
1740
(R 5 0 5 3 )
1737
1741
" Export ‘bar’"
1738
1742
(Just $ T. unlines
1739
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1743
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1740
1744
, " module A"
1741
1745
, " ("
1742
1746
, " foo,bar) where"
1743
1747
, " foo = id"
1744
1748
, " bar = foo" ])
1745
1749
, testSession " export list ends in comma" $ template
1746
1750
(T. unlines
1747
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1751
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1748
1752
, " module A"
1749
1753
, " (foo,"
1750
1754
, " ) where"
@@ -1753,91 +1757,91 @@ exportUnusedTests = testGroup "export unused actions"
1753
1757
(R 4 0 4 3 )
1754
1758
" Export ‘bar’"
1755
1759
(Just $ T. unlines
1756
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1760
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1757
1761
, " module A"
1758
1762
, " (foo,"
1759
1763
, " bar) where"
1760
1764
, " foo = id"
1761
1765
, " bar = foo" ])
1762
1766
, testSession " unused pattern synonym" $ template
1763
1767
(T. unlines
1764
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1765
- , " {-# LANGUAGE PatternSynonyms #-}"
1768
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1769
+ , " {-# LANGUAGE PatternSynonyms #-}"
1766
1770
, " module A () where"
1767
1771
, " pattern Foo a <- (a, _)" ])
1768
1772
(R 3 0 3 10 )
1769
1773
" Export ‘Foo’"
1770
1774
(Just $ T. unlines
1771
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1772
- , " {-# LANGUAGE PatternSynonyms #-}"
1775
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1776
+ , " {-# LANGUAGE PatternSynonyms #-}"
1773
1777
, " module A (pattern Foo) where"
1774
1778
, " pattern Foo a <- (a, _)" ])
1775
1779
, testSession " unused data type" $ template
1776
1780
(T. unlines
1777
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1781
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1778
1782
, " module A () where"
1779
1783
, " data Foo = Foo" ])
1780
1784
(R 2 0 2 7 )
1781
1785
" Export ‘Foo’"
1782
1786
(Just $ T. unlines
1783
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1787
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1784
1788
, " module A (Foo(..)) where"
1785
1789
, " data Foo = Foo" ])
1786
1790
, testSession " unused newtype" $ template
1787
1791
(T. unlines
1788
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1792
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1789
1793
, " module A () where"
1790
1794
, " newtype Foo = Foo ()" ])
1791
1795
(R 2 0 2 10 )
1792
1796
" Export ‘Foo’"
1793
1797
(Just $ T. unlines
1794
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1798
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1795
1799
, " module A (Foo(..)) where"
1796
1800
, " newtype Foo = Foo ()" ])
1797
1801
, testSession " unused type synonym" $ template
1798
1802
(T. unlines
1799
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1803
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1800
1804
, " module A () where"
1801
1805
, " type Foo = ()" ])
1802
1806
(R 2 0 2 7 )
1803
1807
" Export ‘Foo’"
1804
1808
(Just $ T. unlines
1805
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1809
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1806
1810
, " module A (Foo) where"
1807
1811
, " type Foo = ()" ])
1808
1812
, testSession " unused type family" $ template
1809
1813
(T. unlines
1810
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1811
- , " {-# LANGUAGE TypeFamilies #-}"
1814
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1815
+ , " {-# LANGUAGE TypeFamilies #-}"
1812
1816
, " module A () where"
1813
1817
, " type family Foo p" ])
1814
1818
(R 3 0 3 15 )
1815
1819
" Export ‘Foo’"
1816
1820
(Just $ T. unlines
1817
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1818
- , " {-# LANGUAGE TypeFamilies #-}"
1821
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1822
+ , " {-# LANGUAGE TypeFamilies #-}"
1819
1823
, " module A (Foo(..)) where"
1820
1824
, " type family Foo p" ])
1821
1825
, testSession " unused typeclass" $ template
1822
1826
(T. unlines
1823
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1827
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1824
1828
, " module A () where"
1825
1829
, " class Foo a" ])
1826
1830
(R 2 0 2 8 )
1827
1831
" Export ‘Foo’"
1828
1832
(Just $ T. unlines
1829
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1833
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1830
1834
, " module A (Foo(..)) where"
1831
1835
, " class Foo a" ])
1832
1836
, testSession " infix" $ template
1833
1837
(T. unlines
1834
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1838
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1835
1839
, " module A () where"
1836
1840
, " a `f` b = ()" ])
1837
1841
(R 2 0 2 11 )
1838
1842
" Export ‘f’"
1839
1843
(Just $ T. unlines
1840
- [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1844
+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
1841
1845
, " module A (f) where"
1842
1846
, " a `f` b = ()" ])
1843
1847
]
@@ -2260,6 +2264,7 @@ thTests =
2260
2264
-- | test that TH is reevaluated on typecheck
2261
2265
thReloadingTest :: TestTree
2262
2266
thReloadingTest = testCase " reloading-th-test" $ withoutStackEnv $ runWithExtraFiles " TH" $ \ dir -> do
2267
+
2263
2268
let aPath = dir </> " THA.hs"
2264
2269
bPath = dir </> " THB.hs"
2265
2270
cPath = dir </> " THC.hs"
0 commit comments