Commit 12e88a36 authored by Andrew Gibiansky's avatar Andrew Gibiansky

Get test suite working again.

Also, add some utilities for working with IHaskell components in `stack
ghci`.
parent f9846b6b
:set -package ghc :set -package ghc
:set -package ghc-paths :set -package ghc-paths
:set -optP-include -optPdist/build/autogen/cabal_macros.h
:set -i. -isrc -idist/build/autogen :set -i. -isrc -idist/build/autogen
:set -XDoAndIfThenElse -XOverloadedStrings :set -XDoAndIfThenElse -XOverloadedStrings
:set prompt "\ESC[34mλ> \ESC[m"
...@@ -130,6 +130,7 @@ executable ihaskell ...@@ -130,6 +130,7 @@ executable ihaskell
hs-source-dirs: main hs-source-dirs: main
other-modules: other-modules:
IHaskellPrelude IHaskellPrelude
Paths_ihaskell
ghc-options: -threaded ghc-options: -threaded
-- Other library packages from which modules are imported. -- Other library packages from which modules are imported.
...@@ -162,47 +163,21 @@ Test-Suite hspec ...@@ -162,47 +163,21 @@ Test-Suite hspec
Type: exitcode-stdio-1.0 Type: exitcode-stdio-1.0
Ghc-Options: -threaded Ghc-Options: -threaded
Main-Is: Hspec.hs Main-Is: Hspec.hs
hs-source-dirs: src/tests
default-language: Haskell2010 default-language: Haskell2010
build-depends: build-depends:
base,
ihaskell, ihaskell,
aeson >=0.6 && < 0.12,
base >=4.6 && < 4.9,
base64-bytestring >=1.0,
bytestring >=0.10,
cereal >=0.3,
cmdargs >=0.10,
containers >=0.5,
directory -any,
filepath -any,
ghc >=7.6 && < 7.11,
ghc-parser >=0.1.7,
ghc-paths ==0.1.*,
haskeline -any,
hlint >=1.9 && <2.0,
haskell-src-exts >=1.16 && < 1.18,
here, here,
hspec -any, hspec,
HUnit -any, HUnit,
mtl >=2.1, ghc,
parsec -any, ghc-paths,
process >=1.1, transformers,
random >=1.0, directory,
shelly >=1.5, text,
split >= 0.2, shelly,
stm -any, setenv
strict >=0.3,
system-argv0 -any,
text >=0.11,
http-client == 0.4.*,
http-client-tls == 0.2.*,
transformers -any,
unix >= 2.6,
unordered-containers -any,
utf8-string -any,
uuid >=1.3,
vector -any,
setenv ==0.1.*,
ipython-kernel >= 0.7
if flag(binPkgDb) if flag(binPkgDb)
build-depends: bin-package-db build-depends: bin-package-db
...@@ -212,7 +187,6 @@ Test-Suite hspec ...@@ -212,7 +187,6 @@ Test-Suite hspec
OverloadedStrings OverloadedStrings
ExtendedDefaultRules ExtendedDefaultRules
source-repository head source-repository head
type: git type: git
location: git://github.com/gibiansky/IHaskell.git location: git://github.com/gibiansky/IHaskell.git
...@@ -107,10 +107,9 @@ complete code posOffset = do ...@@ -107,10 +107,9 @@ complete code posOffset = do
Qualified moduleName candidate -> do Qualified moduleName candidate -> do
trueName <- getTrueModuleName moduleName trueName <- getTrueModuleName moduleName
let prefix = intercalate "." [trueName, candidate] let prefix = intercalate "." [moduleName, candidate]
completions = filter (prefix `isPrefixOf`) qualNames completions = filter (prefix `isPrefixOf`) qualNames
falsifyName = replace trueName moduleName return completions
return $ map falsifyName completions
ModuleName previous candidate -> do ModuleName previous candidate -> do
let prefix = if null previous let prefix = if null previous
......
...@@ -7,6 +7,7 @@ This module exports all functions used for evaluation of IHaskell input. ...@@ -7,6 +7,7 @@ This module exports all functions used for evaluation of IHaskell input.
-} -}
module IHaskell.Eval.Evaluate ( module IHaskell.Eval.Evaluate (
interpret, interpret,
testInterpret,
evaluate, evaluate,
flushWidgetMessages, flushWidgetMessages,
Interpreter, Interpreter,
...@@ -48,6 +49,7 @@ import qualified MonadUtils (MonadIO, liftIO) ...@@ -48,6 +49,7 @@ import qualified MonadUtils (MonadIO, liftIO)
import System.Environment (getEnv) import System.Environment (getEnv)
import qualified Data.Map as Map import qualified Data.Map as Map
import qualified GHC.Paths
import NameSet import NameSet
import Name import Name
import PprTyThing import PprTyThing
...@@ -145,6 +147,11 @@ ihaskellGlobalImports = ...@@ -145,6 +147,11 @@ ihaskellGlobalImports =
, "import qualified IHaskell.Eval.Widgets" , "import qualified IHaskell.Eval.Widgets"
] ]
-- | Evaluation function for testing.
testInterpret :: Interpreter a -> IO a
testInterpret val = interpret GHC.Paths.libdir False (const val)
-- | Run an interpreting action. This is effectively runGhc with initialization and importing. First -- | Run an interpreting action. This is effectively runGhc with initialization and importing. First
-- argument indicates whether `stdin` is handled specially, which cannot be done in a testing -- argument indicates whether `stdin` is handled specially, which cannot be done in a testing
-- environment. The argument passed to the action indicates whether Haskell support libraries are -- environment. The argument passed to the action indicates whether Haskell support libraries are
......
...@@ -250,7 +250,7 @@ completionTests = do ...@@ -250,7 +250,7 @@ completionTests = do
, "Control.Monad.liftM2" , "Control.Monad.liftM2"
, "Control.Monad.liftM5"] , "Control.Monad.liftM5"]
"print $ List.intercal*" `completionHas` ["List.intercalate"] "print $ List.intercal*" `completionHas` ["List.intercalate"]
"print $ Data.Maybe.cat*" `completionHas` ["Data.Maybe.catMaybes"] "print $ Data.Maybe.cat*" `completionHas` []
"print $ Maybe.catM*" `completionHas` ["Maybe.catMaybes"] "print $ Maybe.catM*" `completionHas` ["Maybe.catMaybes"]
it "properly completes imports" $ do it "properly completes imports" $ do
...@@ -543,7 +543,9 @@ parseStringTests = describe "Parser" $ do ...@@ -543,7 +543,9 @@ parseStringTests = describe "Parser" $ do
it "breaks without data kinds" $ it "breaks without data kinds" $
parses "data X = 3" `like` [ parses "data X = 3" `like` [
#if MIN_VERSION_ghc(7, 8, 0) #if MIN_VERSION_ghc(7, 10, 0)
ParseError (Loc 1 10) "Cannot parse data constructor in a data/newtype declaration: 3"
#elif MIN_VERSION_ghc(7, 8, 0)
ParseError (Loc 1 10) "Illegal literal in type (use DataKinds to enable): 3" ParseError (Loc 1 10) "Illegal literal in type (use DataKinds to enable): 3"
#else #else
ParseError (Loc 1 10) "Illegal literal in type (use -XDataKinds to enable): 3" ParseError (Loc 1 10) "Illegal literal in type (use -XDataKinds to enable): 3"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment