implemented rendering of beads on abacus
This commit is contained in:
parent
475b1ed05c
commit
fe9263cfae
|
@ -53,7 +53,13 @@ abacusLeft s =
|
||||||
else ' '
|
else ' '
|
||||||
|
|
||||||
beads :: Abacus -> [(String, String)]
|
beads :: Abacus -> [(String, String)]
|
||||||
beads = undefined
|
beads a = map
|
||||||
|
( \n ->
|
||||||
|
( replicate (getNumBeads a - n) 'O'
|
||||||
|
, replicate n 'O'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(rungList a)
|
||||||
|
|
||||||
abacusRight :: AppState -> [String]
|
abacusRight :: AppState -> [String]
|
||||||
abacusRight = undefined
|
abacusRight = undefined
|
||||||
|
|
|
@ -21,11 +21,12 @@ License along with this program. If not, see
|
||||||
|
|
||||||
module Abacus.App.Widgets.InternalSpec (spec) where
|
module Abacus.App.Widgets.InternalSpec (spec) where
|
||||||
|
|
||||||
import Lens.Micro.Platform ((&), (.~))
|
import Lens.Micro.Platform ((^.), (&), (.~))
|
||||||
import Test.Hspec (Spec, describe, context, it, shouldBe)
|
import Test.Hspec (Spec, describe, context, it, shouldBe)
|
||||||
|
|
||||||
import Abacus.App.Types
|
import Abacus.App.Types
|
||||||
import Abacus.App.Widgets.Internal
|
import Abacus.App.Widgets.Internal
|
||||||
|
import Abacus.Internal
|
||||||
|
|
||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = describe "Internal" $ do
|
spec = describe "Internal" $ do
|
||||||
|
@ -90,8 +91,30 @@ abacusLeftSpec = describe "abacusLeft" $ mapM_
|
||||||
negState = initialState & rungNum .~ (-1)
|
negState = initialState & rungNum .~ (-1)
|
||||||
|
|
||||||
beadsSpec :: Spec
|
beadsSpec :: Spec
|
||||||
beadsSpec = describe "beads" $
|
beadsSpec = describe "beads" $ mapM_
|
||||||
return ()
|
( \(desc, a, expected) -> context desc $
|
||||||
|
it ("should be " ++ show expected) $
|
||||||
|
beads a `shouldBe` expected
|
||||||
|
)
|
||||||
|
[ ( "initial state", initAb, initRes )
|
||||||
|
, ( "1-10", countAb, countRes )
|
||||||
|
]
|
||||||
|
where
|
||||||
|
initAb = initialState^.abacus
|
||||||
|
countAb = Abacus 10 [1..10]
|
||||||
|
initRes = replicate 10 ("OOOOOOOOOO", "")
|
||||||
|
countRes =
|
||||||
|
[ ( "OOOOOOOOO", "O" )
|
||||||
|
, ( "OOOOOOOO", "OO" )
|
||||||
|
, ( "OOOOOOO", "OOO" )
|
||||||
|
, ( "OOOOOO", "OOOO" )
|
||||||
|
, ( "OOOOO", "OOOOO" )
|
||||||
|
, ( "OOOO", "OOOOOO" )
|
||||||
|
, ( "OOO", "OOOOOOO" )
|
||||||
|
, ( "OO", "OOOOOOOO" )
|
||||||
|
, ( "O", "OOOOOOOOO" )
|
||||||
|
, ( "", "OOOOOOOOOO" )
|
||||||
|
]
|
||||||
|
|
||||||
abacusRightSpec :: Spec
|
abacusRightSpec :: Spec
|
||||||
abacusRightSpec = describe "abacusRight" $
|
abacusRightSpec = describe "abacusRight" $
|
||||||
|
|
Loading…
Reference in New Issue
Block a user