haskell-homework/test/Homework/Ch01/HanoiSpec.hs

31 lines
758 B
Haskell
Raw Normal View History

2021-10-01 00:04:16 +00:00
module Homework.Ch01.HanoiSpec where
import Homework.Ch01.Hanoi
import Test.Hspec
spec :: Spec
spec = describe "Hanoi" $ do
describe "hanoi" $ do
it "can solve for a stack of 1 and three pegs" $ do
hanoi 1 "a" "b" "c"
`shouldBe` Right
[Move "a" "c"]
it "can solve for stack of 3 and three pegs" $ do
hanoi 3 "a" "b" "c"
`shouldBe` Right
[ Move "a" "c",
Move "a" "b",
Move "c" "b"
]
2021-10-06 20:39:05 +00:00
describe "fillPeg" $ do
it "creates a list of disks from biggest to smallest" $ do
2021-10-06 20:39:05 +00:00
fillPeg "a" 3
`shouldBe` Peg
{ pegLabel = "a",
pegDiscs =
[ Disc 3,
Disc 2,
Disc 1
]
}