1-----------------------------------------------------------------------------
4-- Copyright : (c) Phil Freeman 2013
7-- Maintainer : Phil Freeman <paf31@cantab.net>
8-- Stability : experimental
13-----------------------------------------------------------------------------
15module Main (main) where
17import Language.PureScript
19import Data.List (isSuffixOf)
20import Control.Applicative
22import System.Exit (exitSuccess, exitFailure)
23import System.FilePath (pathSeparator)
24import System.Directory (getCurrentDirectory, getDirectoryContents)
25import qualified System.IO.UTF8 as U
26import qualified Data.Map as M
28compile :: FilePath -> IO (Either String Environment)
30 ast <- runIndentParser parseDeclarations <$> U.readFile inputFile
33 return (Left $ show parseError)
35 case check (typeCheckAll decls) of
37 return (Left typeError)
41assert :: FilePath -> (Either String Environment -> Maybe String) -> IO ()
42assert inputFile f = do
43 e <- compile inputFile
45 Just err -> exitFailure
48assertCompiles :: FilePath -> IO ()
49assertCompiles inputFile = do
50 putStrLn $ "assert " ++ inputFile ++ " compiles successfully"
51 assert inputFile $ either Just (const Nothing)
53assertDoesNotCompile :: FilePath -> IO ()
54assertDoesNotCompile inputFile = do
55 putStrLn $ "assert " ++ inputFile ++ " does not compile"
56 assert inputFile $ either (const Nothing) (const $ Just "Should not have compiled")
60 cd <- getCurrentDirectory
61 let examples = cd ++ pathSeparator : "examples"
62 let passing = examples ++ pathSeparator : "passing"
63 passingTestCases <- getDirectoryContents passing
64 forM_ passingTestCases $ \inputFile -> when (".ps" `isSuffixOf` inputFile) $
65 assertCompiles (passing ++ pathSeparator : inputFile)
66 let failing = examples ++ pathSeparator : "failing"
67 failingTestCases <- getDirectoryContents failing
68 forM_ failingTestCases $ \inputFile -> when (".ps" `isSuffixOf` inputFile) $
69 assertDoesNotCompile (failing ++ pathSeparator : inputFile)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list