diff options
author | Burak Emir <emir@epfl.ch> | 2007-03-02 19:25:20 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2007-03-02 19:25:20 +0000 |
commit | d3d697a9c5c51e4a78d8a0392cc37723bbe6e3e5 (patch) | |
tree | 4ff23a88110d9146a33ae56929fb9a4384435a55 /test/files | |
parent | 61b2debaa00361250fbee05cbb71f2c989ad2c03 (diff) | |
download | scala-d3d697a9c5c51e4a78d8a0392cc37723bbe6e3e5.tar.gz scala-d3d697a9c5c51e4a78d8a0392cc37723bbe6e3e5.tar.bz2 scala-d3d697a9c5c51e4a78d8a0392cc37723bbe6e3e5.zip |
fixed xml02
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/jvm/xml02.scala | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/test/files/jvm/xml02.scala b/test/files/jvm/xml02.scala index ac400d7adf..bae815b1c1 100644 --- a/test/files/jvm/xml02.scala +++ b/test/files/jvm/xml02.scala @@ -2,21 +2,25 @@ import testing.SUnit._ object Test extends TestConsoleMain { - import scala.xml.NodeSeq + import scala.xml.{NodeSeq, Utility} import NodeSeq.view val ax = <hello foo="bar"> <world/> </hello> + val cx = <z:hello foo="bar" xmlns:z="z"> + crazy text world + </z:hello> + val bx = <hello foo="bar&x"></hello> 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") + override def runTest = { + assertTrue("@one", ax \ "@foo" == "bar") // uses NodeSeq.view! + assertTrue("@two", ax \ "@foo" == xml.Text("bar")) // dto. + assertTrue("@three", bx \ "@foo" == "bar&x") // dto. 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) @@ -24,28 +28,13 @@ object Test extends TestConsoleMain { } class XmlPat extends TestCase("patterns") with Assert { - override def run = { + override def runTest = { 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> - <world/> - </hello> if x \ "@foo" == "bar" => true; - case _ => false; }, - true); - - assertEquals( - <hello foo="bar"> - crazy text world - </hello> match { case <hello> - crazy text world - </hello> => true; - case _ => false; }, - true); - */ - } + assertTrue(Utility.trim(cx) match { case n @ <hello>crazy text world</hello> if n \ "@foo" == "bar" => true; }) + } } + def suite = new TestSuite( new XmlEx, new XmlPat |