Permalink
Browse files

Refactored \^ to 'select' (to avoid introducing a new operator)

  • Loading branch information...
1 parent f8e53c8 commit 6ab2a4d3fb86211011316c7516dc6100f1a35690 @djspiewak committed Aug 13, 2011
@@ -148,7 +148,7 @@ trait Selectable[+A <: Node] {
* In other respects, this operator behaves similarly to '\' operator. Backtrace ("zipper") operations
* are fully supported.
*/
- def \^[B, That](selector: Selector[B])(implicit cbf: CanBuildFromWithZipper[Group[_], B, That]): That = {
+ def select[B, That](selector: Selector[B])(implicit cbf: CanBuildFromWithZipper[Group[_], B, That]): That = {
implicit val cbf2 = cbf.lift[That]
if (matches(selector)) {
// note: this is mutable and horrible for performance reasons
@@ -252,7 +252,7 @@ trait Selectable[+A <: Node] {
* a result set with this property is said to be ''topologically consistent'' with the original
* XML tree.
*
- * As with the '\', and '\^' operators, backtrace ("zipper") operations are fully supported. Indeed,
+ * As with the '\', and 'select' operators, backtrace ("zipper") operations are fully supported. Indeed,
* backtrace support is a major advantage of topological consistency. Without this property,
* backtracing semmantics must provide some means of resolving conflicting updates to nodes that
* appear in multiple localations of the result set.
@@ -280,11 +280,11 @@ class ZipperSpecs extends Specification with ScalaCheck with XMLGenerators {
}
}
- "zipper updates within '\\^' results" should {
+ "zipper updates within 'select' results" should {
val topLevel = Group(<a1 ><a1b1 /><a1b2 /></a1>.convert, <a2><a2b1 /><a2b2 /></a2>.convert)
"rebuild from non-trivial selector" in {
- val second = topLevel \^ 'a2
+ val second = topLevel select 'a2
val changed = second map { e=>
e.copy(children = e.children :+ <zzz />.convert)
@@ -304,7 +304,7 @@ class ZipperSpecs extends Specification with ScalaCheck with XMLGenerators {
case e: Elem => for(i <- 0 until 10) yield e.copy(name=e.name+i)
}
- val filtered = expanded \^ elementWhere {e:Elem => ((e.name.substring(1).toInt) % 2) == 0}
+ val filtered = expanded select elementWhere {e:Elem => ((e.name.substring(1).toInt) % 2) == 0}
val modified = filtered map {e => e.copy(name="z"+e.name)}
@@ -316,11 +316,11 @@ class ZipperSpecs extends Specification with ScalaCheck with XMLGenerators {
"rebuild from empty result set" in {
val xml = Group(<parent><child/><child/></parent>.convert)
- (xml \^ 'foo).unselect mustEqual xml
- (bookstore \ 'book \^ 'foo).unselect mustEqual (bookstore \ 'book)
- (bookstore \^ 'bookstore \^ 'foo).unselect mustEqual (bookstore \^ 'bookstore)
- (bookstore \ 'book \^ 'foo).unselect.unselect mustEqual Group(bookstore)
- (bookstore \^ 'bookstore \^ 'foo).unselect.unselect mustEqual Group(bookstore)
+ (xml select 'foo).unselect mustEqual xml
+ (bookstore \ 'book select 'foo).unselect mustEqual (bookstore \ 'book)
+ (bookstore select 'bookstore select 'foo).unselect mustEqual (bookstore select 'bookstore)
+ (bookstore \ 'book select 'foo).unselect.unselect mustEqual Group(bookstore)
+ (bookstore select 'bookstore select 'foo).unselect.unselect mustEqual Group(bookstore)
}
}

0 comments on commit 6ab2a4d

Please sign in to comment.