diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-07-17 09:27:29 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-08-27 10:26:21 -0700 |
commit | 9c50dd52743b7ff4de19548669dfa7e7a0304034 (patch) | |
tree | 8b0044529b3106ea84bca046dc5710fada708cce /test/files/jvm/xmlstuff.scala | |
parent | 7817efe2468480317965fc5baece52be392f0f7a (diff) | |
download | scala-9c50dd52743b7ff4de19548669dfa7e7a0304034.tar.gz scala-9c50dd52743b7ff4de19548669dfa7e7a0304034.tar.bz2 scala-9c50dd52743b7ff4de19548669dfa7e7a0304034.zip |
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.
Diffstat (limited to 'test/files/jvm/xmlstuff.scala')
-rw-r--r-- | test/files/jvm/xmlstuff.scala | 181 |
1 files changed, 0 insertions, 181 deletions
diff --git a/test/files/jvm/xmlstuff.scala b/test/files/jvm/xmlstuff.scala deleted file mode 100644 index 45234c7139..0000000000 --- a/test/files/jvm/xmlstuff.scala +++ /dev/null @@ -1,181 +0,0 @@ -import java.io.StringReader -import org.xml.sax.InputSource -import scala.xml.{Node, NodeSeq, Elem, Text, XML} - -object Test { - - /** returns true if exception was thrown */ - def catcher(att: Function1[Unit, scala.xml.MetaData]): Boolean = { - var ex = false - try { - att.apply({}) - } catch { - case scala.xml.MalformedAttributeException(msg) => - println(msg) - ex = true - } - ex - } - - def main(args: Array[String]) { - - println("NodeSeq") - - val p = <foo> - <bar gt='ga' value="3"/> - <baz bazValue="8"/> - <bar value="5" gi='go'/> - </foo>; - - val pelems_1 = for (x <- p \ "bar"; y <- p \ "baz" ) yield { - Text(x.attributes("value").toString + y.attributes("bazValue").toString+ "!") - }; - val pelems_2 = new NodeSeq { val theSeq = List(Text("38!"),Text("58!")) }; - assert(pelems_1 sameElements pelems_2) - - assert(Text("8") sameElements (p \\ "@bazValue")) - - val books = - <bks> - <book><title>Blabla</title></book> - <book><title>Blubabla</title></book> - <book><title>Baaaaaaalabla</title></book> - </bks>; - - val reviews = - <reviews> - <entry><title>Blabla</title> - <remarks> - Hallo Welt. - </remarks> - </entry> - <entry><title>Blubabla</title> - <remarks> - Hello Blu - </remarks> - </entry> - <entry><title>Blubabla</title> - <remarks> - rem 2 - </remarks> - </entry> - </reviews>; - - println( new scala.xml.PrettyPrinter(80, 5).formatNodes ( - for (t <- books \\ "title"; - r <- reviews \\ "entry" - if (r \ "title") xml_== t) yield - <result> - { t } - { r \ "remarks" } - </result> - )); - - // example - println( - for (t @ <book><title>Blabla</title></book> <- new NodeSeq { val theSeq = books.child }.toList) - yield t - ); - val phoneBook = - <phonebook> - <descr> - This is the <b>phonebook</b> of the - <a href="http://acme.org">ACME</a> corporation. - </descr> - <entry> - <name>John</name> - <phone where="work"> +41 21 693 68 67</phone> - <phone where="mobile">+41 79 602 23 23</phone> - </entry> - </phonebook>; - - - val addrBook = - <addrbook> - <descr> - This is the <b>addressbook</b> of the - <a href="http://acme.org">ACME</a> corporation. - </descr> - <entry> - <name>John</name> - <street> Elm Street</street> - <city>Dolphin City</city> - </entry> - </addrbook>; - - println( new scala.xml.PrettyPrinter(80, 5).formatNodes ( - for (t <- addrBook \\ "entry"; - r <- phoneBook \\ "entry" - if (t \ "name") xml_== (r \ "name")) yield - <result> - { t.child } - { r \ "phone" } - </result> - )); - - - /* namespaces */ - // begin tmp - println("namespaces") - val cuckoo = <cuckoo xmlns="http://cuckoo.com"> - <foo/> - <bar/> - </cuckoo>; - assert(cuckoo.namespace == "http://cuckoo.com") - for (n <- cuckoo \ "_" ) { - //println("n = "+n); - //println("n.prefix = "+n.prefix); - //.println("n.scope = "+n.scope); - assert( n.namespace == "http://cuckoo.com") - } - - println("validation - elements") - val vtor = new scala.xml.dtd.ElementValidator(); - { - import scala.xml.dtd.ELEMENTS - import scala.xml.dtd.ContentModel._ - vtor.setContentModel( - ELEMENTS( - Sequ( - Letter(ElemName("bar")), - Star(Letter(ElemName("baz"))) ))); - - } - assert(vtor( <foo><bar/><baz/><baz/></foo> )) - - { - import scala.xml.dtd.MIXED - import scala.xml.dtd.ContentModel._ - - vtor.setContentModel( - MIXED( - Alt(Letter(ElemName("bar")), - Letter(ElemName("baz")), - Letter(ElemName("bal"))))); - } - - assert(vtor(<foo><bar/><baz/><baz/></foo> )) - assert(vtor(<foo>ab<bar/>cd<baz/>ed<baz/>gh</foo> )) - assert(!vtor(<foo> <ugha/> <bugha/> </foo> )) - - println("validation - attributes") - vtor.setContentModel(null) - vtor.setMetaData(List()) - assert(!vtor( <foo bar="hello"/> )) - - { - import scala.xml.dtd._ - vtor setMetaData List(AttrDecl("bar", "CDATA", IMPLIED)) - } - assert(!vtor(<foo href="http://foo.com" bar="hello"/>)) - assert(vtor(<foo bar="hello"/>)) - - { - import scala.xml.dtd._ - vtor.setMetaData(List(AttrDecl("bar","CDATA",REQUIRED))) - } - assert(!vtor( <foo href="http://foo.com" /> )) - assert( vtor( <foo bar="http://foo.com" /> )) - - } -} |