2module Test.Compiler (compilerTests) where
4import qualified Data.Map as Map
5import Data.Traversable (traverse)
7import System.FilePath ((</>))
8import System.FilePath.Find (find, (==?), extension)
11import Test.Framework.Providers.HUnit (testCase)
12import Test.HUnit (Assertion, assertFailure, assertBool)
14import qualified Elm.Compiler as Compiler
20 goods <- testIf isSuccess =<< getElms "good"
21 bads <- testIf isFailure =<< getElms "bad"
23 testGroup "Compile Tests"
24 [ testGroup "Good Tests" goods
25 , testGroup "Bad Tests" bads
31getElms :: FilePath -> IO [FilePath]
35 (extension ==? ".elm")
36 (testsDir </> filePath)
41 "tests" </> "test-files"
47 :: (Either String Compiler.Result -> Assertion)
50testIf handleResult filePaths =
51 traverse setupTest filePaths
53 setupTest filePath = do
54 source <- readFile filePath
57 Compiler.Context "elm-lang" "core" True False
58 let (dealiaser, _warnings, result) =
59 Compiler.compile context source Map.empty
60 let formatErrors errors =
61 concatMap (Compiler.errorToString dealiaser filePath source) errors
63 either (Left . formatErrors) Right result
65 return $ testCase filePath (handleResult formattedResult)
70isSuccess :: Either String a -> Assertion
77 assertFailure errorMessages
80isFailure :: Either a b -> Assertion
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