on master help sign in
Re-org tests
commit1408d928d55e2d9bd8c11da1cce8570f7bcd6fa2 authorMax New <maxsnew@gmail.com> dateSun 29 Dec 2013, 15:04 (13 years ago) parent840eca6
17 files changed+38−32
tests/Main.hs+2−32 tests/Tests/Compiler.hs+36 tests/bad/BBTArgs → tests/data/bad/BBTArgs tests/bad/InfiniteType.elm → tests/data/bad/InfiniteType.elm tests/bad/NonElementMain.elm → tests/data/bad/NonElementMain.elm tests/good/AliasSubstitution.elm → tests/data/good/AliasSubstitution.elm tests/good/NoExpressions.elm → tests/data/good/NoExpressions.elm tests/good/Otherwise.elm → tests/data/good/Otherwise.elm tests/good/QuotesAndComments.elm → tests/data/good/QuotesAndComments.elm tests/good/Soundness/Apply.elm → tests/data/good/Soundness/Apply.elm tests/good/Soundness/ApplyAnnotated.elm → tests/data/good/Soundness/ApplyAnnotated.elm tests/good/Soundness/Id.elm → tests/data/good/Soundness/Id.elm tests/good/Soundness/IdAnnotated.elm → tests/data/good/Soundness/IdAnnotated.elm tests/good/Soundness/TrickyId.elm → tests/data/good/Soundness/TrickyId.elm tests/good/Soundness/TrickyIdAnnotated.elm → tests/data/good/Soundness/TrickyIdAnnotated.elm tests/good/Unify/LockedVars.elm → tests/data/good/Unify/LockedVars.elm tests/good/Unify/NonHomogeneousRecords.elm → tests/data/good/Unify/NonHomogeneousRecords.elm
tests/Main.hs+2−32
@@ -1,38 +1,8 @@
11module Main where
22
3−import Data.Functor ((<$>))
4−import Data.Traversable (traverse)
5−import System.FilePath.Find (find, (==?), extension)
63import Test.Framework
7−import Test.Framework.Providers.HUnit (testCase)
8−import Test.HUnit ((@=?), Assertion)
94
10−import Elm.Internal.Utils as Elm
5+import Tests.Compiler
116
127main :: IO ()
13−main = defaultMain [compilerTests]
14−
15−compilerTests :: Test
16−compilerTests = buildTest $ do
17− goods <- getElms "tests/good" >>= mkTests True
18− bads <- getElms "tests/bad" >>= mkTests False
19−
20− return $ testGroup "Compile Tests"
21− [
22− testGroup "Good Tests" goods
23− , testGroup "Bad Tests" bads
24− ]
25−
26− where getElms :: FilePath -> IO [FilePath]
27− getElms = find (return True) (extension ==? ".elm")
28−
29− mkTests :: Bool -> [FilePath] -> IO [Test]
30− mkTests b = traverse setupTest
31− where setupTest f = testCase f . mkCompileTest b <$> readFile f
32−
33−mkCompileTest :: Bool -- ^ Expect success?
34− -> String -- ^ File Contents
35− -> Assertion
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"
8+main = defaultMain [ compilerTests ]
tests/Tests/Compiler.hsnew file+36
@@ -0,0 +1,36 @@
1+module Tests.Compiler (compilerTests)
2+ where
3+
4+import Data.Functor ((<$>))
5+import Data.Traversable (traverse)
6+import System.FilePath.Find (find, (==?), extension)
7+import Test.Framework
8+import Test.Framework.Providers.HUnit (testCase)
9+import Test.HUnit ((@=?), Assertion)
10+
11+import Elm.Internal.Utils as Elm
12+
13+compilerTests :: Test
14+compilerTests = buildTest $ do
15+ goods <- getElms "tests/data/good" >>= mkTests True
16+ bads <- getElms "tests/data/bad" >>= mkTests False
17+
18+ return $ testGroup "Compile Tests"
19+ [
20+ testGroup "Good Tests" goods
21+ , testGroup "Bad Tests" bads
22+ ]
23+
24+ where getElms :: FilePath -> IO [FilePath]
25+ getElms = find (return True) (extension ==? ".elm")
26+
27+ mkTests :: Bool -> [FilePath] -> IO [Test]
28+ mkTests b = traverse setupTest
29+ where setupTest f = testCase f . mkCompileTest b <$> readFile f
30+
31+mkCompileTest :: Bool -- ^ Expect success?
32+ -> String -- ^ File Contents
33+ -> Assertion
34+mkCompileTest succ modul = noCompileErr @=? succ
35+ where noCompileErr = either (const False) (const True) . Elm.compile $ modul
36+ expectation = "Compile " ++ if succ then "Success" else "Error"
tests/bad/BBTArgs → tests/data/bad/BBTArgsrenamed

The content is the same.

tests/bad/InfiniteType.elm → tests/data/bad/InfiniteType.elmrenamed

The content is the same.

tests/bad/NonElementMain.elm → tests/data/bad/NonElementMain.elmrenamed

The content is the same.

tests/good/AliasSubstitution.elm → tests/data/good/AliasSubstitution.elmrenamed

The content is the same.

tests/good/NoExpressions.elm → tests/data/good/NoExpressions.elmrenamed

The content is the same.

tests/good/Otherwise.elm → tests/data/good/Otherwise.elmrenamed

The content is the same.

tests/good/QuotesAndComments.elm → tests/data/good/QuotesAndComments.elmrenamed

The content is the same.

tests/good/Soundness/Apply.elm → tests/data/good/Soundness/Apply.elmrenamed

The content is the same.

tests/good/Soundness/ApplyAnnotated.elm → tests/data/good/Soundness/ApplyAnnotated.elmrenamed

The content is the same.

tests/good/Soundness/Id.elm → tests/data/good/Soundness/Id.elmrenamed

The content is the same.

tests/good/Soundness/IdAnnotated.elm → tests/data/good/Soundness/IdAnnotated.elmrenamed

The content is the same.

tests/good/Soundness/TrickyId.elm → tests/data/good/Soundness/TrickyId.elmrenamed

The content is the same.

tests/good/Soundness/TrickyIdAnnotated.elm → tests/data/good/Soundness/TrickyIdAnnotated.elmrenamed

The content is the same.

tests/good/Unify/LockedVars.elm → tests/data/good/Unify/LockedVars.elmrenamed

The content is the same.

tests/good/Unify/NonHomogeneousRecords.elm → tests/data/good/Unify/NonHomogeneousRecords.elmrenamed

The content is the same.