Skip to content

Commit 2220dd7

Browse files
committed
More tail and init, fix module name
1 parent 91419bb commit 2220dd7

File tree

6 files changed

+11
-13
lines changed

6 files changed

+11
-13
lines changed

.hlint.yaml

+1-5
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@
122122
- Development.IDE.Plugin.CodeAction.ExactPrint
123123
- Development.IDE.Session
124124
- UnificationSpec
125-
- WatchedFileTests #Previously part of GHCIDE Main tests
126125

127126
- name: [Prelude.last, Data.List.last]
128127
within:
@@ -142,10 +141,7 @@
142141
- Development.IDE.Spans.Common
143142
- Ide.PluginUtils
144143
- Development.Benchmark.Rules
145-
- ErrorGivenPartialSignature
146-
- IfaceTests #Previously part of GHCIDE Main tests
147-
- THTests #Previously part of GHCIDE Main tests
148-
- WatchedFileTests #Previously part of GHCIDE Main tests
144+
- TErrorGivenPartialSignature
149145

150146
- name: Data.List.foldl1'
151147
within: []

ghcide/test/exe/IfaceTests.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
module IfaceTests (tests) where
55

66
import Control.Monad.IO.Class (liftIO)
7+
import Data.List.Extra (dropEnd1)
78
import Data.Row
89
import qualified Data.Text as T
910
import Development.IDE.GHC.Util
@@ -49,7 +50,7 @@ ifaceTHTest = testCase "iface-th-test" $ runWithExtraFiles "TH" $ \dir -> do
4950
cdoc <- createDoc cPath "haskell" cSource
5051

5152
-- Change [TH]a from () to Bool
52-
liftIO $ writeFileUTF8 aPath (unlines $ init (lines $ T.unpack aSource) ++ ["th_a = [d| a = False|]"])
53+
liftIO $ writeFileUTF8 aPath (T.unpack $ T.unlines $ dropEnd1 (T.lines aSource) ++ ["th_a = [d| a = False|]"])
5354

5455
-- Check that the change propagates to C
5556
changeDoc cdoc [TextDocumentContentChangeEvent . InR . (.==) #text $ cSource]

ghcide/test/exe/THTests.hs

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
module THTests (tests) where
55

66
import Control.Monad.IO.Class (liftIO)
7+
import Data.List.Extra (dropEnd, dropEnd1)
78
import Data.Row
89
import qualified Data.Text as T
910
import Development.IDE.GHC.Util
@@ -141,7 +142,7 @@ thReloadingTest unboxed = testCase name $ runWithExtraFiles dir $ \dir -> do
141142
expectDiagnostics [("THB.hs", [(DiagnosticSeverity_Warning, (4,1), "Top-level binding")])]
142143

143144
-- Change th from () to Bool
144-
let aSource' = T.unlines $ init (T.lines aSource) ++ ["th_a = [d| a = False|]"]
145+
let aSource' = T.unlines $ dropEnd1 (T.lines aSource) ++ ["th_a = [d| a = False|]"]
145146
changeDoc adoc [TextDocumentContentChangeEvent . InR . (.==) #text $ aSource']
146147
-- generate an artificial warning to avoid timing out if the TH change does not propagate
147148
changeDoc cdoc [TextDocumentContentChangeEvent . InR . (.==) #text $ cSource <> "\nfoo=()"]
@@ -175,11 +176,11 @@ thLinkingTest unboxed = testCase name $ runWithExtraFiles dir $ \dir -> do
175176

176177
expectDiagnostics [("THB.hs", [(DiagnosticSeverity_Warning, (4,1), "Top-level binding")])]
177178

178-
let aSource' = T.unlines $ init (init (T.lines aSource)) ++ ["th :: DecsQ", "th = [d| a = False|]"]
179+
let aSource' = T.unlines $ dropEnd 2 (T.lines aSource) ++ ["th :: DecsQ", "th = [d| a = False|]"]
179180
changeDoc adoc [TextDocumentContentChangeEvent . InR . (.==) #text $ aSource']
180181

181182
-- modify b too
182-
let bSource' = T.unlines $ init (T.lines bSource) ++ ["$th"]
183+
let bSource' = T.unlines $ dropEnd1 (T.lines bSource) ++ ["$th"]
183184
changeDoc bdoc [TextDocumentContentChangeEvent . InR . (.==) #text $ bSource']
184185
waitForProgressBegin
185186
waitForAllProgressDone

ghcide/test/exe/WatchedFileTests.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module WatchedFileTests (tests) where
66
import Control.Applicative.Combinators
77
import Control.Monad.IO.Class (liftIO)
88
import qualified Data.Aeson as A
9+
import Data.List.Extra (drop1, dropEnd1)
910
import qualified Data.Text as T
1011
import Development.IDE.Test (expectDiagnostics)
1112
import Language.LSP.Protocol.Message
@@ -17,7 +18,6 @@ import Language.LSP.Protocol.Types hiding
1718
import Language.LSP.Test
1819
import System.Directory
1920
import System.FilePath
20-
-- import Test.QuickCheck.Instances ()
2121
import Test.Tasty
2222
import Test.Tasty.HUnit
2323
import TestUtils
@@ -36,7 +36,7 @@ tests = testGroup "watched files"
3636

3737
, testSession' "non workspace file" $ \sessionDir -> do
3838
tmpDir <- liftIO getTemporaryDirectory
39-
let yaml = "cradle: {direct: {arguments: [\"-i" <> tail(init(show tmpDir)) <> "\", \"A\", \"WatchedFilesMissingModule\"]}}"
39+
let yaml = "cradle: {direct: {arguments: [\"-i" <> drop1 (dropEnd1 (show tmpDir)) <> "\", \"A\", \"WatchedFilesMissingModule\"]}}"
4040
liftIO $ writeFile (sessionDir </> "hie.yaml") yaml
4141
_doc <- createDoc "A.hs" "haskell" "{-# LANGUAGE NoImplicitPrelude#-}\nmodule A where\nimport WatchedFilesMissingModule"
4242
setIgnoringRegistrationRequests False

hls-test-utils/src/Test/Hls.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import Control.Concurrent.Async (async, cancel, wait)
6565
import Control.Concurrent.Extra
6666
import Control.Exception.Safe
6767
import Control.Lens.Extras (is)
68-
import Control.Monad (guard, unless, void, when)
68+
import Control.Monad (guard, unless, void)
6969
import Control.Monad.Extra (forM)
7070
import Control.Monad.IO.Class
7171
import Data.Aeson (Result (Success),
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module ErrorGivenPartialSignature where
1+
module TErrorGivenPartialSignature where
22

33
partial :: Int -> Int
44
partial x = init x

0 commit comments

Comments
 (0)