implemented getRung

This commit is contained in:
2024-08-21 13:49:00 -04:00
parent 24a1f2f10c
commit 768497d399
2 changed files with 36 additions and 1 deletions

View File

@@ -32,6 +32,7 @@ spec = describe "Abacus" $ do
newAbacusSpec
getNumBeadsSpec
getNumRungsSpec
getRungSpec
newAbacusSpec :: Spec
newAbacusSpec = describe "newAbacusSpec" $ mapM_
@@ -73,4 +74,18 @@ getNumRungsSpec = describe "getNumRungs" $ mapM_
tenRungs = build 10
build n = fromJust $ newAbacus 10 n
getRungSpec :: Spec
getRungSpec = describe "getRung" $ mapM_
( \(desc, rung, expected) -> context desc $ let
actual = getRung rung abacus
in it ("should be " ++ show expected) $
actual `shouldBe` expected
)
[ ( "0th rung", 0, Just 2 )
, ( "last rung", 2, Just 5 )
, ( "negative rung", -1, Nothing )
, ( "too large", 3, Nothing )
] where
abacus = Abacus 10 [2, 3, 5]
--jl