Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added two tests for deep setRight and setLeft #1121

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions exercises/practice/zipper/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ specs = do
t5 = BT 6 (leaf 7 ) $ leaf 8
t6 = BT 1 (node 2 Nothing $ leaf 3) $ node 6 (leaf 7) (leaf 8)
t7 = BT 1 (node 2 Nothing $ leaf 5) $ leaf 4
t8 = BT 1 (node 2 Nothing $ leaf 3) $ node 6 (leaf 7) (node 8 (leaf 15) Nothing)
t9 = BT 1 (node 2 Nothing $ leaf 3) $ node 6 (leaf 7) (node 8 Nothing (leaf 15))

it "data is retained" $
toTree (fromTree t1)
Expand Down Expand Up @@ -82,3 +84,11 @@ specs = do
it "different paths to same zipper" $
(right . fromJust . up . fromJust . left . fromTree) t1
`shouldBe` (right . fromTree) t1

it "setLeft with subtree on deep focus" $
(toTree . setLeft (leaf 15) . fromJust . right . fromJust . right . fromTree) t6
`shouldBe` t8

it "setRight with subtree on deep focus" $
(toTree . setRight (leaf 15) . fromJust . right . fromJust . right . fromTree) t6
`shouldBe` t9