on master help sign in
Style tweaks and use cross-platform file name construction.
commitdcac0e0d5c41d12b61a1af5cd8de47c79573bcac authorMax New <maxsnew@gmail.com> dateMon 30 Dec 2013, 02:19 (13 years ago) parent37f5d9e
2 files changed+7−5
tests/Tests/Compiler.hs+6−4 tests/Tests/Property/Arbitrary.hs+1−1
tests/Tests/Compiler.hs+6−4
@@ -3,6 +3,7 @@ module Tests.Compiler (compilerTests)
33
44import Data.Functor ((<$>))
55import Data.Traversable (traverse)
6+import System.FilePath ((</>))
67import System.FilePath.Find (find, (==?), extension)
78import Test.Framework
89import Test.Framework.Providers.HUnit (testCase)
@@ -12,9 +13,8 @@ import Elm.Internal.Utils as Elm
1213
1314compilerTests :: Test
1415compilerTests = buildTest $ do
15− goods <- getElms "tests/data/good" >>= mkTests True
16− bads <- getElms "tests/data/bad" >>= mkTests False
17−
16+ goods <- mkTests True =<< getElms "good"
17+ bads <- mkTests False =<< getElms "bad"
1818 return $ testGroup "Compile Tests"
1919 [
2020 testGroup "Good Tests" goods
@@ -22,12 +22,14 @@ compilerTests = buildTest $ do
2222 ]
2323
2424 where getElms :: FilePath -> IO [FilePath]
25− getElms = find (return True) (extension ==? ".elm")
25+ getElms fname = find (return True) (extension ==? ".elm") (testsDir </> fname)
2626
2727 mkTests :: Bool -> [FilePath] -> IO [Test]
2828 mkTests b = traverse setupTest
2929 where setupTest f = testCase f . mkCompileTest b <$> readFile f
3030
31+ testsDir = "tests" </> "data"
32+
3133mkCompileTest :: Bool -- ^ Expect success?
3234 -> String -- ^ File Contents
3335 -> Assertion
tests/Tests/Property/Arbitrary.hs+1−1
@@ -49,7 +49,7 @@ instance Arbitrary Pattern where
4949 shrink pat = case pat of
5050 PAnything -> []
5151 PVar v -> PVar <$> shrinkWHead v
52− PRecord fs -> PRecord <$> (filter (all $ not.null) . filter (not.null) $ shrink fs)
52+ PRecord fs -> PRecord <$> (filter (all $ not . null) . filter (not . null) $ shrink fs)
5353 PLiteral l -> PLiteral <$> shrink l
5454 PAlias s p -> p : (PAlias <$> shrinkWHead s <*> shrink p)
5555 PData s ps -> ps ++ (PData <$> shrinkWHead s <*> shrink ps)