From dfbb330c9b670aa4f18180b180ccdc32452a2d6a Mon Sep 17 00:00:00 2001 From: Slash Date: Sun, 9 Aug 2015 11:55:13 +0200 Subject: [PATCH] tests are working again --- src/Tests.hs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/Tests.hs b/src/Tests.hs index 82bf0be..e61fdc3 100644 --- a/src/Tests.hs +++ b/src/Tests.hs @@ -1,6 +1,8 @@ import Datatypes import VM +import qualified Datatypes.Unit as Unit + import Data.Hashable (hash, Hashable(..)) import Data.Set (Set) import qualified Data.Set as Set @@ -12,7 +14,7 @@ test f = [f (0,3) == (2,5), f (1,3) == (3, 6), f (2,3) == (3,7), f (3, 3) == (4, test2 :: (Cell -> Cell) -> [Bool] test2 f = [f (2,5) == (3,6), f (3,6) == (2, 7), f (2,7) == (1,7), f (1, 7) == (1,6), f (1, 6) == (1,5), f (1, 5) == (2, 5)] -deepCheck p = quickCheckWith (stdArgs { maxSuccess = 10000 }) p +deepCheck p = quickCheckWith (stdArgs { maxSuccess = 100000 }) p testTutto = do deepCheck (\pivot cell -> let r2 = rotateCell pivot in (r2 . r2 . r2 . r2 . r2 . r2) cell == cell) @@ -32,21 +34,21 @@ testTutteRotazioni = checkForNothing [ testControRotazioni (5, 5) [(6,1), (8,4), (7, 8), (4,9), (1,6), (2,2), (5,5)] ] ---testCentering = deepCheck (\up um um1 -> let b = Board 5 10 (Set.fromList []) --- u = Unit (Set.fromList (um1:um)) up --- c = centerUnit u b --- bw = 5 --- xCoords = Set.map (\(x, y) -> x) (unitMembers c) --- yCoords = Set.map (\(x, y) -> y) (unitMembers c) --- unitLeft = Set.findMin xCoords --- unitRight = Set.findMax xCoords --- unitTop = Set.findMin yCoords --- deltaLeft = unitLeft --- deltaRight = bw - unitRight - 1 --- in (deltaLeft == deltaRight || (deltaRight - deltaLeft) == 1) && unitTop == 0) +testCentering = deepCheck (\up um um1 -> let b = Board 5 10 (Set.fromList []) + u = Unit up (Set.fromList (um1:um)) + c = Unit.centeredIn u b + bw = 5 + xCoords = Set.map (\(x, y) -> x) (Unit.members c) + yCoords = Set.map (\(x, y) -> y) (Unit.members c) + unitLeft = Set.findMin xCoords + unitRight = Set.findMax xCoords + unitTop = Set.findMin yCoords + deltaLeft = unitLeft + deltaRight = bw - unitRight - 1 + in (deltaLeft == deltaRight || (deltaRight - deltaLeft) == 1) && unitTop == 0) testGame = let board = Board 5 10 (Set.fromList []) - unit = Unit (Set.fromList [(2, 8)]) (2, 8) + unit = Unit (2, 8) (Set.fromList [(2, 8)]) game = Game board [unit] (Set.fromList [hash unit]) in game