Skip to content

Commit

Permalink
Style tweaks and use cross-platform file name construction.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsnew committed Dec 30, 2013
1 parent 37f5d9e commit dcac0e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions tests/Tests/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -12,22 +13,23 @@ 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
, testGroup "Bad Tests" bads
]

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
Expand Down
2 changes: 1 addition & 1 deletion tests/Tests/Property/Arbitrary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dcac0e0

Please sign in to comment.