on master help sign in
Add PackageImport test
commit2312cba38588596360a783df2ed1d9a193e24d62 authorOlle Fredriksson <fredriksson.olle@gmail.com> dateThu 12 Sep 2019, 09:39 (7 years ago) parentd859af2
1 file changed+24
test/exe/Main.hs+24
test/exe/Main.hs+24
@@ -180,6 +180,30 @@ diagnosticTests = testGroup "diagnostics"
180180 , [(DsWarning, (2, 0), "The import of 'ModuleA' is redundant")]
181181 )
182182 ]
183+ , testSession "package imports" $ do
184+ let thisDataListContent = T.unlines
185+ [ "module Data.List where"
186+ , "x = 123"
187+ ]
188+ let mainContent = T.unlines
189+ [ "{-# LANGUAGE PackageImports #-}"
190+ , "module Main where"
191+ , "import qualified \"this\" Data.List as ThisList"
192+ , "import qualified \"base\" Data.List as BaseList"
193+ , "useThis = ThisList.x"
194+ , "useBase = BaseList.map"
195+ , "wrong1 = ThisList.map"
196+ , "wrong2 = BaseList.x"
197+ ]
198+ _ <- openDoc' "Data/List.hs" "haskell" thisDataListContent
199+ _ <- openDoc' "Main.hs" "haskell" mainContent
200+ expectDiagnostics
201+ [ ( "Main.hs"
202+ , [(DsError, (6, 9), "Not in scope: \8216ThisList.map\8217")
203+ ,(DsError, (7, 9), "Not in scope: \8216BaseList.x\8217")
204+ ]
205+ )
206+ ]
183207 ]
184208
185209