summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2008-04-13 23:48:34 +0000
committerBurak Emir <emir@epfl.ch>2008-04-13 23:48:34 +0000
commitf4ab1e5dfa6e907500c68bdca0decbd33d4369e8 (patch)
tree144e44dd96ac99e6883e74a7296ecb0f8cfa4cb7 /test
parent88a96b4ff37f122ae702cc8063731330eba676b5 (diff)
downloadscala-f4ab1e5dfa6e907500c68bdca0decbd33d4369e8.tar.gz
scala-f4ab1e5dfa6e907500c68bdca0decbd33d4369e8.tar.bz2
scala-f4ab1e5dfa6e907500c68bdca0decbd33d4369e8.zip
method NodeSeq#\ supports arguments like "@{uri...
method NodeSeq#\ supports arguments like "@{uri}attrname" for searching prefixed attributes.
Diffstat (limited to 'test')
-rw-r--r--test/files/jvm/xml02.scala34
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&amp;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
)