From 9c50dd52743b7ff4de19548669dfa7e7a0304034 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Wed, 17 Jul 2013 09:27:29 -0700 Subject: Prepare removal of scala-xml, scala-parser-combinators Every test deleted here has found its way to the respective repositories of scala-xml and scala-parser-combinators, where they will continue to be tested with partest. The modified tests became independent of these modules, as they should've been from the start. --- test/files/jvm/xml01.scala | 182 --------------------------------------------- 1 file changed, 182 deletions(-) delete mode 100644 test/files/jvm/xml01.scala (limited to 'test/files/jvm/xml01.scala') diff --git a/test/files/jvm/xml01.scala b/test/files/jvm/xml01.scala deleted file mode 100644 index 2b456f5ff5..0000000000 --- a/test/files/jvm/xml01.scala +++ /dev/null @@ -1,182 +0,0 @@ -import java.io.StringReader -import org.xml.sax.InputSource - -import scala.xml._ - -object Test extends App { - def Elem(prefix: String, label: String, attributes: MetaData, scope: NamespaceBinding, child: Node*): Elem = - scala.xml.Elem.apply(prefix, label, attributes, scope, minimizeEmpty = true, child: _*) - val e: scala.xml.MetaData = Null //Node.NoAttributes - val sc: scala.xml.NamespaceBinding = TopScope - - val xmlFile1 = ""; - val isrc1 = new InputSource(new StringReader(xmlFile1)) - val parsedxml1 = XML.load(isrc1) - val isrc11 = new InputSource(new StringReader(xmlFile1)) - val parsedxml11 = XML.load(isrc11) - - val c = new Node { - def label = "hello" - override def hashCode() = - Utility.hashCode(prefix, label, attributes.hashCode(), scope.hashCode(), child); - def child = Elem(null, "world", e, sc); - //def attributes = e; - override def text = "" - } - - println("equality") - assert(c == parsedxml11) - assert(parsedxml1 == parsedxml11) - assert(List(parsedxml1) sameElements List(parsedxml11)) - assert(Array(parsedxml1).toList sameElements List(parsedxml11)) - - val x2 = "Peter BunemanDan SuciuData on ze web"; - - val i = new InputSource(new StringReader(x2)) - val x2p = XML.load(i) - - assert(x2p == Elem(null, "book" , e, sc, - Elem(null, "author", e, sc,Text("Peter Buneman")), - Elem(null, "author", e, sc,Text("Dan Suciu")), - Elem(null, "title" , e, sc,Text("Data on ze web")))) - - val xmlFile2 = "Peter BunemanDan SuciuData on ze webJohn MitchellFoundations of Programming Languages"; - val isrc2 = new InputSource(new StringReader(xmlFile2)) - val parsedxml2 = XML.load(isrc2) - - println("xpath \\") - - assert(parsedxml1 \ "_" sameElements List(Elem(null,"world", e, sc))) - - assert(parsedxml1 \ "world" sameElements List(Elem(null,"world", e, sc))) - - assert( - (parsedxml2 \ "_") sameElements List( - Elem(null,"book", e, sc, - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), - Elem(null,"title" , e, sc, Text("Data on ze web"))), - Elem(null,"book",e,sc, - Elem(null,"author",e,sc,Text("John Mitchell")), - Elem(null,"title",e,sc,Text("Foundations of Programming Languages")))) - ) - assert((parsedxml2 \ "author").isEmpty) - - assert( - (parsedxml2 \ "book") sameElements List( - Elem(null,"book",e,sc, - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), - Elem(null,"title" , e, sc, Text("Data on ze web"))), - Elem(null,"book",e,sc, - Elem(null,"author", e, sc, Text("John Mitchell")), - Elem(null,"title" , e, sc, Text("Foundations of Programming Languages"))) - ) - ) - - assert( - (parsedxml2 \ "_" \ "_") sameElements List( - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), - Elem(null,"title" , e, sc, Text("Data on ze web")), - Elem(null,"author", e, sc, Text("John Mitchell")), - Elem(null,"title" , e, sc, Text("Foundations of Programming Languages")) - ) - ) - - assert( - (parsedxml2 \ "_" \ "author") sameElements List( - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), - Elem(null,"author", e, sc, Text("John Mitchell")) - ) - ) - - assert((parsedxml2 \ "_" \ "_" \ "author").isEmpty) - - Console.println("xpath \\\\ DESCENDANTS"); - - assert( - (parsedxml2 \\ "author") sameElements List( - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), - Elem(null,"author", e, sc, Text("John Mitchell")) - ) - ) - - assert( - (parsedxml2 \\ "title") sameElements List( - Elem(null,"title", e, sc, Text("Data on ze web")), - Elem(null,"title", e, sc, Text("Foundations of Programming Languages"))) - ) - - - println( - (parsedxml2 \\ "book" ){ n:Node => (n \ "title") xml_== "Data on ze web" } - ) - - assert( - ((new NodeSeq { val theSeq = List( parsedxml2 ) }) \\ "_") sameElements List( - Elem(null,"bib",e,sc, - Elem(null,"book",e,sc, - Elem(null, "author", e, sc, Text("Peter Buneman")), - Elem(null, "author", e, sc, Text("Dan Suciu")), - Elem(null, "title" , e, sc, Text("Data on ze web"))), - Elem(null,"book",e,sc, - Elem(null,"author",e,sc,Text("John Mitchell")), - Elem(null,"title",e,sc,Text("Foundations of Programming Languages")))), - Elem(null,"book",e,sc, - Elem(null,"author",e,sc,Text("Peter Buneman")), - Elem(null,"author",e,sc,Text("Dan Suciu")), - Elem(null,"title",e,sc,Text("Data on ze web"))), - Elem(null,"author",e,sc,Text("Peter Buneman")), - Elem(null,"author",e,sc,Text("Dan Suciu")), - Elem(null,"title",e,sc,Text("Data on ze web")), - Elem(null,"book",e,sc, - Elem(null,"author",e,sc,Text("John Mitchell")), - Elem(null,"title",e,sc,Text("Foundations of Programming Languages"))), - Elem(null,"author",e,sc,Text("John Mitchell")), - Elem(null,"title",e,sc,Text("Foundations of Programming Languages")) - ) - ) - - // test group node - Console println "-- group nodes" - val zx1: Node = Group { } - val zy1 = {zx1} - Console println zy1.toString() - - val zx2: Node = Group { List(,zy1,zx1) } - Console println zx2.toString() - - val zz1 = - - assert(zx1 xml_== zz1) - assert(zz1.length == 3) - - // unparsed - - println("attribute value normalization") - val xmlAttrValueNorm = ""; - { - val isrcA = new InputSource( new StringReader(xmlAttrValueNorm) ); - val parsedxmlA = XML.load(isrcA); - val c = (parsedxmlA \ "@nom").text.charAt(0); - assert(c == '\u015e'); - } - // buraq: if the following test fails with 'character x not allowed', it is - // related to the mutable variable in a closures in MarkupParser.parsecharref - { - val isr = scala.io.Source.fromString(xmlAttrValueNorm); - val pxmlB = scala.xml.parsing.ConstructingParser.fromSource(isr,false); - val parsedxmlB = pxmlB.element(TopScope); - val c = (parsedxmlB \ "@nom").text.charAt(0); - assert(c == '\u015e'); - } - - // #60 test by round trip - - val p = scala.xml.parsing.ConstructingParser.fromSource(scala.io.Source.fromString(""),true) - val n = p.element(new scala.xml.NamespaceBinding("bar","BAR",scala.xml.TopScope))(0) - assert( n.attributes.get("BAR", n, "attr").nonEmpty) -} -- cgit v1.2.3