From f4ab1e5dfa6e907500c68bdca0decbd33d4369e8 Mon Sep 17 00:00:00 2001 From: Burak Emir Date: Sun, 13 Apr 2008 23:48:34 +0000 Subject: method NodeSeq#\ supports arguments like "@{uri... method NodeSeq#\ supports arguments like "@{uri}attrname" for searching prefixed attributes. --- test/files/jvm/xml02.scala | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'test') 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 = + val ax = - val cx = + val cx = crazy text world @@ -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", "", 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( match { case => true; case _ => false; }) @@ -44,6 +71,7 @@ object Test extends TestConsoleMain { } def suite = new TestSuite( XmlEx, + XmlEy, XmlPat, DodgyNamespace ) -- cgit v1.2.3