1module Tests.Compiler (compilerTests)
4import Data.Functor ((<$>))
5import Data.Traversable (traverse)
6import System.FilePath ((</>))
7import System.FilePath.Find (find, (==?), extension)
9import Test.Framework.Providers.HUnit (testCase)
10import Test.HUnit (Assertion, assertFailure, assertBool)
11import Text.Parsec (ParseError)
13import Elm.Internal.Utils as Elm
16compilerTests = buildTest $ do
17 goods <- mkTests goodCompile =<< getElms "good"
18 bads <- mkTests badCompile =<< getElms "bad"
19 return $ testGroup "Compile Tests"
21 testGroup "Good Tests" goods
22 , testGroup "Bad Tests" bads
25 where getElms :: FilePath -> IO [FilePath]
26 getElms fname = find (return True) (extension ==? ".elm") (testsDir </> fname)
28 mkTests :: (Either String String -> Assertion) -> [FilePath] -> IO [Test]
29 mkTests h = traverse setupTest
30 where setupTest f = testCase f . mkCompileTest h <$> readFile f
32 testsDir = "tests" </> "test-files"
34goodCompile :: Either String String -> Assertion
35goodCompile (Left err) = assertFailure err
36goodCompile (Right _) = assertBool "" True
38badCompile :: Either String String -> Assertion
39badCompile (Left _) = assertBool "" True
40badCompile (Right _) = assertFailure "Compilation succeeded but should have failed"
42mkCompileTest :: ((Either String String) -> Assertion) -- ^ Handler
43 -> String -- ^ File Contents
45mkCompileTest handle = handle . Elm.compile
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