@@ -7,18 +7,43 @@ import Test.Hls
77import Test.Hls.Command
88
99tests :: TestTree
10- tests = testGroup " definitions" [
10+ tests = testGroup " definitions" [symbolTests, moduleTests]
1111
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
1416 doc <- openDoc " References.hs" " haskell"
1517 defs <- getDefinitions doc (Position 7 8 )
1618 let expRange = Range (Position 4 0 ) (Position 4 3 )
1719 liftIO $ defs @?= InL (Definition (InR [Location (doc ^. uri) expRange]))
1820
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+
1942 -- -----------------------------------
2043
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" $
2247 testCase " goto's imported modules" $ runSession hlsCommand fullCaps " test/testdata/definition" $ do
2348 doc <- openDoc " Foo.hs" " haskell"
2449 defs <- getDefinitions doc (Position 2 8 )
0 commit comments