@@ -3,6 +3,7 @@ module Tests.Compiler (compilerTests)
4import Data.Functor ((<$>))
4import Data.Functor ((<$>))
5import Data.Traversable (traverse)
5import Data.Traversable (traverse)
6+import System.FilePath ((</>))
6import System.FilePath.Find (find, (==?), extension)
7import System.FilePath.Find (find, (==?), extension)
7import Test.Framework
8import Test.Framework
8import Test.Framework.Providers.HUnit (testCase)
9import Test.Framework.Providers.HUnit (testCase)
@@ -12,9 +13,8 @@ import Elm.Internal.Utils as Elm
13compilerTests :: Test
14compilerTests :: Test
14compilerTests = buildTest $ do
15compilerTests = buildTest $ do
15− goods <- getElms "tests/data/good" >>= mkTests True
16+ goods <- mkTests True =<< getElms "good"
16− bads <- getElms "tests/data/bad" >>= mkTests False
17+ bads <- mkTests False =<< getElms "bad"
18 return $ testGroup "Compile Tests"
18 return $ testGroup "Compile Tests"
20 testGroup "Good Tests" goods
20 testGroup "Good Tests" goods
@@ -22,12 +22,14 @@ compilerTests = buildTest $ do
24 where getElms :: FilePath -> IO [FilePath]
24 where getElms :: FilePath -> IO [FilePath]
25− getElms = find (return True) (extension ==? ".elm")
25+ getElms fname = find (return True) (extension ==? ".elm") (testsDir </> fname)
27 mkTests :: Bool -> [FilePath] -> IO [Test]
27 mkTests :: Bool -> [FilePath] -> IO [Test]
28 mkTests b = traverse setupTest
28 mkTests b = traverse setupTest
29 where setupTest f = testCase f . mkCompileTest b <$> readFile f
29 where setupTest f = testCase f . mkCompileTest b <$> readFile f
31+ testsDir = "tests" </> "data"
31mkCompileTest :: Bool -- ^ Expect success?
33mkCompileTest :: Bool -- ^ Expect success?
32 -> String -- ^ File Contents
34 -> String -- ^ File Contents
33 -> Assertion
35 -> Assertion