From b0774a09f67ee2da51b290ba625cc407be8b2518 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Mon, 28 Mar 2016 04:20:12 +0200 Subject: Add failing puzzle test. --- 8puzzle/PuzzleTest.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to '8puzzle') diff --git a/8puzzle/PuzzleTest.hs b/8puzzle/PuzzleTest.hs index cbd88af..0044608 100644 --- a/8puzzle/PuzzleTest.hs +++ b/8puzzle/PuzzleTest.hs @@ -10,13 +10,14 @@ import Puzzle hiding (main) instance Arbitrary Puzzle where arbitrary = do - size <- choose (1, 10) + size <- choose (2, 4) board <- shuffle [0 .. (size*size - 1)] return $ Puzzle size (V.fromList board) False tests = [ testGroup "Board" [ testProperty "neighbors have distance of 1" prop_neighborDistance, + testProperty "can solve puzzle" prop_canSolvePuzzle, testCase "basic distance" test_distance ] ] @@ -27,6 +28,8 @@ test_distance = distance puzzle @?= 4 prop_neighborDistance p = all validNeighbor (neighbors p) where validNeighbor n = abs (distance p - distance n) == 1 +prop_canSolvePuzzle = not . null . solve + example = Puzzle 2 (V.fromList [1, 3, 2, 0]) False main = do -- cgit v1.2.3