File tree 5 files changed +62
-6
lines changed
5 files changed +62
-6
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,10 @@ jobs:
133
133
# run the tests without parallelism to avoid running out of memory
134
134
run : cabal test ghcide --test-options="$TEST_OPTS" || cabal test ghcide --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test ghcide --test-options="$TEST_OPTS"
135
135
136
+ - if : matrix.test
137
+ name : Test hls-plugin-api
138
+ run : cabal test hls-plugin-api --test-options="$TEST_OPTS" || cabal test hls-plugin-api --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-plugin-api --test-options="$TEST_OPTS"
139
+
136
140
- if : matrix.test
137
141
name : Test func-test suite
138
142
env :
Original file line number Diff line number Diff line change @@ -77,3 +77,18 @@ library
77
77
DataKinds
78
78
KindSignatures
79
79
TypeOperators
80
+
81
+ test-suite tests
82
+ type : exitcode-stdio-1.0
83
+ default-language : Haskell2010
84
+ hs-source-dirs : test
85
+ main-is : Main.hs
86
+ ghc-options : -threaded -rtsopts -with-rtsopts=-N
87
+ other-modules : Ide.PluginUtilsTest
88
+ build-depends :
89
+ base
90
+ , hls-plugin-api
91
+ , tasty
92
+ , tasty-hunit
93
+ , tasty-rerun
94
+ , lsp-types
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ module Ide.PluginUtils
25
25
allLspCmdIds' ,
26
26
installSigUsr1Handler ,
27
27
subRange ,
28
+ positionInRange ,
28
29
usePropertyLsp ,
29
30
response ,
30
31
handleMaybe ,
@@ -178,7 +179,7 @@ getClientConfig = getConfig
178
179
getPluginConfig :: MonadLsp Config m => PluginId -> m PluginConfig
179
180
getPluginConfig plugin = do
180
181
config <- getClientConfig
181
- return $ configForPlugin config plugin
182
+ return $ configForPlugin config plugin
182
183
183
184
-- ---------------------------------------------------------------------
184
185
@@ -220,11 +221,7 @@ subRange smallRange range =
220
221
&& positionInRange (_end smallRange) range
221
222
222
223
positionInRange :: Position -> Range -> Bool
223
- positionInRange (Position pl po) (Range (Position sl so) (Position el eo)) =
224
- pl > sl && pl < el
225
- || pl == sl && pl == el && po >= so && po <= eo
226
- || pl == sl && po >= so
227
- || pl == el && po <= eo
224
+ positionInRange p (Range sp ep) = sp <= p && p <= ep
228
225
229
226
-- ---------------------------------------------------------------------
230
227
Original file line number Diff line number Diff line change
1
+ module Ide.PluginUtilsTest
2
+ ( tests
3
+ ) where
4
+
5
+ import Ide.PluginUtils (positionInRange )
6
+ import Language.LSP.Types (Position (Position ), Range (Range ))
7
+ import Test.Tasty
8
+ import Test.Tasty.HUnit
9
+
10
+ tests :: TestTree
11
+ tests = testGroup " PluginUtils"
12
+ [ positionInRangeTest
13
+ ]
14
+
15
+ positionInRangeTest :: TestTree
16
+ positionInRangeTest = testGroup " positionInRange"
17
+ [ testCase " single line, after the end" $
18
+ positionInRange (Position 1 10 ) (Range (Position 1 1 ) (Position 1 3 )) @?= False
19
+ , testCase " single line, before the begining" $
20
+ positionInRange (Position 1 0 ) (Range (Position 1 1 ) (Position 1 6 )) @?= False
21
+ , testCase " single line, in range" $
22
+ positionInRange (Position 1 5 ) (Range (Position 1 1 ) (Position 1 6 )) @?= True
23
+ , testCase " multiline, in range" $
24
+ positionInRange (Position 3 5 ) (Range (Position 1 1 ) (Position 5 6 )) @?= True
25
+ , testCase " multiline, out of range" $
26
+ positionInRange (Position 3 5 ) (Range (Position 3 6 ) (Position 4 10 )) @?= False
27
+ ]
Original file line number Diff line number Diff line change
1
+ module Main where
2
+
3
+ import qualified Ide.PluginUtilsTest as PluginUtilsTest
4
+ import Test.Tasty
5
+ import Test.Tasty.Ingredients.Rerun
6
+
7
+ main :: IO ()
8
+ main = defaultMainWithRerun tests
9
+
10
+ tests :: TestTree
11
+ tests = testGroup " Main"
12
+ [ PluginUtilsTest. tests
13
+ ]
You can’t perform that action at this time.
0 commit comments