diff options
-rw-r--r-- | test/Test.hs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/Test.hs b/test/Test.hs index 4aa3197..7155d84 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -28,6 +28,15 @@ atAnyState ok pgn = and [ok b | Right b <- seqList [moveSAN m | m <- moves pgn] seqList _ (Left _) = [] seqList [] _ = [] +atAnyTwoStates :: (Board -> Board -> Bool) -> PGN -> Bool +atAnyTwoStates ok pgn = and [ok b1 b2 | Right b1 <- seqList [moveSAN m | m <- moves pgn] | Right b2 <- seqList [moveSAN m | m <- moves pgn] $ Right defaultBoard] + where + seqList :: [r -> Either e r] -> Either e r -> [Either e r] + seqList (f:fs) (Right io) = f io:seqList fs (f io) + seqList _ (Left _) = [] + seqList [] _ = [] + + prop_checkPGN :: PGN -> Bool prop_checkPGN pgn | isLeft parsed = False @@ -83,5 +92,12 @@ prop_only_2_kings = atAnyState (\b -> 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 -> + length (pieceCoords Nothing Nothing b1) == length (pieceCoords Nothing Nothing b2) + || + length (pieceCoords Nothing Nothing b1) - 1 == length (pieceCoords Nothing Nothing b2) + ) + return [] main = $forAllProperties (quickCheckWithResult (stdArgs {maxSuccess=10000})) |