@@ -1,5 +1,4 @@
1−module Tests.Compiler (compilerTests)
1+module Tests.Compiler (compilerTests) where
4import Data.Functor ((<$>))
3import Data.Functor ((<$>))
5import Data.Traversable (traverse)
4import Data.Traversable (traverse)
@@ -13,31 +12,36 @@ import Text.Parsec (ParseError)
13import Elm.Internal.Utils as Elm
12import Elm.Internal.Utils as Elm
15compilerTests :: Test
14compilerTests :: Test
16−compilerTests = buildTest $ do
15+compilerTests =
17− goods <- mkTests goodCompile =<< getElms "good"
17+ goods <- mkTests goodCompile =<< getElms "good"
18− bads <- mkTests badCompile =<< getElms "bad"
18+ bads <- mkTests badCompile =<< getElms "bad"
19− return $ testGroup "Compile Tests"
19+ return $ testGroup "Compile Tests"
21− testGroup "Good Tests" goods
20+ [ testGroup "Good Tests" goods
22− , testGroup "Bad Tests" bads
21+ , testGroup "Bad Tests" bads
25− where getElms :: FilePath -> IO [FilePath]
24+ getElms :: FilePath -> IO [FilePath]
26− getElms fname = find (return True) (extension ==? ".elm") (testsDir </> fname)
25+ getElms fname = find (return True) (extension ==? ".elm") (testsDir </> fname)
28− mkTests :: (Either String String -> Assertion) -> [FilePath] -> IO [Test]
27+ mkTests :: (Either String String -> Assertion) -> [FilePath] -> IO [Test]
29− mkTests h = traverse setupTest
28+ mkTests h = traverse setupTest
30− where setupTest f = testCase f . mkCompileTest h <$> readFile f
29+ where setupTest f = testCase f . mkCompileTest h <$> readFile f
32− testsDir = "tests" </> "compiler" </> "test-files"
32+ testsDir = "tests" </> "compiler" </> "test-files"
34goodCompile :: Either String String -> Assertion
34goodCompile :: Either String String -> Assertion
35−goodCompile (Left err) = assertFailure err
37+ Left err -> assertFailure err
36−goodCompile (Right _) = assertBool "" True
38+ Right _ -> assertBool "" True
38badCompile :: Either String String -> Assertion
40badCompile :: Either String String -> Assertion
39−badCompile (Left _) = assertBool "" True
43+ Left _ -> assertBool "" True
40−badCompile (Right _) = assertFailure "Compilation succeeded but should have failed"
44+ Right _ -> assertFailure "Compilation succeeded but should have failed"
42mkCompileTest :: ((Either String String) -> Assertion) -- ^ Handler
46mkCompileTest :: ((Either String String) -> Assertion) -- ^ Handler
43 -> String -- ^ File Contents
47 -> String -- ^ File Contents