implemented goalieSearchExact
This commit is contained in:
parent
7e19ee072f
commit
12c8d0bdd6
|
@ -854,7 +854,12 @@ goalieSearchExact
|
||||||
-- ^ The list to search
|
-- ^ The list to search
|
||||||
-> Maybe (Int, Goalie)
|
-> Maybe (Int, Goalie)
|
||||||
-- ^ The result with its index number
|
-- ^ The result with its index number
|
||||||
goalieSearchExact = undefined
|
goalieSearchExact sStr goalies = let
|
||||||
|
results = filter (\(_, goalie) -> sStr == goalie^.gName) $
|
||||||
|
zip [0..] goalies
|
||||||
|
in case results of
|
||||||
|
[] -> Nothing
|
||||||
|
result:_ -> Just result
|
||||||
|
|
||||||
-- | Provides a description string for a 'Goalie'
|
-- | Provides a description string for a 'Goalie'
|
||||||
goalieSummary :: Goalie -> String
|
goalieSummary :: Goalie -> String
|
||||||
|
|
|
@ -66,6 +66,7 @@ spec = describe "Mtlstats.Types" $ do
|
||||||
psPointsSpec
|
psPointsSpec
|
||||||
addPlayerStatsSpec
|
addPlayerStatsSpec
|
||||||
goalieSearchSpec
|
goalieSearchSpec
|
||||||
|
goalieSearchExactSpec
|
||||||
Menu.spec
|
Menu.spec
|
||||||
|
|
||||||
playerSpec :: Spec
|
playerSpec :: Spec
|
||||||
|
@ -674,6 +675,30 @@ goalieSearchSpec = describe "goalieSearch" $ do
|
||||||
it "should return Steve" $
|
it "should return Steve" $
|
||||||
goalieSearch "Bob" goalies `shouldBe` [result 1]
|
goalieSearch "Bob" goalies `shouldBe` [result 1]
|
||||||
|
|
||||||
|
goalieSearchExactSpec :: Spec
|
||||||
|
goalieSearchExactSpec = describe "goalieSearchExact" $ do
|
||||||
|
let
|
||||||
|
goalies =
|
||||||
|
[ newGoalie 2 "Joe"
|
||||||
|
, newGoalie 3 "Bob"
|
||||||
|
, newGoalie 5 "Steve"
|
||||||
|
]
|
||||||
|
result n = (n, goalies!!n)
|
||||||
|
|
||||||
|
mapM_
|
||||||
|
(\(name, num) -> context name $
|
||||||
|
it ("should return " ++ name) $
|
||||||
|
goalieSearchExact name goalies `shouldBe` Just (result num))
|
||||||
|
-- name, num
|
||||||
|
[ ( "Joe", 0 )
|
||||||
|
, ( "Bob", 1 )
|
||||||
|
, ( "Steve", 2 )
|
||||||
|
]
|
||||||
|
|
||||||
|
context "Greg" $
|
||||||
|
it "should return Nothing" $
|
||||||
|
goalieSearchExact "Greg" goalies `shouldBe` Nothing
|
||||||
|
|
||||||
joe :: Player
|
joe :: Player
|
||||||
joe = newPlayer 2 "Joe" "center"
|
joe = newPlayer 2 "Joe" "center"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user