From 16c4dd1ba2ef4aeca1cb21c8d75fb3939507a7ba Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 21 Nov 2017 10:02:55 +0100 Subject: Don't shrink test cases; this always reduces to the moves '' which gives a runtime error --- test/ArbitraryMove.hs | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/ArbitraryMove.hs b/test/ArbitraryMove.hs index df3d7fb..486eb36 100644 --- a/test/ArbitraryMove.hs +++ b/test/ArbitraryMove.hs @@ -56,8 +56,6 @@ instance Arbitrary PGN sensibleString = listOf $ choose ('a', 'z') - shrink pgn = [pgn {moves=ms} | ms <- shrink $ moves pgn] - {- This file can largely be generated with the following pipeline: - - grep -v '^\(\[\|$\)' \ -- cgit v1.2.3 From 4707c68955ec0d9e38e7b5430c7100434c2334e0 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 22 Nov 2017 16:36:00 +0100 Subject: Add prop_dont_touch_my_pieces --- test/Test.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/Test.hs b/test/Test.hs index f8a8729..f451c75 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -5,8 +5,8 @@ module Test where import Data.Array import Data.Attoparsec.ByteString.Char8 import Data.ByteString.Char8 (pack) - import Data.Either +import Data.Function import Data.List import Data.Maybe @@ -107,5 +107,11 @@ prop_not_in_check_twice = atAnyTwoStates (\b1 b2 -> not (check Black b1 && check Black b2) && not (check White b1 && check White b2)) +prop_dont_touch_my_pieces :: PGN -> Bool +prop_dont_touch_my_pieces = atAnyTwoStates (\b1 b2 -> notMoved (turn b2) b1 b2) + where + notMoved :: Color -> Board -> Board -> Bool + notMoved c = (==) `on` pieceCoords (Just c) Nothing + return [] main = $forAllProperties (quickCheckWithResult (stdArgs {maxSuccess=10000})) -- cgit v1.2.3 From 5bf752794a6637f1bf4fa8b97a5fbce22f3fb1b4 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 22 Nov 2017 16:51:58 +0100 Subject: Fix prop_dont_touch_my_pieces for caught pieces --- test/Test.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Test.hs b/test/Test.hs index 032e125..91849c2 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -118,7 +118,7 @@ prop_dont_touch_my_pieces :: PGN -> Bool prop_dont_touch_my_pieces = atAnyTwoStates (\b1 b2 -> notMoved (turn b2) b1 b2) where notMoved :: Color -> Board -> Board -> Bool - notMoved c = (==) `on` pieceCoords (Just c) Nothing + notMoved c = (\b a -> null (a \\ b)) `on` pieceCoords (Just c) Nothing return [] main = $forAllProperties (quickCheckWithResult (stdArgs {maxSuccess=10000})) -- cgit v1.2.3