Skip to content

Commit 5fc4966

Browse files
Enable getTypeDefinitions tests.
1 parent cf3f6fa commit 5fc4966

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

test/functional/TypeDefinition.hs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import Language.Haskell.LSP.Types
66
import System.Directory
77
import Test.Hls.Util
88
import Test.Tasty
9-
import Test.Tasty.ExpectedFailure (ignoreTestBecause)
109
import Test.Tasty.HUnit
10+
import Test.Tasty.ExpectedFailure (expectFailBecause)
1111

1212
tests :: TestTree
1313
tests = testGroup "type definitions" [
14-
ignoreTestBecause "Broken" $ testCase "finds local definition of record variable"
14+
testCase "finds local definition of record variable"
1515
$ runSession hlsCommand fullCaps "test/testdata/gototest"
1616
$ do
1717
doc <- openDoc "src/Lib.hs" "haskell"
@@ -21,7 +21,8 @@ tests = testGroup "type definitions" [
2121
defs @?= [ Location (filePathToUri fp)
2222
(Range (toPos (8, 1)) (toPos (8, 29)))
2323
]
24-
, ignoreTestBecause "Broken" $ testCase "finds local definition of newtype variable"
24+
25+
, testCase "finds local definition of newtype variable"
2526
$ runSession hlsCommand fullCaps "test/testdata/gototest"
2627
$ do
2728
doc <- openDoc "src/Lib.hs" "haskell"
@@ -31,7 +32,8 @@ tests = testGroup "type definitions" [
3132
defs @?= [ Location (filePathToUri fp)
3233
(Range (toPos (13, 1)) (toPos (13, 30)))
3334
]
34-
, ignoreTestBecause "Broken" $ testCase "finds local definition of sum type variable"
35+
36+
, testCase "finds local definition of sum type variable"
3537
$ runSession hlsCommand fullCaps "test/testdata/gototest"
3638
$ do
3739
doc <- openDoc "src/Lib.hs" "haskell"
@@ -41,7 +43,8 @@ tests = testGroup "type definitions" [
4143
defs @?= [ Location (filePathToUri fp)
4244
(Range (toPos (18, 1)) (toPos (18, 26)))
4345
]
44-
, ignoreTestBecause "Broken" $ testCase "finds local definition of sum type contructor"
46+
47+
, testCase "finds local definition of sum type constructor"
4548
$ runSession hlsCommand fullCaps "test/testdata/gototest"
4649
$ do
4750
doc <- openDoc "src/Lib.hs" "haskell"
@@ -52,27 +55,32 @@ tests = testGroup "type definitions" [
5255
@?= [ Location (filePathToUri fp)
5356
(Range (toPos (18, 1)) (toPos (18, 26)))
5457
]
55-
, ignoreTestBecause "Broken" $ testCase "can not find non-local definition of type def"
58+
59+
, testCase "finds non-local definition of type def"
5660
$ runSession hlsCommand fullCaps "test/testdata/gototest"
5761
$ do
5862
doc <- openDoc "src/Lib.hs" "haskell"
5963
defs <- getTypeDefinitions doc (toPos (30, 17))
60-
liftIO $ defs @?= []
64+
liftIO $ do
65+
fp <- canonicalizePath "test/testdata/gototest/src/Lib.hs"
66+
defs
67+
@?= [ Location (filePathToUri fp)
68+
(Range (toPos (27, 1)) (toPos (27, 17)))
69+
]
6170

62-
, ignoreTestBecause "Broken" $ testCase "find local definition of type def"
71+
, testCase "find local definition of type def"
6372
$ runSession hlsCommand fullCaps "test/testdata/gototest"
6473
$ do
6574
doc <- openDoc "src/Lib.hs" "haskell"
6675
defs <- getTypeDefinitions doc (toPos (35, 16))
6776
liftIO $ do
6877
fp <- canonicalizePath "test/testdata/gototest/src/Lib.hs"
6978
defs @?= [ Location (filePathToUri fp)
70-
(Range (toPos (18, 1)) (toPos (18, 26)))
79+
(Range (toPos (32, 1)) (toPos (32, 18)))
7180
]
7281

73-
{-- TODO Implement
74-
, ignoreTestBecause "Broken" $ testCase "find type-definition of type def in component"
75-
$ pendingWith "Finding symbols cross module is currently not supported"
82+
, expectFailBecause "This test is broken because it needs a proper cradle." $
83+
testCase "find type-definition of type def in component"
7684
$ runSession hlsCommand fullCaps "test/testdata/gototest"
7785
$ do
7886
doc <- openDoc "src/Lib2.hs" "haskell"
@@ -85,8 +93,8 @@ tests = testGroup "type definitions" [
8593
@?= [ Location (filePathToUri fp)
8694
(Range (toPos (8, 1)) (toPos (8, 29)))
8795
]
88-
--}
89-
, ignoreTestBecause "Broken" $ testCase "find definition of parameterized data type"
96+
97+
, testCase "find definition of parameterized data type"
9098
$ runSession hlsCommand fullCaps "test/testdata/gototest"
9199
$ do
92100
doc <- openDoc "src/Lib.hs" "haskell"

0 commit comments

Comments
 (0)