Permalink
Browse files

Added Elem#canonicalize method

  • Loading branch information...
djspiewak committed May 14, 2011
1 parent e01a16d commit 042eab85958bb12c7b833faca337903ab0db17f7
@@ -111,6 +111,12 @@ case class ProcInstr(target: String, data: String) extends Node {
* }}}
*/
case class Elem(prefix: Option[String], name: String, attrs: Attributes, scope: Map[String, String], children: Group[Node]) extends Node with Selectable[Elem] {
/**
* See the `canonicalize` method on [[com.codecommit.antixml.Group]].
*/
def canonicalize = copy(children=children.canonicalize)
override def toString = {
import Node._
@@ -30,8 +30,14 @@ package com.codecommit.antixml
import org.specs2.mutable._
import org.specs2.matcher.DataTables
import org.specs2.ScalaCheck
import org.scalacheck._
class NodeSpecs extends Specification with DataTables {
class NodeSpecs extends Specification with DataTables with ScalaCheck with XMLGenerators {
import Prop._
lazy val numProcessors = Runtime.getRuntime.availableProcessors()
implicit val params = set(workers -> numProcessors, maxSize -> 15) // doesn't need to be so large
"elements" should {
"serialize empty elements correctly" in {
@@ -57,6 +63,10 @@ class NodeSpecs extends Specification with DataTables {
"select text within self" in {
(<parent>Text</parent>.anti \\ text mkString) mustEqual "Text"
}
"delegate canonicalization to Group" in check { e: Elem =>
e.canonicalize mustEqual e.copy(children=e.children.canonicalize)
}
}
"text nodes" should {

0 comments on commit 042eab8

Please sign in to comment.