|
| 1 | +module Test.AgdaLibResolution (tests) where |
| 2 | + |
| 3 | +import Agda.Syntax.Common.Pretty (prettyShow) |
| 4 | +import Control.Monad.IO.Class (liftIO) |
| 5 | +import Indexer (indexFile, usingSrcAsCurrent) |
| 6 | +import qualified Language.LSP.Protocol.Types as LSP |
| 7 | +import qualified Language.LSP.Server as LSP |
| 8 | +import Monad (runServerT) |
| 9 | +import Server.Model.Monad (MonadAgdaLib (askAgdaLib), runWithAgdaLib) |
| 10 | +import System.Directory (makeAbsolute) |
| 11 | +import Test.Tasty (TestTree, testGroup) |
| 12 | +import Test.Tasty.HUnit (assertFailure, testCase) |
| 13 | +import qualified TestData |
| 14 | + |
| 15 | +natPath, constPath :: FilePath |
| 16 | +natPath = "test/data/libs/no-deps/src/Data/Nat.agda" |
| 17 | +constPath = "test/data/libs/no-deps/src/Constants.agda" |
| 18 | + |
| 19 | +tests :: TestTree |
| 20 | +tests = |
| 21 | + testGroup |
| 22 | + "Agda lib resolution" |
| 23 | + [ testCase "Module without imports in lib without dependencies" $ do |
| 24 | + model <- TestData.getModel |
| 25 | + |
| 26 | + LSP.runLspT undefined $ do |
| 27 | + env <- TestData.getServerEnv model |
| 28 | + runServerT env $ do |
| 29 | + runWithAgdaLib (LSP.filePathToUri natPath) $ do |
| 30 | + natSrc <- TestData.parseSourceFromPath natPath |
| 31 | + _ <- indexFile natSrc |
| 32 | + return (), |
| 33 | + testCase "Module with imports in lib without lib dependencies" $ do |
| 34 | + model <- TestData.getModel |
| 35 | + |
| 36 | + absConstPath <- makeAbsolute constPath |
| 37 | + |
| 38 | + LSP.runLspT undefined $ do |
| 39 | + env <- TestData.getServerEnv model |
| 40 | + runServerT env $ do |
| 41 | + runWithAgdaLib (LSP.filePathToUri absConstPath) $ do |
| 42 | + lib <- askAgdaLib |
| 43 | + _ <- liftIO $ assertFailure $ prettyShow lib |
| 44 | + constSrc <- TestData.parseSourceFromPath constPath |
| 45 | + _ <- indexFile constSrc |
| 46 | + return () |
| 47 | + ] |
0 commit comments