implemented addGoalieStats
This commit is contained in:
parent
de67628df0
commit
e3d5af5f88
|
@ -996,7 +996,15 @@ goalieIsActive g = g^.gYtd.gsMinsPlayed /= 0
|
||||||
|
|
||||||
-- | Adds two sets of 'GoalieStats'
|
-- | Adds two sets of 'GoalieStats'
|
||||||
addGoalieStats :: GoalieStats -> GoalieStats -> GoalieStats
|
addGoalieStats :: GoalieStats -> GoalieStats -> GoalieStats
|
||||||
addGoalieStats = undefined
|
addGoalieStats g1 g2 = GoalieStats
|
||||||
|
{ _gsGames = g1^.gsGames + g2^.gsGames
|
||||||
|
, _gsMinsPlayed = g1^.gsMinsPlayed + g2^.gsMinsPlayed
|
||||||
|
, _gsGoalsAllowed = g1^.gsGoalsAllowed + g2^.gsGoalsAllowed
|
||||||
|
, _gsShutouts = g1^.gsShutouts + g2^.gsShutouts
|
||||||
|
, _gsWins = g1^.gsWins + g2^.gsWins
|
||||||
|
, _gsLosses = g1^.gsLosses + g2^.gsLosses
|
||||||
|
, _gsTies = g1^.gsTies + g2^.gsTies
|
||||||
|
}
|
||||||
|
|
||||||
-- | Determines a goalie's average goals allowed per game.
|
-- | Determines a goalie's average goals allowed per game.
|
||||||
gsAverage :: GoalieStats -> Rational
|
gsAverage :: GoalieStats -> Rational
|
||||||
|
|
|
@ -79,6 +79,7 @@ spec = describe "Mtlstats.Types" $ do
|
||||||
goalieSearchExactSpec
|
goalieSearchExactSpec
|
||||||
goalieSummarySpec
|
goalieSummarySpec
|
||||||
goalieIsActiveSpec
|
goalieIsActiveSpec
|
||||||
|
addGoalieStatsSpec
|
||||||
Menu.spec
|
Menu.spec
|
||||||
|
|
||||||
playerSpec :: Spec
|
playerSpec :: Spec
|
||||||
|
@ -772,6 +773,43 @@ goalieIsActiveSpec = describe "goalieIsActive" $ mapM_
|
||||||
active = inactive
|
active = inactive
|
||||||
& gYtd.gsMinsPlayed .~ 1
|
& gYtd.gsMinsPlayed .~ 1
|
||||||
|
|
||||||
|
addGoalieStatsSpec :: Spec
|
||||||
|
addGoalieStatsSpec = describe "addGoalieStats" $ let
|
||||||
|
g1 = GoalieStats
|
||||||
|
{ _gsGames = 1
|
||||||
|
, _gsMinsPlayed = 2
|
||||||
|
, _gsGoalsAllowed = 3
|
||||||
|
, _gsShutouts = 4
|
||||||
|
, _gsWins = 5
|
||||||
|
, _gsLosses = 6
|
||||||
|
, _gsTies = 7
|
||||||
|
}
|
||||||
|
|
||||||
|
g2 = GoalieStats
|
||||||
|
{ _gsGames = 8
|
||||||
|
, _gsMinsPlayed = 9
|
||||||
|
, _gsGoalsAllowed = 10
|
||||||
|
, _gsShutouts = 11
|
||||||
|
, _gsWins = 12
|
||||||
|
, _gsLosses = 13
|
||||||
|
, _gsTies = 14
|
||||||
|
}
|
||||||
|
|
||||||
|
expected = GoalieStats
|
||||||
|
{ _gsGames = 9
|
||||||
|
, _gsMinsPlayed = 11
|
||||||
|
, _gsGoalsAllowed = 13
|
||||||
|
, _gsShutouts = 15
|
||||||
|
, _gsWins = 17
|
||||||
|
, _gsLosses = 19
|
||||||
|
, _gsTies = 21
|
||||||
|
}
|
||||||
|
|
||||||
|
actual = g1 `addGoalieStats` g2
|
||||||
|
|
||||||
|
in it ("should be " ++ show expected) $
|
||||||
|
actual `shouldBe` expected
|
||||||
|
|
||||||
joe :: Player
|
joe :: Player
|
||||||
joe = newPlayer 2 "Joe" "center"
|
joe = newPlayer 2 "Joe" "center"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user