be pedantic
This commit is contained in:
@@ -81,13 +81,13 @@ recordGoalieStatsSpec = describe "recordGoalieStats" $ let
|
||||
& progMode.gameStateL .~ gameState n mins goals
|
||||
|
||||
in mapM_
|
||||
(\(name, gid, mins, goals, joeData, bobData, reset) -> let
|
||||
s = recordGoalieStats $ progState gid mins goals
|
||||
in context name $ do
|
||||
(\(setName, setGid, mins, goals, joeData, bobData, reset) -> let
|
||||
s = recordGoalieStats $ progState setGid mins goals
|
||||
in context setName $ do
|
||||
|
||||
mapM_
|
||||
(\( name
|
||||
, gid
|
||||
(\( chkName
|
||||
, chkGid
|
||||
, ( gGames
|
||||
, gMins
|
||||
, gGoals
|
||||
@@ -98,11 +98,11 @@ recordGoalieStatsSpec = describe "recordGoalieStats" $ let
|
||||
, ltMins
|
||||
, ltGoals
|
||||
)
|
||||
) -> context name $ do
|
||||
) -> context chkName $ do
|
||||
let
|
||||
gs = s^.progMode.gameStateL.gameGoalieStats
|
||||
game = M.findWithDefault newGoalieStats gid gs
|
||||
goalie = fromJust $ nth gid $ s^.database.dbGoalies
|
||||
game = M.findWithDefault newGoalieStats chkGid gs
|
||||
goalie = fromJust $ nth chkGid $ s^.database.dbGoalies
|
||||
ytd = goalie^.gYtd
|
||||
lt = goalie^.gLifetime
|
||||
|
||||
@@ -120,7 +120,7 @@ recordGoalieStatsSpec = describe "recordGoalieStats" $ let
|
||||
]
|
||||
|
||||
context "selected goalie" $ let
|
||||
expected = if reset then Nothing else gid
|
||||
expected = if reset then Nothing else setGid
|
||||
in it ("should be " ++ show expected) $
|
||||
(s^.progMode.gameStateL.gameSelectedGoalie) `shouldBe` expected
|
||||
|
||||
@@ -211,16 +211,16 @@ setGameGoalieSpec = describe "setGameGoalie" $ let
|
||||
tiedGame = gameState 0 1 True
|
||||
|
||||
in mapM_
|
||||
(\(label, gameState, gid, bobData, joeData) -> context label $ let
|
||||
(\(setLabel, gs, setGid, bobData, joeData) -> context setLabel $ let
|
||||
|
||||
progState = newProgState
|
||||
& database.dbGoalies .~ [bob, joe]
|
||||
& progMode.gameStateL .~ gameState
|
||||
& setGameGoalie gid
|
||||
& progMode.gameStateL .~ gs
|
||||
& setGameGoalie setGid
|
||||
|
||||
in mapM_
|
||||
(\( label
|
||||
, gid
|
||||
(\( chkLabel
|
||||
, chkGid
|
||||
, ( gWins
|
||||
, gLosses
|
||||
, gTies
|
||||
@@ -231,16 +231,16 @@ setGameGoalieSpec = describe "setGameGoalie" $ let
|
||||
, ltLosses
|
||||
, ltTies
|
||||
)
|
||||
) -> context label $ do
|
||||
) -> context chkLabel $ do
|
||||
let
|
||||
goalie = (progState^.database.dbGoalies) !! gid
|
||||
goalie = (progState^.database.dbGoalies) !! chkGid
|
||||
gameStats = progState^.progMode.gameStateL.gameGoalieStats
|
||||
game = M.findWithDefault newGoalieStats gid gameStats
|
||||
game = M.findWithDefault newGoalieStats chkGid gameStats
|
||||
ytd = goalie^.gYtd
|
||||
lifetime = goalie^.gLifetime
|
||||
|
||||
mapM_
|
||||
(\(label, expected, actual) -> context label $
|
||||
(\(label', expected, actual) -> context label' $
|
||||
expected `TS.compareTest` actual)
|
||||
[ ( "game stats", game, goalieStats gWins gLosses gTies )
|
||||
, ( "YTD stats", ytd, goalieStats ytdWins ytdLosses ytdTies )
|
||||
|
||||
@@ -327,20 +327,20 @@ awardGoalSpec = describe "awardGoal" $ do
|
||||
& database .~ db
|
||||
|
||||
mapM_
|
||||
(\(pName, pid, ytd, lt, game) ->
|
||||
context pName $ do
|
||||
(\(name, pid, ytd, lt, game) ->
|
||||
context name $ do
|
||||
let
|
||||
ps' = awardGoal pid ps
|
||||
player = (ps'^.database.dbPlayers) !! pid
|
||||
gStats = (ps'^.progMode.gameStateL.gamePlayerStats) M.! pid
|
||||
|
||||
it ("should increment " ++ pName ++ "'s year-to-date goals") $
|
||||
it ("should increment " ++ name ++ "'s year-to-date goals") $
|
||||
player^.pYtd.psGoals `shouldBe` ytd
|
||||
|
||||
it ("should increment " ++ pName ++ "'s lifetime goals") $
|
||||
it ("should increment " ++ name ++ "'s lifetime goals") $
|
||||
player^.pLifetime.psGoals `shouldBe` lt
|
||||
|
||||
it ("should increment " ++ pName ++ "'s game goals") $
|
||||
it ("should increment " ++ name ++ "'s game goals") $
|
||||
gStats^.psGoals `shouldBe` game)
|
||||
-- player name, player id, ytd goals, lifetime goals, game goals
|
||||
[ ( "Joe", 0, 2, 3, 2 )
|
||||
@@ -377,20 +377,20 @@ awardAssistSpec = describe "awardAssist" $ do
|
||||
& database.dbPlayers .~ [joe, bob]
|
||||
|
||||
mapM_
|
||||
(\(pName, pid, ytd, lt, game) ->
|
||||
context pName $ do
|
||||
(\(name, pid, ytd, lt, game) ->
|
||||
context name $ do
|
||||
let
|
||||
ps' = awardAssist pid ps
|
||||
player = (ps'^.database.dbPlayers) !! pid
|
||||
gStats = (ps'^.progMode.gameStateL.gamePlayerStats) M.! pid
|
||||
|
||||
it ("should increment " ++ pName ++ "'s year-to-date assists") $
|
||||
it ("should increment " ++ name ++ "'s year-to-date assists") $
|
||||
player^.pYtd.psAssists `shouldBe` ytd
|
||||
|
||||
it ("should increment " ++ pName ++ "'s lifetime assists") $
|
||||
it ("should increment " ++ name ++ "'s lifetime assists") $
|
||||
player^.pLifetime.psAssists `shouldBe` lt
|
||||
|
||||
it ("should increment " ++ pName ++ "'s game assists") $
|
||||
it ("should increment " ++ name ++ "'s game assists") $
|
||||
gStats^.psAssists `shouldBe` game)
|
||||
-- player name, player id, ytd assists, lifetime assists, game assists
|
||||
[ ( "Joe", 0, 2, 3, 2 )
|
||||
|
||||
@@ -589,22 +589,22 @@ playerSearchExactSpec = describe "playerSearchExact" $ mapM_
|
||||
|
||||
modifyPlayerSpec :: Spec
|
||||
modifyPlayerSpec = describe "modifyPlayer" $ mapM_
|
||||
(\(pName, j, b, s) -> let
|
||||
(\(name, j, b, s) -> let
|
||||
modifier = pLifetime.psGoals .~ 1
|
||||
players = modifyPlayer modifier pName [joe, bob, steve]
|
||||
in context ("modify " ++ pName) $ do
|
||||
players = modifyPlayer modifier name [joe, bob, steve]
|
||||
in context ("modify " ++ name) $ do
|
||||
|
||||
context "Joe's lifetime goals" $
|
||||
it ("should be " ++ show j) $
|
||||
head players ^. pLifetime.psGoals `shouldBe` j
|
||||
head players^.pLifetime.psGoals `shouldBe` j
|
||||
|
||||
context "Bob's lifetime goals" $
|
||||
it ("should be " ++ show b) $
|
||||
(players !! 1) ^. pLifetime.psGoals `shouldBe` b
|
||||
(players !! 1)^.pLifetime.psGoals `shouldBe` b
|
||||
|
||||
context "Steve's lifetime goals" $
|
||||
it ("should be " ++ show s) $
|
||||
last players ^. pLifetime.psGoals `shouldBe` s)
|
||||
last players^.pLifetime.psGoals `shouldBe` s)
|
||||
-- player name, Joe's goals, Bob's goals, Steve's goals
|
||||
[ ( "Joe", 1, 0, 0 )
|
||||
, ( "Bob", 0, 1, 0 )
|
||||
@@ -621,7 +621,7 @@ playerDetailsSpec :: Spec
|
||||
playerDetailsSpec = describe "playerDetails" $
|
||||
it "should give a detailed description" $ let
|
||||
|
||||
player = newPlayer 1 "Joe" "centre"
|
||||
p = newPlayer 1 "Joe" "centre"
|
||||
& pYtd .~ PlayerStats
|
||||
{ _psGoals = 2
|
||||
, _psAssists = 3
|
||||
@@ -645,26 +645,26 @@ playerDetailsSpec = describe "playerDetails" $
|
||||
, "Lifetime penalty mins: 7"
|
||||
]
|
||||
|
||||
in playerDetails player `shouldBe` expected
|
||||
in playerDetails p `shouldBe` expected
|
||||
|
||||
playerIsActiveSpec :: Spec
|
||||
playerIsActiveSpec = describe "playerIsActive" $ do
|
||||
let
|
||||
pState = newPlayerStats
|
||||
pStats = newPlayerStats
|
||||
& psGoals .~ 10
|
||||
& psAssists .~ 11
|
||||
& psPMin .~ 12
|
||||
player = newPlayer 1 "Joe" "centre" & pLifetime .~ pState
|
||||
p = newPlayer 1 "Joe" "centre" & pLifetime .~ pStats
|
||||
|
||||
mapM_
|
||||
(\(label, player', expected) -> context label $
|
||||
(\(label, p', expected) -> context label $
|
||||
it ("should be " ++ show expected) $
|
||||
playerIsActive player' `shouldBe` expected)
|
||||
-- label, player, expected
|
||||
[ ( "not active", player, False )
|
||||
, ( "has goal", player & pYtd.psGoals .~ 1, True )
|
||||
, ( "has assist", player & pYtd.psAssists .~ 1, True )
|
||||
, ( "has penalty minute", player & pYtd.psPMin .~ 1, True )
|
||||
playerIsActive p' `shouldBe` expected)
|
||||
-- label, player, expected
|
||||
[ ( "not active", p, False )
|
||||
, ( "has goal", p & pYtd.psGoals .~ 1, True )
|
||||
, ( "has assist", p & pYtd.psAssists .~ 1, True )
|
||||
, ( "has penalty minute", p & pYtd.psPMin .~ 1, True )
|
||||
]
|
||||
|
||||
psPointsSpec :: Spec
|
||||
|
||||
@@ -49,18 +49,19 @@ nthSpec = describe "nth" $ mapM_
|
||||
|
||||
modifyNthSpec :: Spec
|
||||
modifyNthSpec = describe "modifyNth" $ do
|
||||
let list = [1, 2, 3] :: [Int]
|
||||
|
||||
context "in bounds" $
|
||||
it "should modify the value" $
|
||||
modifyNth 1 succ [1, 2, 3] `shouldBe` [1, 3, 3]
|
||||
modifyNth 1 succ list `shouldBe` [1, 3, 3]
|
||||
|
||||
context "out of bounds" $
|
||||
it "should not modify the value" $
|
||||
modifyNth 3 succ [1, 2, 3] `shouldBe` [1, 2, 3]
|
||||
modifyNth 3 succ list `shouldBe` [1, 2, 3]
|
||||
|
||||
context "negative index" $
|
||||
it "should not modify the value" $
|
||||
modifyNth (-1) succ [1, 2, 3] `shouldBe` [1, 2, 3]
|
||||
modifyNth (-1) succ list `shouldBe` [1, 2, 3]
|
||||
|
||||
updateMapSpec :: Spec
|
||||
updateMapSpec = describe "updateMap" $ do
|
||||
@@ -68,7 +69,7 @@ updateMapSpec = describe "updateMap" $ do
|
||||
input = M.fromList [(1, 2), (3, 5)]
|
||||
|
||||
context "key found" $ let
|
||||
expected = M.fromList [(1, 3), (3, 5)]
|
||||
expected = M.fromList [(1, 3), (3, 5)] :: M.Map Int Int
|
||||
in it "should update the value" $
|
||||
updateMap 1 10 succ input `shouldBe` expected
|
||||
|
||||
@@ -79,7 +80,7 @@ updateMapSpec = describe "updateMap" $ do
|
||||
|
||||
sliceSpec :: Spec
|
||||
sliceSpec = describe "slice" $ do
|
||||
let list = [2, 4, 6, 8]
|
||||
let list = [2, 4, 6, 8] :: [Int]
|
||||
|
||||
context "sublist" $
|
||||
it "should return the sublist" $
|
||||
|
||||
Reference in New Issue
Block a user