summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPhilFreeman <>2014-11-08 21:23:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2014-11-08 21:23:00 (GMT)
commitffa65f27c5b68bd44bab7169c36cc05b651c29f8 (patch)
tree07952979b9b4f5c1f06a846384084b9376bc014c /tests
parent657524098de0309d959c2e93175116bc3e20db5e (diff)
version 0.6.00.6.0
Diffstat (limited to 'tests')
-rw-r--r--tests/Main.hs23
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/Main.hs b/tests/Main.hs
index 390dab7..8bbdcd5 100644
--- a/tests/Main.hs
+++ b/tests/Main.hs
@@ -22,6 +22,7 @@ import Data.List (isSuffixOf)
import Data.Traversable (traverse)
import Control.Monad
import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
+import Control.Applicative
import System.Exit
import System.Process
import System.FilePath (pathSeparator)
@@ -29,18 +30,24 @@ import System.Directory (getCurrentDirectory, getTemporaryDirectory, getDirector
import Text.Parsec (ParseError)
import qualified System.IO.UTF8 as U
-readInput :: [FilePath] -> IO (Either ParseError [P.Module])
-readInput inputFiles = fmap (fmap concat . sequence) $ forM inputFiles $ \inputFile -> do
+readInput :: [FilePath] -> IO [(Maybe FilePath, String)]
+readInput inputFiles = forM inputFiles $ \inputFile -> do
text <- U.readFile inputFile
- return $ P.runIndentParser inputFile P.parseModules text
+ return (Just inputFile, text)
+
+loadPrelude :: Either String (String, String, P.Environment)
+loadPrelude =
+ case P.parseModulesFromFiles [(Nothing, P.prelude)] of
+ Left parseError -> Left (show parseError)
+ Right ms -> P.compile (P.defaultCompileOptions { P.optionsAdditional = P.CompileOptions "Tests" [] [] }) (map snd ms) []
compile :: P.Options P.Compile -> [FilePath] -> IO (Either String (String, String, P.Environment))
compile opts inputFiles = do
- modules <- readInput inputFiles
+ modules <- P.parseModulesFromFiles <$> readInput inputFiles
case modules of
Left parseError ->
return (Left $ show parseError)
- Right ms -> return $ P.compile opts ms []
+ Right ms -> return $ P.compile opts (map snd ms) []
assert :: FilePath -> P.Options P.Compile -> FilePath -> (Either String (String, String, P.Environment) -> IO (Maybe String)) -> IO ()
assert preludeExterns opts inputFile f = do
@@ -79,10 +86,8 @@ findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
main :: IO ()
main = do
- prelude <- P.preludeFilename
- putStrLn "Compiling Prelude"
- preludeResult <- compile (P.defaultCompileOptions { P.optionsAdditional = P.CompileOptions "Tests" [] [] }) [prelude]
- case preludeResult of
+ putStrLn "Compiling Prelude"
+ case loadPrelude of
Left err -> putStrLn err >> exitFailure
Right (preludeJs, exts, _) -> do
tmp <- getTemporaryDirectory