on master help sign in
cosmetic: get style more in line with rest of compiler
commit069a4c5a857a86697a38204b6965ca3c17d7a175 authorEvan Czaplicki <info@elm-lang.org> dateFri 13 Jun 2014, 12:25 (12 years ago) parent223b4df
1 file changed+27−23
tests/compiler/Tests/Compiler.hs+27−23
tests/compiler/Tests/Compiler.hs+27−23
@@ -1,5 +1,4 @@
1−module Tests.Compiler (compilerTests)
2− where
1+module Tests.Compiler (compilerTests) where
32
43import Data.Functor ((<$>))
54import Data.Traversable (traverse)
@@ -13,31 +12,36 @@ import Text.Parsec (ParseError)
1312import Elm.Internal.Utils as Elm
1413
1514compilerTests :: Test
16−compilerTests = buildTest $ do
17− goods <- mkTests goodCompile =<< getElms "good"
18− bads <- mkTests badCompile =<< getElms "bad"
19− return $ testGroup "Compile Tests"
20− [
21− testGroup "Good Tests" goods
22− , testGroup "Bad Tests" bads
23− ]
24−
25− where getElms :: FilePath -> IO [FilePath]
26− getElms fname = find (return True) (extension ==? ".elm") (testsDir </> fname)
27−
28− mkTests :: (Either String String -> Assertion) -> [FilePath] -> IO [Test]
29− mkTests h = traverse setupTest
30− where setupTest f = testCase f . mkCompileTest h <$> readFile f
31−
32− testsDir = "tests" </> "compiler" </> "test-files"
15+compilerTests =
16+ buildTest $ do
17+ goods <- mkTests goodCompile =<< getElms "good"
18+ bads <- mkTests badCompile =<< getElms "bad"
19+ return $ testGroup "Compile Tests"
20+ [ testGroup "Good Tests" goods
21+ , testGroup "Bad Tests" bads
22+ ]
23+ where
24+ getElms :: FilePath -> IO [FilePath]
25+ getElms fname = find (return True) (extension ==? ".elm") (testsDir </> fname)
26+
27+ mkTests :: (Either String String -> Assertion) -> [FilePath] -> IO [Test]
28+ mkTests h = traverse setupTest
29+ where setupTest f = testCase f . mkCompileTest h <$> readFile f
30+
31+ testsDir :: FilePath
32+ testsDir = "tests" </> "compiler" </> "test-files"
3333
3434goodCompile :: Either String String -> Assertion
35−goodCompile (Left err) = assertFailure err
36−goodCompile (Right _) = assertBool "" True
35+goodCompile result =
36+ case result of
37+ Left err -> assertFailure err
38+ Right _ -> assertBool "" True
3739
3840badCompile :: Either String String -> Assertion
39−badCompile (Left _) = assertBool "" True
40−badCompile (Right _) = assertFailure "Compilation succeeded but should have failed"
41+badCompile result =
42+ case result of
43+ Left _ -> assertBool "" True
44+ Right _ -> assertFailure "Compilation succeeded but should have failed"
4145
4246mkCompileTest :: ((Either String String) -> Assertion) -- ^ Handler
4347 -> String -- ^ File Contents