From 4afa092314487c0095ff9fd5756d05340f6150b0 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 19 May 2011 20:06:19 +0000 Subject: Removes SUnit (long deprecated!) from the stand... Removes SUnit (long deprecated!) from the standard library. the relatively small number of partest tests in Scala's suite that were still using SUnit now either just use regular asserts, or they print stuff that partest checks with a .check file. Also fixed some bad indentation, removed ancient useless-looking commented-out code, etc. Contributed by Seth Tisue (way to go seth) no review. --- test/files/jvm/xmlstuff.scala | 292 +++++++++++++++++++----------------------- 1 file changed, 130 insertions(+), 162 deletions(-) (limited to 'test/files/jvm/xmlstuff.scala') diff --git a/test/files/jvm/xmlstuff.scala b/test/files/jvm/xmlstuff.scala index 6e711a0f86..08aa716352 100644 --- a/test/files/jvm/xmlstuff.scala +++ b/test/files/jvm/xmlstuff.scala @@ -1,10 +1,8 @@ import java.io.StringReader import org.xml.sax.InputSource - -import scala.testing.SUnit.Assert import scala.xml.{Node, NodeSeq, Elem, Text, XML} -object Test extends AnyRef with Assert { +object Test { /** returns true if exception was thrown */ def catcher(att: Function1[Unit, scala.xml.MetaData]): Boolean = { @@ -21,193 +19,163 @@ object Test extends AnyRef with Assert { def main(args: Array[String]) { - //val e: scala.xml.MetaData = null; //Node.NoAttributes; - //val sc: scala.xml.NamespaceBinding = null; - - // ------------------------------------------ tests for class NodeSeq - - /** - println("checking wellformed attributes"); - { - import scala.xml.{ UnprefixedAttribute, Null } - assertTrue(catcher {x:Unit => new UnprefixedAttribute("key", "<", Null)}); // < illegal - assertTrue(catcher(x:Unit => new UnprefixedAttribute("key", "&", Null))); // & illegal - assertTrue(catcher(x:Unit => new UnprefixedAttribute("key", "a&a", Null))); // & illegal - assertTrue(catcher(x:Unit => new UnprefixedAttribute("key", "a&a;&", Null))); // 2nd & - - assertFalse(catcher(x:Unit => new UnprefixedAttribute("key", "a&a; <<", Null))); - } -*/ - -/* -checking wellformed attributes -< not allowed in attribute value -passed ok -malformed entity reference in attribute value [&] -passed ok -malformed entity reference in attribute value [a&a] -passed ok -malformed entity reference in attribute value [a&a;&] -passed ok -passed ok -*/ - - println("NodeSeq") + println("NodeSeq") val p = - - - - ; + + + + ; val pelems_1 = for( val x <- p \ "bar"; val 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!")) }; - assertSameElementsXML(pelems_1, pelems_2) + assert(pelems_1 sameElements pelems_2) - assertEqualsXML(p \\ "@bazValue", Text("8")) + assert(Text("8") sameElements (p \\ "@bazValue")) val books = - - Blabla - Blubabla - Baaaaaaalabla + + Blabla + Blubabla + Baaaaaaalabla ; - val reviews = - - Blabla - - Hallo Welt. - + val reviews = + + Blabla + + Hallo Welt. + + + Blubabla + + Hello Blu + + + Blubabla + + rem 2 + - Blubabla - - Hello Blu - - - Blubabla - - rem 2 - - ; - println( new scala.xml.PrettyPrinter(80, 5).formatNodes ( - for (t <- books \\ "title"; - r <- reviews \\ "entry" - if (r \ "title") xml_== t) yield - - { t } - { r \ "remarks" } - - )); - - // example - println( - for (t @ Blabla <- new NodeSeq { val theSeq = books.child }.toList) - yield t - ); -val phoneBook = - - - This is the phonebook of the - ACME corporation. - - - John - +41 21 693 68 67 - +41 79 602 23 23 - + println( new scala.xml.PrettyPrinter(80, 5).formatNodes ( + for (t <- books \\ "title"; + r <- reviews \\ "entry" + if (r \ "title") xml_== t) yield + + { t } + { r \ "remarks" } + + )); + + // example + println( + for (t @ Blabla <- new NodeSeq { val theSeq = books.child }.toList) + yield t + ); + val phoneBook = + + + This is the phonebook of the + ACME corporation. + + + John + +41 21 693 68 67 + +41 79 602 23 23 + ; -val addrBook = - - - This is the addressbook of the - ACME corporation. - - - John - Elm Street - Dolphin City - + val addrBook = + + + This is the addressbook of the + ACME corporation. + + + John + Elm Street + Dolphin City + ; - println( new scala.xml.PrettyPrinter(80, 5).formatNodes ( - for (t <- addrBook \\ "entry"; - r <- phoneBook \\ "entry" - if (t \ "name") xml_== (r \ "name")) yield - - { t.child } - { r \ "phone" } - - )); - - - /* namespaces */ - // begin tmp - println("namespaces") - val cuckoo = + println( new scala.xml.PrettyPrinter(80, 5).formatNodes ( + for (t <- addrBook \\ "entry"; + r <- phoneBook \\ "entry" + if (t \ "name") xml_== (r \ "name")) yield + + { t.child } + { r \ "phone" } + + )); + + + /* namespaces */ + // begin tmp + println("namespaces") + val cuckoo = - ; - assertEquals(cuckoo.namespace, "http://cuckoo.com") - for (n <- cuckoo \ "_" ) { - //println("n = "+n); - //println("n.prefix = "+n.prefix); - //.println("n.scope = "+n.scope); - assertEquals( n.namespace, "http://cuckoo.com") - } + ; + 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"))) ))); + 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"))) ))); - } - assertEquals(vtor( ), true); - { - 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( )) - assertEquals(vtor( ), true) - assertEquals(vtor(abcdedgh ), true) - assertEquals(vtor( ), false) + { + import scala.xml.dtd.MIXED + import scala.xml.dtd.ContentModel._ + + vtor.setContentModel( + MIXED( + Alt(Letter(ElemName("bar")), + Letter(ElemName("baz")), + Letter(ElemName("bal"))))); + } - println("validation - attributes") - vtor.setContentModel(null) - vtor.setMetaData(List()) - assertEquals(vtor( ), false) + assert(vtor( )) + assert(vtor(abcdedgh )) + assert(!vtor( )) - { - import scala.xml.dtd._ - vtor setMetaData List(AttrDecl("bar", "CDATA", IMPLIED)) - } - assertEquals(vtor(), false) - assertEquals(vtor(), true) + println("validation - attributes") + vtor.setContentModel(null) + vtor.setMetaData(List()) + assert(!vtor( )) - { - import scala.xml.dtd._ - vtor.setMetaData(List(AttrDecl("bar","CDATA",REQUIRED))) - } - assertEquals( vtor( ), false ) - assertEquals( vtor( ), true ) + { + import scala.xml.dtd._ + vtor setMetaData List(AttrDecl("bar", "CDATA", IMPLIED)) + } + assert(!vtor()) + assert(vtor()) + + { + import scala.xml.dtd._ + vtor.setMetaData(List(AttrDecl("bar","CDATA",REQUIRED))) + } + assert(!vtor( )) + assert( vtor( )) } } -- cgit v1.2.3