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
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 :: (([Compiler.Warning], Either [Compiler.Error] (Module.Interface, String)) -> Assertion)
50testIf handleResult filePaths =
51 traverse setupTest filePaths
54 do source <- readFile filePath
55 let result = Compiler.compile "elm-lang" "core" True source Map.empty
56 return (testCase filePath (handleResult result))
61isSuccess :: ([Compiler.Warning], Either [Compiler.Error] a) -> Assertion
62isSuccess (_, result) =
64 Right _ -> assertBool "" True
65 Left errors -> assertFailure $ (unlines $ map (Compiler.errorToString "" "") errors)
68isFailure :: ([Compiler.Warning], Either a b) -> Assertion
69isFailure (_, result) =
71 Right _ -> assertFailure "Compilation succeeded but should have failed"
72 Left _ -> assertBool "" True
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