diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/jvm/xml02.scala | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/test/files/jvm/xml02.scala b/test/files/jvm/xml02.scala index ad1e95cbb0..1c3f4c2599 100644 --- a/test/files/jvm/xml02.scala +++ b/test/files/jvm/xml02.scala @@ -5,11 +5,11 @@ object Test extends TestConsoleMain { import scala.xml.{NodeSeq, Utility} import NodeSeq.view - val ax = <hello foo="bar"> + val ax = <hello foo="bar" x:foo="baz" xmlns:x="the namespace from outer space"> <world/> </hello> - val cx = <z:hello foo="bar" xmlns:z="z"> + val cx = <z:hello foo="bar" xmlns:z="z" x:foo="baz" xmlns:x="the namespace from outer space"> crazy text world </z:hello> @@ -22,11 +22,38 @@ object Test extends TestConsoleMain { 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) } } + object XmlEy extends TestCase("attributes with namespace") with Assert { + override def runTest = { + val z = ax \ "@{the namespace from outer space}foo" + assertTrue("@six", ax \ "@{the namespace from outer space}foo" == "baz") + assertTrue("@eight", cx \ "@{the namespace from outer space}foo" == "baz") + + try { + ax \ "@" + assertTrue("wrong1", false) + } catch { + case _: IllegalArgumentException => + } + try { + ax \ "@{" + assertTrue("wrong2", false) + } catch { + case _: IllegalArgumentException => + } + try { + ax \ "@{}" + assertTrue("wrong3", false) + } catch { + case _: IllegalArgumentException => + } + + } + } + object XmlPat extends TestCase("patterns") with Assert { override def runTest = { assertTrue(<hello/> match { case <hello/> => true; case _ => false; }) @@ -44,6 +71,7 @@ object Test extends TestConsoleMain { } def suite = new TestSuite( XmlEx, + XmlEy, XmlPat, DodgyNamespace ) |