2021-10-01 00:04:16 +00:00
|
|
|
module Homework.Ch01.HanoiSpec where
|
|
|
|
|
|
|
|
import Homework.Ch01.Hanoi
|
|
|
|
import Test.Hspec
|
|
|
|
|
|
|
|
spec :: Spec
|
2021-10-06 19:12:47 +00:00
|
|
|
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
|
2021-10-06 19:12:47 +00:00
|
|
|
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
|
|
|
|
]
|
|
|
|
}
|