2module Test.Compiler (compilerTests) where
4import Control.Arrow (second)
5import qualified Data.Map as Map
6import Data.Traversable (traverse)
8import System.FilePath ((</>))
9import System.FilePath.Find (find, (==?), extension)
12import Test.Framework.Providers.HUnit (testCase)
13import Test.HUnit (Assertion, assertFailure, assertBool)
15import qualified Elm.Compiler as Compiler
16import qualified Elm.Compiler.Module as Module
22 goods <- testIf isSuccess =<< getElms "good"
23 bads <- testIf isFailure =<< getElms "bad"
25 testGroup "Compile Tests"
26 [ testGroup "Good Tests" goods
27 , testGroup "Bad Tests" bads
33getElms :: FilePath -> IO [FilePath]
37 (extension ==? ".elm")
38 (testsDir </> filePath)
43 "tests" </> "test-files"
49 :: (([Compiler.Warning], Either String (Module.Interface, String)) -> Assertion)
52testIf handleResult filePaths =
53 traverse setupTest filePaths
55 setupTest filePath = do
56 source <- readFile filePath
59 Compiler.compile "elm-lang" "core" True source Map.empty
60 let formatErrors errors =
61 concatMap (Compiler.errorToString filePath source) errors
63 second (either (Left . formatErrors) Right) result
65 return $ testCase filePath (handleResult formattedResult)
70isSuccess :: ([Compiler.Warning], Either String a) -> Assertion
71isSuccess (_, result) =
77 assertFailure errorMessages
80isFailure :: ([Compiler.Warning], Either a b) -> Assertion
81isFailure (_, result) =
84 assertFailure "Compilation succeeded but should have failed"
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