@@ -7,18 +7,43 @@ import Test.Hls
7
7
import Test.Hls.Command
8
8
9
9
tests :: TestTree
10
- tests = testGroup " definitions" [
10
+ tests = testGroup " definitions" [symbolTests, moduleTests]
11
11
12
- ignoreTestBecause " Broken: file:///Users/jwindsor/src/haskell-language-server/test/testdata/References.hs" $
13
- testCase " goto's symbols" $ runSession hlsCommand fullCaps " test/testdata" $ do
12
+ symbolTests :: TestTree
13
+ symbolTests = testGroup " gotoDefinition on symbols"
14
+ -- gotoDefinition where the definition is in the same file
15
+ [ testCase " gotoDefinition in this file" $ runSession hlsCommand fullCaps " test/testdata" $ do
14
16
doc <- openDoc " References.hs" " haskell"
15
17
defs <- getDefinitions doc (Position 7 8 )
16
18
let expRange = Range (Position 4 0 ) (Position 4 3 )
17
19
liftIO $ defs @?= InL (Definition (InR [Location (doc ^. uri) expRange]))
18
20
21
+ -- gotoDefinition where the definition is in a different file
22
+ , testCase " gotoDefinition in other file" $ runSession hlsCommand fullCaps " test/testdata/definition" $ do
23
+ doc <- openDoc " Foo.hs" " haskell"
24
+ defs <- getDefinitions doc (Position 4 11 )
25
+ let expRange = Range (Position 2 0 ) (Position 2 1 )
26
+ liftIO $ do
27
+ fp <- canonicalizePath " test/testdata/definition/Bar.hs"
28
+ defs @?= InL (Definition (InR [Location (filePathToUri fp) expRange]))
29
+
30
+ -- gotoDefinition where the definition is in a different file and the
31
+ -- definition in the other file is on a line number that is greater
32
+ -- than the number of lines in the file we are requesting from
33
+ , testCase " gotoDefinition in other file past lines in this file" $ runSession hlsCommand fullCaps " test/testdata/definition" $ do
34
+ doc <- openDoc " Foo.hs" " haskell"
35
+ defs <- getDefinitions doc (Position 5 13 )
36
+ let expRange = Range (Position 8 0 ) (Position 8 1 )
37
+ liftIO $ do
38
+ fp <- canonicalizePath " test/testdata/definition/Bar.hs"
39
+ defs @?= InL (Definition (InR [Location (filePathToUri fp) expRange]))
40
+ ]
41
+
19
42
-- -----------------------------------
20
43
21
- , ignoreTestBecause " Broken: file:///Users/jwindsor/src/haskell-language-server/test/testdata/Bar.hs" $
44
+ moduleTests :: TestTree
45
+ moduleTests = testGroup " gotoDefinition on modules"
46
+ [ ignoreTestBecause " Broken: file:///Users/jwindsor/src/haskell-language-server/test/testdata/Bar.hs" $
22
47
testCase " goto's imported modules" $ runSession hlsCommand fullCaps " test/testdata/definition" $ do
23
48
doc <- openDoc " Foo.hs" " haskell"
24
49
defs <- getDefinitions doc (Position 2 8 )
0 commit comments