aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Main.hs25
1 files changed, 13 insertions, 12 deletions
diff --git a/test/Main.hs b/test/Main.hs
index d080135..a1e774a 100644
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -1,5 +1,6 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE DuplicateRecordFields #-}
@@ -49,10 +50,10 @@ packageInfoSpec :: FilePath -> Spec
packageInfoSpec currentDir = do
eitherPackageInfo <- runIO $ buildAndIndexTestPackage currentDir
case eitherPackageInfo of
- Right packageInfo -> do
+ Right HCE.PackageInfo{id=pkgId, ..} -> do
describe "createPackageInfo" $ do
it "returns valid package id" $
- HCE.id (packageInfo :: PackageInfo ModuleInfo) `shouldBe`
+ pkgId `shouldBe`
PackageId "test-package" (makeVersion [0, 1, 0, 0])
it "returns valid list of module paths" $ do
let paths =
@@ -67,7 +68,7 @@ packageInfoSpec currentDir = do
, ())
]
(HM.map (const ()))
- (HCE.moduleMap (packageInfo :: PackageInfo ModuleInfo)) `shouldBe`
+ moduleMap `shouldBe`
paths
it "returns valid list of module names" $ do
let names =
@@ -96,25 +97,25 @@ packageInfoSpec currentDir = do
{getHaskellModulePath = "src/Lib.hs"})
])
]
- (HCE.moduleNameMap (packageInfo :: PackageInfo ModuleInfo)) `shouldBe`
+ moduleNameMap `shouldBe`
names
let mbModuleInfo =
HM.lookup
(HCE.HaskellModulePath "src/Lib.hs")
- (moduleMap (packageInfo :: HCE.PackageInfo HCE.ModuleInfo))
+ moduleMap
case mbModuleInfo of
Just modInfo -> moduleInfoSpec modInfo
Nothing -> return ()
Left e -> runIO $ putStrLn e >> return ()
moduleInfoSpec :: ModuleInfo -> Spec
-moduleInfoSpec modInfo =
+moduleInfoSpec HCE.ModuleInfo{id = _, ..} =
describe "createModuleInfo" $ do
it "returns valid module name" $
- HCE.name (modInfo :: HCE.ModuleInfo) `shouldBe`
+ name `shouldBe`
HCE.HaskellModuleName "Lib"
it "returns valid list of declarations " $
- HCE.declarations (modInfo :: HCE.ModuleInfo) `shouldBe` testDeclarations
+ declarations `shouldBe` testDeclarations
it "returns valid source code " $ do
let sourceCodeLines =
V.fromList
@@ -133,9 +134,9 @@ moduleInfoSpec modInfo =
, "mkTest i = Test i"
, ""
]
- HCE.source (modInfo :: HCE.ModuleInfo) `shouldBe` sourceCodeLines
+ source `shouldBe` sourceCodeLines
it "returns valid map of expressions" $
- HCE.exprInfoMap (modInfo :: HCE.ModuleInfo) `shouldBe` testExprInfoMap
+ exprInfoMap `shouldBe` testExprInfoMap
#if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0)
it "returns valid map of identifiers " $
let removeLocationInfo :: HCE.LocationInfo -> HCE.LocationInfo
@@ -149,10 +150,10 @@ moduleInfoSpec modInfo =
cleanup :: HCE.IdentifierInfoMap -> HCE.IdentifierInfoMap
cleanup = U.transformBi removeLocationInfo . U.transformBi removePackageVersionFromExternalId
in
- cleanup (HCE.idInfoMap (modInfo :: HCE.ModuleInfo)) `shouldBe` cleanup testIdInfoMap
+ cleanup idInfoMap `shouldBe` cleanup testIdInfoMap
#endif
it "returns valid map of identifier occurrences" $
- HCE.idOccMap (modInfo :: HCE.ModuleInfo) `shouldBe` testIdOccMap
+ idOccMap `shouldBe` testIdOccMap
stackYamlArg :: [String]
#if MIN_VERSION_GLASGOW_HASKELL(8,6,5,0)