diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Test.hs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/test/Test.hs b/test/Test.hs index b162a9f..1eea3ce 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -30,13 +30,17 @@ atAnyState = atAnyTwoStates . const atAnyTwoStates :: (Board -> Board -> Bool) -> PGN -> Property atAnyTwoStates ok pgn = - let moveList = seqList [moveSAN m | m <- moves pgn] $ Right defaultBoard in - let moves = length moveList in - classify ( moves < 10) " <10 legal moves" $ - classify ( 10 <= moves && moves < 50) "10- 50 legal moves" $ - classify ( 50 <= moves && moves < 100) "50-100 legal moves" $ - classify (100 <= moves ) "100+ legal moves" $ - and [ok b1 b2 | Right b1 <- moveList | Right b2 <- tail moveList] + let moveList = seqList [\(_,b) -> (,) m <$> moveSAN m b | m <- moves pgn] $ Right ("", defaultBoard) in + let boards = [b | Right (_,b) <- moveList] in + let moves = [m | Right (m,_) <- moveList] in + let count = length moveList in + classify ( count < 10) " <10 legal moves" $ + classify ( 10 <= count && count < 50) "10- 50 legal moves" $ + classify ( 50 <= count && count < 100) "50-100 legal moves" $ + classify (100 <= count ) "100+ legal moves" $ + classify (any (`elem` ["O-O", "O-O-O"]) moves) "has castling" $ + classify (any (\b -> check White b || check Black b) boards) "has check" $ + and [ok b1 b2 | b1 <- boards | b2 <- tail boards] where seqList :: [r -> Either e r] -> Either e r -> [Either e r] seqList (f:fs) (Right io) = f io:seqList fs (f io) |