diff options
author | Erin van der Veen | 2017-11-20 13:59:28 +0100 |
---|---|---|
committer | Erin van der Veen | 2017-11-20 13:59:28 +0100 |
commit | e37ce07f0374cd6cc9adbee48a2d23ab8388e56f (patch) | |
tree | 6b2cf32fa98af4c2c2209b7688e0d6accd55c2ed /test | |
parent | Merge branch '7-quickcheck-property-if-a-side-was-in-check-before-a-ply-he-sh... (diff) | |
parent | nomenclature (diff) |
Merge branch '5-quickcheck-property-there-can-never-be-a-pawn-on-rank-a-and-h' into 'master'
Add prop_no_pawns_on_1_and_8
Closes #5
See merge request eveen/Testing-Techniques!4
Diffstat (limited to 'test')
-rw-r--r-- | test/Test.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/test/Test.hs b/test/Test.hs index b9f58b3..bfe9f55 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -77,7 +77,7 @@ makePGN event site date round white black result moves = -- 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] +pieceCoords clr piece brd = [(i,pc) | (i,Just pc) <- assocs $ board brd, match pc] where match :: Piece -> Bool match (Piece clr' piece') = @@ -89,6 +89,12 @@ prop_only_2_kings = atAnyState (\b -> length (pieceCoords (Just Black) (Just King) b) == 1 && length (pieceCoords (Just White) (Just King) b) == 1) +prop_no_pawns_on_1_and_8 :: PGN -> Bool +prop_no_pawns_on_1_and_8 = atAnyState $ all notOnAorH . pieceCoords Nothing (Just Pawn) + where + notOn1or8 :: ((Int,Int),a) -> Bool + notOn1or8 ((_,r),_) = r /= 0 && r /= 7 + prop_number_of_pieces :: PGN -> Bool prop_number_of_pieces = atAnyTwoStates (\b1 b2 -> length (pieceCoords Nothing Nothing b1) == length (pieceCoords Nothing Nothing b2) |