Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 4eec139

Browse files
committed
Add more tests for type information
1 parent 6a7a5b1 commit 4eec139

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

test/unit/GhcModPluginSpec.hs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ ghcmodSpec =
8282

8383
-- ---------------------------------
8484

85-
it "runs the type command" $ withCurrentDirectory "./test/testdata" $ do
85+
it "runs the type command, find type" $ withCurrentDirectory "./test/testdata" $ do
8686
fp <- makeAbsolute "HaReRename.hs"
8787
let uri = filePathToUri fp
8888
act = do
@@ -93,6 +93,26 @@ ghcmodSpec =
9393
[(Range (toPos (5,9)) (toPos (5,10)), "Int")
9494
]
9595
testCommand testPlugins act "ghcmod" "type" arg res
96+
it "runs the type command, find function type" $ withCurrentDirectory "./test/testdata" $ do
97+
fp <- makeAbsolute "HaReRename.hs"
98+
let uri = filePathToUri fp
99+
act = do
100+
_ <- setTypecheckedModule uri
101+
liftToGhc $ newTypeCmd (toPos (2,11)) uri
102+
arg = TP False uri (toPos (2,11))
103+
res = IdeResultOk
104+
[(Range (toPos (2, 8)) (toPos (2,16)), "String -> IO ()")
105+
]
106+
testCommand testPlugins act "ghcmod" "type" arg res
107+
108+
it "runs the type command, no type at location" $ withCurrentDirectory "./test/testdata" $ do
109+
fp <- makeAbsolute "HaReRename.hs"
110+
let uri = filePathToUri fp
111+
act = do
112+
_ <- setTypecheckedModule uri
113+
liftToGhc $ newTypeCmd (toPos (1,1)) uri
114+
arg = TP False uri (toPos (1,1))
115+
res = IdeResultOk []
96116

97117
it "runs the type command with an absolute path from another folder, correct params" $ do
98118
fp <- makeAbsolute "./test/testdata/HaReRename.hs"

0 commit comments

Comments
 (0)