Advertisement
Guest User

Untitled

a guest
Jun 8th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Main where
  2. import Test.Framework (testGroup,Test)
  3. import Test.Framework.Providers.HUnit
  4. import Test.HUnit hiding (Test)
  5. import Test.Framework (defaultMain)
  6. import Controller
  7. import Board
  8. import GameLogic
  9. import Model
  10. import Debug.Trace
  11.  
  12. -- http://jabberwocky.eu/2013/10/24/how-to-start-a-new-haskell-project/
  13.  
  14. testGroup1 :: Test
  15. testGroup1 = testGroup "grp"
  16.   [
  17.     testCase "case" (assertEqual "one is one" 1 1),
  18.     testCase "case1" (testCommandPhaseEndNoWarsTransitionToEnd),
  19.     -- testCase "case2" (testCommandPhaseEndToBattlePhaseTransition),
  20.     testCase "case4" (testWithCommandActionResultInBattleInit),
  21.     testCase "case21" (testCook )
  22.     ]
  23.  
  24. -- testGroup2 :: Test
  25. -- testGroup2 = testGroup "grp2"
  26. --  [testCase "case21" (testCook ) ]
  27.  
  28. testWithCommandActionResultInBattleInit = let
  29.   deps = [DeploymentWPips 2 (Deployment Legio14 Ravenna) Caesar, DeploymentWPips 3 (Deployment Legio1 Rome) Pompeji]
  30.   parts = (Parts deps [] (Other 1 1))
  31.   caesarCmdAct = CommandAction Caesar [] [Move [Legio14] [Rome]]
  32.   pompejiCmdAct = CommandAction Pompeji [] [Move [Legio14] [Rome]]
  33.   commandState = (CommandS [(Caesar,PlainCard 1 2),(Pompeji,PlainCard 1 2)] [] (Just Caesar))
  34.   b = Board parts commandState
  35.   (b',moreBattlesInits) = board_withCommandAction b caesarCmdAct
  36.  in 1 @=? length moreBattlesInits
  37.  
  38.  
  39. testCommandPhaseEndNoWarsTransitionToEnd = let
  40.  deps = [DeploymentWPips 2 (Deployment Legio14 Ravenna) Caesar, DeploymentWPips 3 (Deployment Legio1 Rome) Pompeji]
  41.  parts = (Parts deps [] (Other 1 1))
  42.  caesarCmdAct = CommandAction Caesar [] [Move [Legio14] [Rome]]
  43.  pompejiCmdAct = CommandAction Pompeji [] [Move [Legio14] [Rome]]
  44.  commandState = (CommandS [(Caesar,PlainCard 1 2),(Pompeji,PlainCard 1 2)] [] (Just Caesar))
  45.  b = Board parts commandState
  46.  p1 = reqCommandAct b Caesar [] caesarCmdAct
  47.  CommandPhase b' _ f1 = p1 -- traceShow(p1) $
  48.   p2 = f1 pompejiCmdAct
  49.   -- BattlePhase b'' batt possBlockActions f2 = p2
  50.   -- in 1 @=? length possBlockActions
  51.   DealPhase b'' f2 = p2
  52.   Board p (CardS cards) = b''
  53.   in 0 @=? length cards
  54.  
  55. testCook :: Assertion
  56. testCook = let
  57.   actual = reqDeck (bb) [PlainCard 1 1,PlainCard 1 2,PlainCard 1 3,PlainCard 2 1]
  58.   bb = create_board ()
  59.   in case actual of
  60.     (DiscardPhase (Board prts stat)  _ ) -> do
  61.       other prts @=? other (parts bb)
  62.       wrld_deployment prts @=? wrld_deployment (parts bb)
  63.       hands prts @=? [(Caesar,[PlainCard 1 1,PlainCard 1 3]),(Pompeji,[PlainCard 1 2,PlainCard 2 1])]
  64.     _ -> assertFailure "yo"
  65. {-|
  66. testBattle :: Assertion
  67. testBattle = let
  68.   actual = reqBattleAction
  69.   in case actual of
  70.     (BattlePhase (Board prts stat) (Battle attack defender) ) -> do
  71.       other prts @=? other (parts bb)
  72.       wrld_deployment prts @=? wrld_deployment (parts bb)
  73.       hands prts @=? [(Caesar,[PlainCard 1 1,PlainCard 1 3]),(Pompeji,[PlainCard 1 2,PlainCard 2 1])]
  74.     _ -> assertFailure "yo"
  75. -}
  76.  
  77.  
  78. tests :: [Test]
  79. tests = [testGroup1]
  80.  
  81. main :: IO ()
  82. main = defaultMain tests
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement