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"
|
|
|
|
]
|
|
|
|
describe "fillPegWithDiscs" $ do
|
|
|
|
it "creates a list of disks from biggest to smallest" $ do
|
|
|
|
fillPegWithDiscs 3
|
|
|
|
`shouldBe` [ Disc 3,
|
|
|
|
Disc 2,
|
|
|
|
Disc 1
|
|
|
|
]
|