Skip to content

Commit 58be9bd

Browse files
committed
Broken library resolution unit tests
1 parent f29df32 commit 58be9bd

File tree

5 files changed

+65
-0
lines changed

5 files changed

+65
-0
lines changed

test/Test.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import qualified Test.Indexer.Invariants as IndexerInvariants
1515
import qualified Test.Indexer.NoAnonFunSymbol as NoAnonFunSymbol
1616
import qualified Test.Uri as URI
1717
import qualified Test.Indexer as Indexer
18+
import qualified Test.AgdaLibResolution as AgdaLibResolution
1819

1920
-- Define the custom option
2021
newtype AlsPathOption = AlsPathOption FilePath
@@ -43,6 +44,7 @@ tests = do
4344
URI.tests,
4445
Model.tests,
4546
ModelMonad.tests,
47+
AgdaLibResolution.tests,
4648
indexerTests
4749
#if defined(wasm32_HOST_ARCH)
4850
, WASM.tests alsPath

test/Test/AgdaLibResolution.hs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name: no-deps
2+
include: src
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module Constants where
2+
3+
open import Data.Nat
4+
5+
one : Nat
6+
one = suc zero
7+
8+
two : Nat
9+
two = suc one
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Data.Nat where
2+
3+
data Nat : Set where
4+
zero : Nat
5+
suc : Nat -> Nat

0 commit comments

Comments
 (0)