(nspov-test(:require[clojure.test:refer[deftestis]]pov));;; Inputs.(defsingleton[:x])(defsimple-tree[:parent[:sibling][:x]])(deflarge-flat[:parent[:sib-a][:sib-b][:x][:sib-c][:sib-d]])(defdeeply-nested[:level-0[:level-1[:level-2[:level-3[:level-4[:x]]]]]])(defcousins[:grand-parent[:parent[:sib-1][:x][:sib-2]][:uncle[:cousin-1][:cousin-2]]])(deftarget-with-children[:grand-parent[:parent[:x[:child-1][:child-2]][:sibling[:nephew][:niece]]][:aunt[:cousin-1[:2nd-cousin-1][:2nd-cousin-2]][:cousin-2[:2nd-cousin-3][:2nd-cousin-4]]]]);;; Expected results.(defsimple-pulled[:x[:parent[:sibling]]])(defflat-pulled[:x[:parent[:sib-a][:sib-b][:sib-c][:sib-d]]])(defnested-pulled[:x[:level-4[:level-3[:level-2[:level-1[:level-0]]]]]])(defcousins-pulled[:x[:parent[:sib-1][:sib-2][:grand-parent[:uncle[:cousin-1][:cousin-2]]]]])(defwith-kids-pulled[:x[:child-1][:child-2][:parent[:sibling[:nephew][:niece]][:grand-parent[:aunt[:cousin-1[:2nd-cousin-1][:2nd-cousin-2]][:cousin-2[:2nd-cousin-3][:2nd-cousin-4]]]]]])(deftesttest-pov(is(=singleton(pov/of:xsingleton))"Can handle singletons")(is(=simple-pulled(pov/of:xsimple-tree))"Can handle simple trees")(is(=nested-pulled(pov/of:xdeeply-nested))"Can handle nested trees")(is(=flat-pulled(pov/of:xlarge-flat))"Can extract a node from a list of siblings")(is(=cousins-pulled(pov/of:xcousins))"Can handle moderate trees")(is(=with-kids-pulled(pov/of:xtarget-with-children))"Can handle complex trees"))(deftestnot-found(is(nil?(pov/of:not-found!target-with-children))"Returns nil if we cannot reparent")(is(nil?(pov/of:x[]))"Return nil if the input is empty")(is(nil?(pov/of:xnil))"Returns nil if the input is nil"))(deftestpath-from-to(is(=[:x:parent](pov/path-from-to:x:parentsimple-tree))"Can trace a path from target to parent")(is(=[:x:parent:sib-c](pov/path-from-to:x:sib-clarge-flat))"Can trace a path from target to sibling")(is(=[:x:parent:grand-parent:aunt:cousin-1:2nd-cousin-1](pov/path-from-to:x:2nd-cousin-1target-with-children))"Can trace a path from :x to :2nd-cousin-1")(is(nil?(pov/path-from-to:x:not-there!cousins))"Returns nil if there is no path"))