Re-org tests
This commit is contained in:
parent
840eca6573
commit
1408d928d5
17 changed files with 38 additions and 32 deletions
|
@ -1,38 +1,8 @@
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import Data.Functor ((<$>))
|
|
||||||
import Data.Traversable (traverse)
|
|
||||||
import System.FilePath.Find (find, (==?), extension)
|
|
||||||
import Test.Framework
|
import Test.Framework
|
||||||
import Test.Framework.Providers.HUnit (testCase)
|
|
||||||
import Test.HUnit ((@=?), Assertion)
|
|
||||||
|
|
||||||
import Elm.Internal.Utils as Elm
|
import Tests.Compiler
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = defaultMain [compilerTests]
|
main = defaultMain [ compilerTests ]
|
||||||
|
|
||||||
compilerTests :: Test
|
|
||||||
compilerTests = buildTest $ do
|
|
||||||
goods <- getElms "tests/good" >>= mkTests True
|
|
||||||
bads <- getElms "tests/bad" >>= mkTests False
|
|
||||||
|
|
||||||
return $ testGroup "Compile Tests"
|
|
||||||
[
|
|
||||||
testGroup "Good Tests" goods
|
|
||||||
, testGroup "Bad Tests" bads
|
|
||||||
]
|
|
||||||
|
|
||||||
where getElms :: FilePath -> IO [FilePath]
|
|
||||||
getElms = find (return True) (extension ==? ".elm")
|
|
||||||
|
|
||||||
mkTests :: Bool -> [FilePath] -> IO [Test]
|
|
||||||
mkTests b = traverse setupTest
|
|
||||||
where setupTest f = testCase f . mkCompileTest b <$> readFile f
|
|
||||||
|
|
||||||
mkCompileTest :: Bool -- ^ Expect success?
|
|
||||||
-> String -- ^ File Contents
|
|
||||||
-> Assertion
|
|
||||||
mkCompileTest succ modul = noCompileErr @=? succ
|
|
||||||
where noCompileErr = either (const False) (const True) . Elm.compile $ modul
|
|
||||||
expectation = "Compile " ++ if succ then "Success" else "Error"
|
|
||||||
|
|
36
tests/Tests/Compiler.hs
Normal file
36
tests/Tests/Compiler.hs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
module Tests.Compiler (compilerTests)
|
||||||
|
where
|
||||||
|
|
||||||
|
import Data.Functor ((<$>))
|
||||||
|
import Data.Traversable (traverse)
|
||||||
|
import System.FilePath.Find (find, (==?), extension)
|
||||||
|
import Test.Framework
|
||||||
|
import Test.Framework.Providers.HUnit (testCase)
|
||||||
|
import Test.HUnit ((@=?), Assertion)
|
||||||
|
|
||||||
|
import Elm.Internal.Utils as Elm
|
||||||
|
|
||||||
|
compilerTests :: Test
|
||||||
|
compilerTests = buildTest $ do
|
||||||
|
goods <- getElms "tests/data/good" >>= mkTests True
|
||||||
|
bads <- getElms "tests/data/bad" >>= mkTests False
|
||||||
|
|
||||||
|
return $ testGroup "Compile Tests"
|
||||||
|
[
|
||||||
|
testGroup "Good Tests" goods
|
||||||
|
, testGroup "Bad Tests" bads
|
||||||
|
]
|
||||||
|
|
||||||
|
where getElms :: FilePath -> IO [FilePath]
|
||||||
|
getElms = find (return True) (extension ==? ".elm")
|
||||||
|
|
||||||
|
mkTests :: Bool -> [FilePath] -> IO [Test]
|
||||||
|
mkTests b = traverse setupTest
|
||||||
|
where setupTest f = testCase f . mkCompileTest b <$> readFile f
|
||||||
|
|
||||||
|
mkCompileTest :: Bool -- ^ Expect success?
|
||||||
|
-> String -- ^ File Contents
|
||||||
|
-> Assertion
|
||||||
|
mkCompileTest succ modul = noCompileErr @=? succ
|
||||||
|
where noCompileErr = either (const False) (const True) . Elm.compile $ modul
|
||||||
|
expectation = "Compile " ++ if succ then "Success" else "Error"
|
Loading…
Reference in a new issue