implemented gsAverage
This commit is contained in:
parent
e3d5af5f88
commit
be54198960
|
@ -1008,4 +1008,4 @@ addGoalieStats g1 g2 = GoalieStats
|
||||||
|
|
||||||
-- | Determines a goalie's average goals allowed per game.
|
-- | Determines a goalie's average goals allowed per game.
|
||||||
gsAverage :: GoalieStats -> Rational
|
gsAverage :: GoalieStats -> Rational
|
||||||
gsAverage = undefined
|
gsAverage gs = fromIntegral (gs^.gsGoalsAllowed) / fromIntegral (gs^.gsGames)
|
||||||
|
|
|
@ -34,6 +34,7 @@ import Control.Monad (replicateM)
|
||||||
import Data.Aeson (FromJSON, ToJSON, decode, encode, toJSON)
|
import Data.Aeson (FromJSON, ToJSON, decode, encode, toJSON)
|
||||||
import Data.Aeson.Types (Value (Object))
|
import Data.Aeson.Types (Value (Object))
|
||||||
import qualified Data.HashMap.Strict as HM
|
import qualified Data.HashMap.Strict as HM
|
||||||
|
import Data.Ratio ((%))
|
||||||
import Lens.Micro (Lens', (&), (^.), (.~), (?~))
|
import Lens.Micro (Lens', (&), (^.), (.~), (?~))
|
||||||
import System.Random (randomRIO)
|
import System.Random (randomRIO)
|
||||||
import Test.Hspec (Spec, context, describe, it, shouldBe)
|
import Test.Hspec (Spec, context, describe, it, shouldBe)
|
||||||
|
@ -80,6 +81,7 @@ spec = describe "Mtlstats.Types" $ do
|
||||||
goalieSummarySpec
|
goalieSummarySpec
|
||||||
goalieIsActiveSpec
|
goalieIsActiveSpec
|
||||||
addGoalieStatsSpec
|
addGoalieStatsSpec
|
||||||
|
gsAverageSpec
|
||||||
Menu.spec
|
Menu.spec
|
||||||
|
|
||||||
playerSpec :: Spec
|
playerSpec :: Spec
|
||||||
|
@ -810,6 +812,17 @@ addGoalieStatsSpec = describe "addGoalieStats" $ let
|
||||||
in it ("should be " ++ show expected) $
|
in it ("should be " ++ show expected) $
|
||||||
actual `shouldBe` expected
|
actual `shouldBe` expected
|
||||||
|
|
||||||
|
gsAverageSpec :: Spec
|
||||||
|
gsAverageSpec = describe "gsAverage" $ let
|
||||||
|
gs = newGoalieStats
|
||||||
|
& gsGames .~ 2
|
||||||
|
& gsGoalsAllowed .~ 3
|
||||||
|
|
||||||
|
expected = 3 % 2
|
||||||
|
|
||||||
|
in it ("should be " ++ show expected) $
|
||||||
|
gsAverage gs `shouldBe` expected
|
||||||
|
|
||||||
joe :: Player
|
joe :: Player
|
||||||
joe = newPlayer 2 "Joe" "center"
|
joe = newPlayer 2 "Joe" "center"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user