diff options
author | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2016-03-28 04:20:12 +0200 |
---|---|---|
committer | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2016-03-28 04:20:12 +0200 |
commit | b0774a09f67ee2da51b290ba625cc407be8b2518 (patch) | |
tree | 3242445e16fab329a3d699bea5ae70ee0d155425 /8puzzle | |
parent | bb67830de2f7fbaf2b95245cbb37f09d841f6790 (diff) |
Add failing puzzle test.
Diffstat (limited to '8puzzle')
-rw-r--r-- | 8puzzle/PuzzleTest.hs | 5 |
1 files changed, 4 insertions, 1 deletions
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 |