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
15import qualified Elm.Compiler.Module as Module
21 goods <- testIf isSuccess =<< getElms "good"
22 bads <- testIf isFailure =<< getElms "bad"
24 testGroup "Compile Tests"
25 [ testGroup "Good Tests" goods
26 , testGroup "Bad Tests" bads
32getElms :: FilePath -> IO [FilePath]
36 (extension ==? ".elm")
37 (testsDir </> filePath)
42 "tests" </> "test-files"
48 :: (Either String (Module.Interface, String) -> Assertion)
51testIf handleResult filePaths =
52 traverse setupTest filePaths
54 setupTest filePath = do
55 source <- readFile filePath
57 let (dealiaser, _warnings, result) =
58 Compiler.compile "elm-lang" "core" True source Map.empty
59 let formatErrors errors =
60 concatMap (Compiler.errorToString dealiaser filePath source) errors
62 either (Left . formatErrors) Right result
64 return $ testCase filePath (handleResult formattedResult)
69isSuccess :: Either String a -> Assertion
76 assertFailure errorMessages
79isFailure :: Either a b -> Assertion
83 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