Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Main where
- import Test.Framework (testGroup,Test)
- import Test.Framework.Providers.HUnit
- import Test.HUnit hiding (Test)
- import Test.Framework (defaultMain)
- import Controller
- import Board
- import GameLogic
- import Model
- import Debug.Trace
- -- http://jabberwocky.eu/2013/10/24/how-to-start-a-new-haskell-project/
- testGroup1 :: Test
- testGroup1 = testGroup "grp"
- [
- testCase "case" (assertEqual "one is one" 1 1),
- testCase "case1" (testCommandPhaseEndNoWarsTransitionToEnd),
- -- testCase "case2" (testCommandPhaseEndToBattlePhaseTransition),
- testCase "case4" (testWithCommandActionResultInBattleInit),
- testCase "case21" (testCook )
- ]
- -- testGroup2 :: Test
- -- testGroup2 = testGroup "grp2"
- -- [testCase "case21" (testCook ) ]
- testWithCommandActionResultInBattleInit = let
- deps = [DeploymentWPips 2 (Deployment Legio14 Ravenna) Caesar, DeploymentWPips 3 (Deployment Legio1 Rome) Pompeji]
- parts = (Parts deps [] (Other 1 1))
- caesarCmdAct = CommandAction Caesar [] [Move [Legio14] [Rome]]
- pompejiCmdAct = CommandAction Pompeji [] [Move [Legio14] [Rome]]
- commandState = (CommandS [(Caesar,PlainCard 1 2),(Pompeji,PlainCard 1 2)] [] (Just Caesar))
- b = Board parts commandState
- (b',moreBattlesInits) = board_withCommandAction b caesarCmdAct
- in 1 @=? length moreBattlesInits
- testCommandPhaseEndNoWarsTransitionToEnd = let
- deps = [DeploymentWPips 2 (Deployment Legio14 Ravenna) Caesar, DeploymentWPips 3 (Deployment Legio1 Rome) Pompeji]
- parts = (Parts deps [] (Other 1 1))
- caesarCmdAct = CommandAction Caesar [] [Move [Legio14] [Rome]]
- pompejiCmdAct = CommandAction Pompeji [] [Move [Legio14] [Rome]]
- commandState = (CommandS [(Caesar,PlainCard 1 2),(Pompeji,PlainCard 1 2)] [] (Just Caesar))
- b = Board parts commandState
- p1 = reqCommandAct b Caesar [] caesarCmdAct
- CommandPhase b' _ f1 = p1 -- traceShow(p1) $
- p2 = f1 pompejiCmdAct
- -- BattlePhase b'' batt possBlockActions f2 = p2
- -- in 1 @=? length possBlockActions
- DealPhase b'' f2 = p2
- Board p (CardS cards) = b''
- in 0 @=? length cards
- testCook :: Assertion
- testCook = let
- actual = reqDeck (bb) [PlainCard 1 1,PlainCard 1 2,PlainCard 1 3,PlainCard 2 1]
- bb = create_board ()
- in case actual of
- (DiscardPhase (Board prts stat) _ ) -> do
- other prts @=? other (parts bb)
- wrld_deployment prts @=? wrld_deployment (parts bb)
- hands prts @=? [(Caesar,[PlainCard 1 1,PlainCard 1 3]),(Pompeji,[PlainCard 1 2,PlainCard 2 1])]
- _ -> assertFailure "yo"
- {-|
- testBattle :: Assertion
- testBattle = let
- actual = reqBattleAction
- in case actual of
- (BattlePhase (Board prts stat) (Battle attack defender) ) -> do
- other prts @=? other (parts bb)
- wrld_deployment prts @=? wrld_deployment (parts bb)
- hands prts @=? [(Caesar,[PlainCard 1 1,PlainCard 1 3]),(Pompeji,[PlainCard 1 2,PlainCard 2 1])]
- _ -> assertFailure "yo"
- -}
- tests :: [Test]
- tests = [testGroup1]
- main :: IO ()
- main = defaultMain tests
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement