mirror of
https://github.com/CrystalSplitter/ghcitui.git
synced 2024-09-11 10:55:29 +03:00
Add basic HSpec testing
This commit is contained in:
parent
2b42b28a94
commit
7d8eb7f3d6
@ -17,24 +17,23 @@ license: BSD-3-Clause
|
||||
license-file: LICENSE
|
||||
author: Jordan 'CrystalSplitter' R AW
|
||||
maintainer: gamewhizzit@gmail.com
|
||||
|
||||
source-repository head
|
||||
type: git
|
||||
location: https://github.com/CrystalSplitter/ghcitui
|
||||
|
||||
-- A copyright notice.
|
||||
-- copyright:
|
||||
category: Debug
|
||||
extra-source-files: CHANGELOG.md
|
||||
, LICENSE
|
||||
|
||||
source-repository head
|
||||
type: git
|
||||
location: https://github.com/CrystalSplitter/ghcitui
|
||||
|
||||
executable ghcitui
|
||||
main-is: Main.hs
|
||||
build-depends: base ^>= 4.17
|
||||
, brick
|
||||
, containers
|
||||
, errors
|
||||
, ghcitui
|
||||
, ghcitui-lib
|
||||
, microlens ^>= 0.4.13.1
|
||||
, optparse-applicative ^>= 0.18.1.0
|
||||
, safe ^>= 0.3.19
|
||||
@ -65,7 +64,7 @@ executable ghcitui
|
||||
RecordWildCards
|
||||
TupleSections
|
||||
|
||||
library
|
||||
library ghcitui-lib
|
||||
hs-source-dirs: lib
|
||||
build-depends: base ^>= 4.17
|
||||
, array ^>= 0.5.4.0
|
||||
@ -83,9 +82,7 @@ library
|
||||
, Loc
|
||||
, StringUtil
|
||||
, NameBinding
|
||||
ghc-options: -rtsopts
|
||||
-threaded
|
||||
-Wall
|
||||
ghc-options: -Wall
|
||||
-Wcompat
|
||||
-Wincomplete-record-updates
|
||||
-Wpartial-fields
|
||||
@ -96,3 +93,13 @@ library
|
||||
OverloadedStrings
|
||||
RecordWildCards
|
||||
TupleSections
|
||||
|
||||
test-suite spec
|
||||
hs-source-dirs: test
|
||||
main-is: Spec.hs
|
||||
type: exitcode-stdio-1.0
|
||||
build-depends: base ^>= 4.17
|
||||
, hspec ^>= 2.11.5
|
||||
, ghcitui-lib
|
||||
other-modules: LocSpec
|
||||
default-language: Haskell2010
|
||||
|
22
test/LocSpec.hs
Normal file
22
test/LocSpec.hs
Normal file
@ -0,0 +1,22 @@
|
||||
{-# 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"
|
11
test/Spec.hs
Normal file
11
test/Spec.hs
Normal file
@ -0,0 +1,11 @@
|
||||
module Main where
|
||||
|
||||
import Test.Hspec
|
||||
|
||||
import qualified LocSpec
|
||||
import qualified StringUtilSpec
|
||||
|
||||
main :: IO ()
|
||||
main = hspec $ do
|
||||
LocSpec.spec
|
||||
StringUtilSpec.spec
|
Loading…
Reference in New Issue
Block a user