summaryrefslogtreecommitdiff
path: root/test/files/jvm/xml02.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/jvm/xml02.scala')
-rw-r--r--test/files/jvm/xml02.scala62
1 files changed, 31 insertions, 31 deletions
diff --git a/test/files/jvm/xml02.scala b/test/files/jvm/xml02.scala
index 11f77cc90f..fb790d5926 100644
--- a/test/files/jvm/xml02.scala
+++ b/test/files/jvm/xml02.scala
@@ -1,6 +1,11 @@
-import testing.SUnit._
+object Test {
-object Test extends TestConsoleMain {
+ def main(args: Array[String]) {
+ XmlEx.run()
+ XmlEy.run()
+ XmlPat.run()
+ DodgyNamespace.run()
+ }
import scala.xml.{NodeSeq, Utility}
import NodeSeq.seqToNodeSeq
@@ -15,38 +20,38 @@ object Test extends TestConsoleMain {
val bx = <hello foo="bar&amp;x"></hello>
- object XmlEx extends TestCase("attributes") with Assert {
+ object XmlEx {
- override def runTest = {
- assertTrue("@one", (ax \ "@foo") xml_== "bar") // uses NodeSeq.view!
- assertTrue("@two", (ax \ "@foo") xml_== xml.Text("bar")) // dto.
- assertTrue("@three", (bx \ "@foo") xml_== "bar&x") // dto.
- assertTrue ("@four", (bx \ "@foo") xml_sameElements List(xml.Text("bar&x")))
- assertEquals("@five", "<hello foo=\"bar&amp;x\"></hello>", bx.toString)
+ def run() {
+ assert((ax \ "@foo") xml_== "bar") // uses NodeSeq.view!
+ assert((ax \ "@foo") xml_== xml.Text("bar")) // dto.
+ assert((bx \ "@foo") xml_== "bar&x") // dto.
+ assert((bx \ "@foo") xml_sameElements List(xml.Text("bar&x")))
+ assert("<hello foo=\"bar&amp;x\"></hello>" == bx.toString)
}
}
- object XmlEy extends TestCase("attributes with namespace") with Assert {
- override def runTest = {
+ object XmlEy {
+ def run() {
val z = ax \ "@{the namespace from outer space}foo"
- assertTrue("@six", (ax \ "@{the namespace from outer space}foo") xml_== "baz")
- assertTrue("@eight", (cx \ "@{the namespace from outer space}foo") xml_== "baz")
+ assert((ax \ "@{the namespace from outer space}foo") xml_== "baz")
+ assert((cx \ "@{the namespace from outer space}foo") xml_== "baz")
try {
ax \ "@"
- assertTrue("wrong1", false)
+ assert(false)
} catch {
case _: IllegalArgumentException =>
}
try {
ax \ "@{"
- assertTrue("wrong2", false)
+ assert(false)
} catch {
case _: IllegalArgumentException =>
}
try {
ax \ "@{}"
- assertTrue("wrong3", false)
+ assert(false)
} catch {
case _: IllegalArgumentException =>
}
@@ -54,25 +59,20 @@ object Test extends TestConsoleMain {
}
}
- object XmlPat extends TestCase("patterns") with Assert {
- override def runTest = {
- assertTrue(<hello/> match { case <hello/> => true; case _ => false; })
- assertTrue(<x:ga xmlns:x="z"/> match { case <x:ga/> => true; case _ => false; });
- assertTrue(Utility.trim(cx) match { case n @ <hello>crazy text world</hello> if (n \ "@foo") xml_== "bar" => true; })
- assertTrue(Utility.trim(cx) match { case n @ <z:hello>crazy text world</z:hello> if (n \ "@foo") xml_== "bar" => true; })
+ object XmlPat {
+ def run() {
+ assert(<hello/> match { case <hello/> => true; case _ => false; })
+ assert(<x:ga xmlns:x="z"/> match { case <x:ga/> => true; case _ => false; });
+ assert(Utility.trim(cx) match { case n @ <hello>crazy text world</hello> if (n \ "@foo") xml_== "bar" => true; })
+ assert(Utility.trim(cx) match { case n @ <z:hello>crazy text world</z:hello> if (n \ "@foo") xml_== "bar" => true; })
}
}
- object DodgyNamespace extends TestCase("DodgyNamespace") with Assert {
- override def runTest = {
+ object DodgyNamespace {
+ def run() {
val x = <flog xmlns:ee="http://ee.com"><foo xmlns:dog="http://dog.com"><dog:cat/></foo></flog>
- assertTrue(x.toString.matches(".*xmlns:dog=\"http://dog.com\".*"));
+ assert(x.toString.matches(".*xmlns:dog=\"http://dog.com\".*"));
}
}
- def suite = new TestSuite(
- XmlEx,
- XmlEy,
- XmlPat,
- DodgyNamespace
- )
+
}