@@ -1,38 +1,8 @@
1module Main where
1module Main where
3−import Data.Functor ((<$>))
4−import Data.Traversable (traverse)
5−import System.FilePath.Find (find, (==?), extension)
6import Test.Framework
3import Test.Framework
7−import Test.Framework.Providers.HUnit (testCase)
8−import Test.HUnit ((@=?), Assertion)
10−import Elm.Internal.Utils as Elm
5+import Tests.Compiler
12main :: IO ()
7main :: IO ()
13−main = defaultMain [compilerTests]
8+main = defaultMain [ compilerTests ]
16−compilerTests = buildTest $ do
17− goods <- getElms "tests/good" >>= mkTests True
18− bads <- getElms "tests/bad" >>= mkTests False
20− return $ testGroup "Compile Tests"
22− testGroup "Good Tests" goods
23− , testGroup "Bad Tests" bads
26− where getElms :: FilePath -> IO [FilePath]
27− getElms = find (return True) (extension ==? ".elm")
29− mkTests :: Bool -> [FilePath] -> IO [Test]
30− mkTests b = traverse setupTest
31− where setupTest f = testCase f . mkCompileTest b <$> readFile f
33−mkCompileTest :: Bool -- ^ Expect success?
34− -> String -- ^ File Contents
36−mkCompileTest succ modul = noCompileErr @=? succ
37− where noCompileErr = either (const False) (const True) . Elm.compile $ modul
38− expectation = "Compile " ++ if succ then "Success" else "Error"