Skip to content

Commit

Permalink
#24, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ndmitchell committed Jun 29, 2013
1 parent 9514eea commit da1a861
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Examples/Test/Files.hs
Expand Up @@ -8,10 +8,12 @@ import Data.List


main = shaken test $ \args obj -> do
want $ map obj ["even.txt","odd.txt"]
let fun = "@" `elem` args
let rest = delete "@" args
want $ map obj $ if null rest then ["even.txt","odd.txt"] else rest

let deps = map obj ["even.txt","odd.txt"]
let def | "fun" `elem` args = (?>>) (\x -> if x `elem` deps then Just deps else Nothing)
let def | fun = (?>>) (\x -> if x `elem` deps then Just deps else Nothing)
| otherwise = (*>>) deps

def $ \[evens,odds] -> do
Expand All @@ -20,11 +22,17 @@ main = shaken test $ \args obj -> do
writeFileLines evens $ map show es
writeFileLines odds $ map show os

map obj ["dir1/out.txt","dir2/out.txt"] *>> \[a,b] -> do
writeFile' a "a"
writeFile' b "b"


test build obj = do
forM_ [[],["fun"]] $ \args -> do
forM_ [[],["@"]] $ \args -> do
let nums = unlines . map show
writeFile (obj "numbers.txt") $ nums [1,2,4,5,2,3,1]
build ("--sleep":args)
assertContents (obj "even.txt") $ nums [2,4,2]
assertContents (obj "odd.txt" ) $ nums [1,5,3,1]
build ["clean"]
build ["dir1/out.txt"]

0 comments on commit da1a861

Please sign in to comment.