Created
October 9, 2013 17:40
-
-
Save jsl/6905165 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Test.HUnit | |
import Control.Applicative | |
data Piece = Cross | Circle deriving (Show, Eq) | |
isWon :: [Maybe Piece] -> Bool | |
isWon [] = False | |
isWon (x:xs) | |
| x == Nothing = False | |
| null xs = True | |
| x /= head xs = False | |
| otherwise = isWon xs | |
isWonTests = TestList [ | |
"test list with Nothing" ~: False ~=? (isWon [Nothing]) | |
, "test unequal list" ~: False ~=? | |
(isWon [Just Circle, Just Cross]) | |
, "test empty list" ~: False ~=? (isWon []) | |
, "test won list" ~: True ~=? | |
(isWon [Just Circle, Just Circle]) | |
] | |
main = runTestTT isWonTests |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment