summaryrefslogtreecommitdiff
path: root/test/test_parser.hs
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_parser.hs')
-rw-r--r--test/test_parser.hs16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/test_parser.hs b/test/test_parser.hs
index e34218b..de9883e 100644
--- a/test/test_parser.hs
+++ b/test/test_parser.hs
@@ -14,11 +14,25 @@ import Chess
import Chess.FEN
import Chess.PGN
+import qualified ArbitraryMove as AM
+
deriving instance Eq PGN
instance Arbitrary GameResult where arbitrary = elements [BlackWon, WhiteWon, Draw]
instance Arbitrary Board where arbitrary = return defaultBoard
-arbitraryMove = return "e4"
+
+type Move = String
+
+arbitraryMove :: Gen Move
+arbitraryMove = frequency
+ [ (2, AM.arbitraryMove)
+ , (1, invalidMove)
+ ]
+ where
+ invalidMove :: Gen Move
+ invalidMove = oneof
+ [ liftM2 (\r c -> [r,c]) (choose ('i', 'z')) (elements "09")
+ ]
instance Arbitrary PGN
where