Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

Commit

Permalink
Add explicit test for how unselect sets the update times of its result
Browse files Browse the repository at this point in the history
  • Loading branch information
josharnold52 committed Oct 19, 2011
1 parent 728879a commit effe767
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/test/scala/com/codecommit/antixml/ZipperSpecs.scala
Expand Up @@ -916,6 +916,26 @@ class ZipperSpecs extends SpecificationWithJUnit with ScalaCheck with XMLGenera
}
}

"Zipper.unselect" should {
"only modify the update times of nodes that receive updates" in {
val xml = <top><a><b /></a></top>.convert
val z = xml \\ *

//Conflicting updates. Second node has latest update time.
val z1 = z.updated(0,elem("a",elem("c")))
val z2 = z1.updated(1,elem("b2"))

//Make an update to the first node only through a child zipper
val zInner = z2 select 'a
val zInner1 = zInner.updated(0, zInner(0).asInstanceOf[Elem].copy(name="A"))
val z3 = zInner1.unselect

z2.unselect mustEqual <top><a><b2 /></a></top>.convert.toGroup
z3.unselect mustEqual <top><A><c /></A></top>.convert.toGroup

}
}

def validate[Expected] = new {
def apply[A](a: A)(implicit evidence: A =:= Expected) = evidence must not beNull
}
Expand Down

0 comments on commit effe767

Please sign in to comment.