diff options
-rw-r--r-- | sources/scala/xml/Comment.scala | 5 | ||||
-rw-r--r-- | sources/scala/xml/EntityRef.scala | 5 | ||||
-rw-r--r-- | sources/scala/xml/ProcInstr.scala | 5 | ||||
-rw-r--r-- | sources/scala/xml/Text.scala | 6 | ||||
-rw-r--r-- | test/files/jvm/xmlLiterals.scala | 2 |
5 files changed, 22 insertions, 1 deletions
diff --git a/sources/scala/xml/Comment.scala b/sources/scala/xml/Comment.scala index 226a881da8..e89674396a 100644 --- a/sources/scala/xml/Comment.scala +++ b/sources/scala/xml/Comment.scala @@ -22,6 +22,11 @@ case class Comment( text:String ) extends Node { if( text.indexOf("--" ) != -1 ) throw new IllegalArgumentException("text containts \"--\""); + final override def equals(x:Any) = x match { + case Comment( s ) => text.equals( s ); + case _ => false; + } + /** the constant "#REM" */ def label = "#REM"; diff --git a/sources/scala/xml/EntityRef.scala b/sources/scala/xml/EntityRef.scala index 0b4edef76e..117519e266 100644 --- a/sources/scala/xml/EntityRef.scala +++ b/sources/scala/xml/EntityRef.scala @@ -21,6 +21,11 @@ case class EntityRef( entityName:String ) extends Node { */ def label = "#ENTITY"; + final override def equals(x:Any) = x match { + case EntityRef( s ) => entityName.equals( s ); + case _ => false; + } + /** always empty */ final def attribute = immutable.TreeMap.Empty[String,String]; diff --git a/sources/scala/xml/ProcInstr.scala b/sources/scala/xml/ProcInstr.scala index 10c690ccb6..d49125f702 100644 --- a/sources/scala/xml/ProcInstr.scala +++ b/sources/scala/xml/ProcInstr.scala @@ -31,6 +31,11 @@ case class ProcInstr( target:String, text:Option[String] ) extends Node { case _ => } + final override def equals(x:Any) = x match { + case x @ ProcInstr( t2, s2 ) => target.equals( t2 ) && text.equals( s2 ); + case _ => false; + } + /** the constant "#PI" */ final def label = "#PI"; diff --git a/sources/scala/xml/Text.scala b/sources/scala/xml/Text.scala index d937b6d0db..a8dcdebe53 100644 --- a/sources/scala/xml/Text.scala +++ b/sources/scala/xml/Text.scala @@ -22,6 +22,12 @@ case class Text( text:String ) extends Node { */ def label = "#PCDATA"; + final override def equals(x:Any) = x match { + case s:String => text.equals( s ); + case Text( s ) => text.equals( s ); + case _ => false; + } + /** always empty */ final def attribute = immutable.TreeMap.Empty[String,String]; diff --git a/test/files/jvm/xmlLiterals.scala b/test/files/jvm/xmlLiterals.scala index 3b20525159..c45f2a1cd5 100644 --- a/test/files/jvm/xmlLiterals.scala +++ b/test/files/jvm/xmlLiterals.scala @@ -138,7 +138,7 @@ object Test { // these are not equal as comments are valid XML Info items. assertEquals( rows2, Elem("tr",e,Comment(" an XML comment "),ProcInstr("pinotext",None),ProcInstr("pi",Some("text")))); - assertEquals( rows3, Elem("tr",e,Text(" a "),Comment(" an XML comment "),Text(" b "),ProcInstr("pinotext",None),Text(" c "),ProcInstr("pi",Some("text")),Text(" d "))); + assertEquals( rows3, Elem("tr",e,Text("a"),Comment(" an XML comment "),Text("b"),ProcInstr("pinotext",None),Text("c"),ProcInstr("pi",Some("text")),Text("d"))); } |