diff options
author | Erin van der Veen | 2017-11-20 13:37:55 +0100 |
---|---|---|
committer | Erin van der Veen | 2017-11-20 13:37:55 +0100 |
commit | 46fd03ef6468a24fb69d08a1726cb4068a62cd30 (patch) | |
tree | 25b30bd3225fdf040393f6a088572e090225b2a9 /test/Test.hs | |
parent | Add number of pieces property test (diff) | |
parent | Add pieceCoords (diff) |
Merge remote-tracking branch 'origin/master' into 1-quickcheck-property-niet-meer-stukken-op-het-bord-na-een-zet
Diffstat (limited to 'test/Test.hs')
-rw-r--r-- | test/Test.hs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/test/Test.hs b/test/Test.hs index e07fcc5..7155d84 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -8,6 +8,7 @@ import Data.ByteString.Char8 (pack) import Data.Either import Data.List +import Data.Maybe import Control.Monad @@ -77,12 +78,19 @@ makePGN event site date round white black result moves = tagPair :: String -> String -> String tagPair tag val = "[" ++ tag ++ " \"" ++ val ++ "\"]\r\n" +-- From Chess.hs, with adaptations +pieceCoords :: Maybe Color -> Maybe PieceType -> Board -> [((Int,Int),Piece)] +pieceCoords clr piece brd = [(i,pc) | (i,Just pc) <- (assocs $ board brd), match pc] + where + match :: Piece -> Bool + match (Piece clr' piece') = + (isJust clr && clr' == fromJust clr || isNothing clr) && + (isJust piece && piece' == fromJust piece || isNothing piece) + prop_only_2_kings :: PGN -> Bool prop_only_2_kings = atAnyState (\b -> - length (pieceCoords Black b King) == 1 && - length (pieceCoords White b King) == 1) - where - pieceCoords clr brd piece = [i | (i, pc) <- (assocs $ board brd), pc == Just (Piece clr piece)] + length (pieceCoords (Just Black) (Just King) b) == 1 && + length (pieceCoords (Just White) (Just King) b) == 1) prop_number_of_pieces :: PGN -> Bool prop_number_of_pieces = atAnyTwoStates (\b1 b2 -> |