implemented rungL
This commit is contained in:
@@ -22,7 +22,14 @@ License along with this program. If not, see
|
||||
module AbacusSpec (spec) where
|
||||
|
||||
import Data.Maybe (fromJust)
|
||||
import Test.Hspec (Spec, context, describe, it, shouldBe)
|
||||
import Lens.Micro.Platform ((^.), (&), (.~), (%~))
|
||||
import Test.Hspec
|
||||
( Spec
|
||||
, context
|
||||
, describe
|
||||
, it
|
||||
, shouldBe
|
||||
)
|
||||
|
||||
import Abacus
|
||||
import Abacus.Internal
|
||||
@@ -34,6 +41,7 @@ spec = describe "Abacus" $ do
|
||||
getNumRungsSpec
|
||||
getRungSpec
|
||||
setRungSpec
|
||||
rungLSpec
|
||||
|
||||
newAbacusSpec :: Spec
|
||||
newAbacusSpec = describe "newAbacusSpec" $ mapM_
|
||||
@@ -105,4 +113,33 @@ setRungSpec = describe "setRung" $ mapM_
|
||||
] where
|
||||
mkA = Abacus 10
|
||||
|
||||
rungLSpec :: Spec
|
||||
rungLSpec = describe "rungL" $ do
|
||||
let
|
||||
mkA = Abacus 10
|
||||
abacus = mkA [2, 3, 5]
|
||||
context "getter" $
|
||||
context "rung 1" $
|
||||
it "should be 3" $
|
||||
abacus^.rungL 1 `shouldBe` 3
|
||||
context "setter" $ mapM_
|
||||
( \(desc, rung, val, expected) -> context desc $ let
|
||||
actual = abacus & rungL rung .~ val
|
||||
in it ("should be " ++ show expected) $
|
||||
actual `shouldBe` expected
|
||||
)
|
||||
[ ( "valid rung and value", 1, 7, mkA [2, 7, 5] )
|
||||
, ( "bad rung", -1, 7, abacus )
|
||||
, ( "bad value", 1, -1, mkA [2, 0, 5] )
|
||||
]
|
||||
context "modifier" $ mapM_
|
||||
( \(desc, rung, expected) -> context desc $ let
|
||||
actual = abacus & rungL rung %~ succ
|
||||
in it ("should be " ++ show expected) $
|
||||
actual `shouldBe` expected
|
||||
)
|
||||
[ ( "valid rung", 1, mkA [2, 4, 5] )
|
||||
, ( "invalid rung", -1, mkA [2, 3, 5] )
|
||||
]
|
||||
|
||||
--jl
|
||||
|
||||
Reference in New Issue
Block a user