ghcitui/test/LocSpec.hs
2023-10-13 00:13:42 -07:00

23 lines
889 B
Haskell

{-# LANGUAGE OverloadedStrings #-}
module LocSpec where
import Loc
import Test.Hspec
spec :: Spec
spec = do
describe "module/file mappings" $ do
let mfmA = moduleFileMapFromList [("A.Module.Name", "some/filepath")]
let mfmB = moduleFileMapFromList [("Another.Module.Name", "some/other/filepath")]
it "can convert a module name to file path" $ do
getPathOfModule mfmA "A.Module.Name" `shouldBe` Just "some/filepath"
it "can convert a file path to a module name" $ do
getModuleOfPath mfmA "some/filepath" `shouldBe` Just "A.Module.Name"
it "can merge ModuleFileMaps" $ do
let merged = mfmB <> mfmA
getModuleOfPath merged "some/other/filepath"
`shouldBe` Just "Another.Module.Name"
getModuleOfPath merged "some/filepath"
`shouldBe` Just "A.Module.Name"