From dcac0e0d5c41d12b61a1af5cd8de47c79573bcac Mon Sep 17 00:00:00 2001 From: Max New Date: Mon, 30 Dec 2013 02:19:02 -0600 Subject: [PATCH] Style tweaks and use cross-platform file name construction. --- tests/Tests/Compiler.hs | 10 ++++++---- tests/Tests/Property/Arbitrary.hs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/Tests/Compiler.hs b/tests/Tests/Compiler.hs index 81162c8f7..1bd2e8598 100644 --- a/tests/Tests/Compiler.hs +++ b/tests/Tests/Compiler.hs @@ -3,6 +3,7 @@ module Tests.Compiler (compilerTests) import Data.Functor ((<$>)) import Data.Traversable (traverse) +import System.FilePath (()) import System.FilePath.Find (find, (==?), extension) import Test.Framework import Test.Framework.Providers.HUnit (testCase) @@ -12,9 +13,8 @@ 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 - + goods <- mkTests True =<< getElms "good" + bads <- mkTests False =<< getElms "bad" return $ testGroup "Compile Tests" [ testGroup "Good Tests" goods @@ -22,12 +22,14 @@ compilerTests = buildTest $ do ] where getElms :: FilePath -> IO [FilePath] - getElms = find (return True) (extension ==? ".elm") + getElms fname = find (return True) (extension ==? ".elm") (testsDir fname) mkTests :: Bool -> [FilePath] -> IO [Test] mkTests b = traverse setupTest where setupTest f = testCase f . mkCompileTest b <$> readFile f + testsDir = "tests" "data" + mkCompileTest :: Bool -- ^ Expect success? -> String -- ^ File Contents -> Assertion diff --git a/tests/Tests/Property/Arbitrary.hs b/tests/Tests/Property/Arbitrary.hs index 3c643769a..f9b778770 100644 --- a/tests/Tests/Property/Arbitrary.hs +++ b/tests/Tests/Property/Arbitrary.hs @@ -49,7 +49,7 @@ instance Arbitrary Pattern where shrink pat = case pat of PAnything -> [] PVar v -> PVar <$> shrinkWHead v - PRecord fs -> PRecord <$> (filter (all $ not.null) . filter (not.null) $ shrink fs) + PRecord fs -> PRecord <$> (filter (all $ not . null) . filter (not . null) $ shrink fs) PLiteral l -> PLiteral <$> shrink l PAlias s p -> p : (PAlias <$> shrinkWHead s <*> shrink p) PData s ps -> ps ++ (PData <$> shrinkWHead s <*> shrink ps)