Skip to content

Commit 23ff249

Browse files
jacgaherrmann-da
authored andcommitted
Add goto/hover tests for type constructors from other package (#167)
1 parent 97e5731 commit 23ff249

File tree

1 file changed

+45
-41
lines changed

1 file changed

+45
-41
lines changed

test/exe/Main.hs

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -740,62 +740,66 @@ findDefinitionTests = let
740740
yes, broken :: (TestTree -> Maybe TestTree)
741741
yes = Just -- test should run and pass
742742
broken = Just . (`xfail` "known broken")
743+
cant = Just . (`xfail` "cannot be made to work")
743744
-- no = const Nothing -- don't run this test at all
744745

745746
source = T.unlines
746747
-- 0123456789 123456789 123456789 123456789
747748
[ "{-# OPTIONS_GHC -Wmissing-signatures #-}" -- 0
748749
, "module Testing where" -- 1
749-
, "data TypeConstructor = DataConstructor" -- 2
750-
, " { fff :: String" -- 3
751-
, " , ggg :: Int }" -- 4
752-
, "aaa :: TypeConstructor" -- 5
753-
, "aaa = DataConstructor" -- 6
754-
, " { fff = \"\"" -- 7
755-
, " , ggg = 0" -- 8
756-
, " }" -- 9
750+
, "import Data.Text (Text)" -- 2
751+
, "data TypeConstructor = DataConstructor" -- 3
752+
, " { fff :: Text" -- 4
753+
, " , ggg :: Int }" -- 5
754+
, "aaa :: TypeConstructor" -- 6
755+
, "aaa = DataConstructor" -- 7
756+
, " { fff = \"\"" -- 8
757+
, " , ggg = 0" -- 9
757758
-- 0123456789 123456789 123456789 123456789
758-
, "bbb :: TypeConstructor" -- 10
759-
, "bbb = DataConstructor \"\" 0" -- 11
760-
, "ccc :: (String, Int)" -- 12
761-
, "ccc = (fff bbb, ggg aaa)" -- 13
762-
, "ddd :: Num a => a -> a -> a" -- 14
763-
, "ddd vv ww = vv +! ww" -- 15
764-
, "a +! b = a - b" -- 16
765-
, "hhh (Just a) (><) = a >< a" -- 17
766-
, "iii a b = a `b` a" -- 18
759+
, " }" -- 10
760+
, "bbb :: TypeConstructor" -- 11
761+
, "bbb = DataConstructor \"\" 0" -- 12
762+
, "ccc :: (Text, Int)" -- 13
763+
, "ccc = (fff bbb, ggg aaa)" -- 14
764+
, "ddd :: Num a => a -> a -> a" -- 15
765+
, "ddd vv ww = vv +! ww" -- 16
766+
, "a +! b = a - b" -- 17
767+
, "hhh (Just a) (><) = a >< a" -- 18
768+
, "iii a b = a `b` a" -- 19
767769
-- 0123456789 123456789 123456789 123456789
768770
]
769771

770772
-- search locations definition locations
771-
fffL3 = _start fff ; fff = mkRange 3 4 3 7
772-
fffL7 = Position 7 4 ;
773-
fffL13 = Position 13 7 ;
774-
aaaL13 = Position 13 20 ; aaa = mkRange 6 0 6 3
775-
dcL6 = Position 6 11 ; tcDC = mkRange 2 23 4 16
776-
dcL11 = Position 11 11 ;
777-
tcL5 = Position 5 11 ; tcData = mkRange 2 0 4 16
778-
vvL15 = Position 15 12 ; vv = mkRange 15 4 15 6
779-
opL15 = Position 15 15 ; op = mkRange 16 2 16 4
780-
opL17 = Position 17 22 ; opp = mkRange 17 13 17 17
781-
aL17 = Position 17 20 ; apmp = mkRange 17 10 17 11
782-
b'L18 = Position 18 13 ; bp = mkRange 18 6 18 7
773+
fffL4 = _start fff ; fff = mkRange 4 4 4 7
774+
fffL8 = Position 8 4 ;
775+
fffL14 = Position 14 7 ;
776+
aaaL14 = Position 14 20 ; aaa = mkRange 7 0 7 3
777+
dcL7 = Position 7 11 ; tcDC = mkRange 3 23 5 16
778+
dcL12 = Position 12 11 ;
779+
xtcL5 = Position 5 11 ; xtc = undefined -- not clear what it should do
780+
tcL6 = Position 6 11 ; tcData = mkRange 3 0 5 16
781+
vvL16 = Position 16 12 ; vv = mkRange 16 4 16 6
782+
opL16 = Position 16 15 ; op = mkRange 17 2 17 4
783+
opL18 = Position 18 22 ; opp = mkRange 18 13 18 17
784+
aL18 = Position 18 20 ; apmp = mkRange 18 10 18 11
785+
b'L19 = Position 19 13 ; bp = mkRange 19 6 19 7
783786

784787
in
785788
mkFindTests
786789
-- def hover look bind
787-
[ test yes yes fffL3 fff "field in record definition"
788-
, test broken broken fffL7 fff "field in record construction"
789-
, test yes yes fffL13 fff "field name used as accessor" -- 120 in Calculate.hs
790-
, test yes yes aaaL13 aaa "top-level name" -- 120
791-
, test broken broken dcL6 tcDC "record data constructor"
792-
, test yes yes dcL11 tcDC "plain data constructor" -- 121
793-
, test yes broken tcL5 tcData "type constructor" -- 147
794-
, test yes yes vvL15 vv "plain parameter"
795-
, test yes yes aL17 apmp "pattern match name"
796-
, test yes yes opL15 op "top-level operator" -- 123
797-
, test yes yes opL17 opp "parameter operator"
798-
, test yes yes b'L18 bp "name in backticks"
790+
[ test yes yes fffL4 fff "field in record definition"
791+
, test broken broken fffL8 fff "field in record construction"
792+
, test yes yes fffL14 fff "field name used as accessor" -- 120 in Calculate.hs
793+
, test yes yes aaaL14 aaa "top-level name" -- 120
794+
, test broken broken dcL7 tcDC "record data constructor"
795+
, test yes yes dcL12 tcDC "plain data constructor" -- 121
796+
, test yes broken tcL6 tcData "type constructor" -- 147
797+
, test cant broken xtcL5 xtc "type constructor from other package"
798+
, test yes yes vvL16 vv "plain parameter"
799+
, test yes yes aL18 apmp "pattern match name"
800+
, test yes yes opL16 op "top-level operator" -- 123
801+
, test yes yes opL18 opp "parameter operator"
802+
, test yes yes b'L19 bp "name in backticks"
799803
]
800804

801805
xfail :: TestTree -> String -> TestTree

0 commit comments

Comments
 (0)