diff options
Diffstat (limited to 'test/files/jvm/xml02.scala')
-rw-r--r-- | test/files/jvm/xml02.scala | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/test/files/jvm/xml02.scala b/test/files/jvm/xml02.scala index d0d97e64eb..ac400d7adf 100644 --- a/test/files/jvm/xml02.scala +++ b/test/files/jvm/xml02.scala @@ -1,39 +1,32 @@ -object Test { -def main(args:Array[String]) = { +import testing.SUnit._ + +object Test extends TestConsoleMain { + import scala.xml.NodeSeq import NodeSeq.view - import testing.UnitTest._ - val ax = <hello foo="bar"> <world/> </hello> - Console.println("attributes"); - - Console.println("one"); - assertEquals(ax \ "@foo", "bar") - Console.println("two"); - assertEquals(ax \ "@foo", xml.Text("bar")) - val bx = <hello foo="bar&x"></hello> - Console.println("three"); - assertEquals(bx \ "@foo", "bar&x") - Console.println("four"); - assertSameElements(bx \ "@foo", List(xml.Text("bar&x"))) - //assertSameElements(bx \ "@foo", List(xml.Text("bar"),xml.EntityRef("amp"),xml.Text("x"))) - - Console.println("five"); - assertEquals(bx.toString, "<hello foo=\"bar&x\"></hello>") - - - /* patterns */ - Console.println("patterns"); - assertEquals(<hello/> match { case <hello/> => true; case _ => false; }, - true); + class XmlEx extends TestCase("attributes") with Assert { + override def run = { + assertEquals("@one", "bar", ax \ "@foo") + assertEquals("@two", xml.Text("bar"), ax \ "@foo") + assertEquals("@three", "bar&x", bx \ "@foo") + assertTrue ("@four", (bx \ "@foo") sameElements List(xml.Text("bar&x"))) + //assertTrue("@four", (bx \ "@foo") sameElements List(xml.Text("bar"),xml.EntityRef("amp"),xml.Text("x"))) + assertEquals("@five", "<hello foo=\"bar&x\"></hello>", bx.toString) + } + } + class XmlPat extends TestCase("patterns") with Assert { + override def run = { + assertTrue(<hello/> match { case <hello/> => true; case _ => false; }) + assertTrue(<x:ga xmlns:x="z"/> match { case <x:ga/> => true; case _ => false; }); /* assertEquals(ax match { case x @ <hello> @@ -51,6 +44,10 @@ def main(args:Array[String]) = { case _ => false; }, true); */ -} - + } + } + def suite = new TestSuite( + new XmlEx, + new XmlPat + ) } |