Add testsuite for the library interface
parent
1adf02dabe
commit
72b8817f32
|
@ -359,3 +359,40 @@ test-suite littests
|
|||
if flag(brittany-dev) {
|
||||
ghc-options: -O0 -Werror -fobject-code
|
||||
}
|
||||
|
||||
test-suite libinterfacetests
|
||||
if flag(brittany-dev-lib) {
|
||||
buildable: False
|
||||
} else {
|
||||
buildable: True
|
||||
}
|
||||
type: exitcode-stdio-1.0
|
||||
default-language: Haskell2010
|
||||
build-depends:
|
||||
{ brittany
|
||||
, base
|
||||
, text
|
||||
, transformers
|
||||
, hspec >=2.4.1 && <2.5
|
||||
}
|
||||
ghc-options: -Wall
|
||||
main-is: Main.hs
|
||||
other-modules:
|
||||
hs-source-dirs: src-libinterfacetests
|
||||
default-extensions: {
|
||||
FlexibleContexts
|
||||
FlexibleInstances
|
||||
ScopedTypeVariables
|
||||
MonadComprehensions
|
||||
LambdaCase
|
||||
MultiWayIf
|
||||
KindSignatures
|
||||
}
|
||||
ghc-options: {
|
||||
-Wall
|
||||
-j
|
||||
-fno-warn-unused-imports
|
||||
-fno-warn-orphans
|
||||
-rtsopts
|
||||
-with-rtsopts "-M2G"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
module Main where
|
||||
|
||||
|
||||
|
||||
import Test.Hspec
|
||||
import Language.Haskell.Brittany
|
||||
import qualified Data.Text as Text
|
||||
import qualified System.Exit as Exit
|
||||
import Control.Monad.IO.Class
|
||||
|
||||
|
||||
|
||||
main :: IO ()
|
||||
main = hspec $ do
|
||||
describe "library interface basic functionality" $ do
|
||||
it "gives properly formatted result for valid input" $ do
|
||||
let
|
||||
input = Text.pack $ unlines
|
||||
["func = [00000000000000000000000, 00000000000000000000000, 00000000000000000000000, 00000000000000000000000]"]
|
||||
let expected = Text.pack $ unlines
|
||||
[ "func ="
|
||||
, " [ 00000000000000000000000"
|
||||
, " , 00000000000000000000000"
|
||||
, " , 00000000000000000000000"
|
||||
, " , 00000000000000000000000"
|
||||
, " ]"
|
||||
]
|
||||
output <- liftIO $ pureModuleTransform mempty input
|
||||
input `shouldSatisfy` \_ -> case output of
|
||||
Right x | x == expected -> True
|
||||
_ -> False
|
||||
|
Loading…
Reference in New Issue