summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2006-10-14 13:31:12 +0000
committerBurak Emir <emir@epfl.ch>2006-10-14 13:31:12 +0000
commit470f990722777041a475de2e5cf02ca4504a2237 (patch)
tree4527d5a708f563c53ffcc1e37f908c76062cd201 /test/files/run
parentf1208fc000438bb03bbb18011659dd4ca25d1127 (diff)
downloadscala-470f990722777041a475de2e5cf02ca4504a2237.tar.gz
scala-470f990722777041a475de2e5cf02ca4504a2237.tar.bz2
scala-470f990722777041a475de2e5cf02ca4504a2237.zip
xml improvements for 2.2.1 (see changes)
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/unittest_xml.scala55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/files/run/unittest_xml.scala b/test/files/run/unittest_xml.scala
new file mode 100644
index 0000000000..5f7c523996
--- /dev/null
+++ b/test/files/run/unittest_xml.scala
@@ -0,0 +1,55 @@
+
+object Test {
+
+ import scala.testing.SUnit._
+ import scala.xml.{MetaData, Null, PrefixedAttribute, UnprefixedAttribute }
+
+ class MetaDataTest extends TestCase("collection.mutable.ArrayBuffer") with Assert {
+
+ import scala.xml.{TopScope, NamespaceBinding, Atom, Text }
+
+ override def runTest = {
+
+ var x: MetaData = Null
+ var s: NamespaceBinding = TopScope
+
+ // testing method def apply(uri:String, scp:NamespaceBinding, k:String): Seq[Node]
+ // def apply(k:String): Seq[Node]
+
+ assertEquals("absent element (prefixed) 1", null, x("za://foo.com", s, "bar" ))
+ assertEquals("absent element (unprefix) 1", null, x("bar"))
+
+ assertEquals("absent element (prefixed) 2", None, x.get("za://foo.com", s, "bar" ))
+ assertEquals("absent element (unprefix) 2", None, x.get("bar"))
+
+ x = new PrefixedAttribute("zo","bar", new Atom(42), x)
+ s = new NamespaceBinding("zo","za://foo.com",s)
+
+ assertEquals("present element (prefixed) 3", new Atom(42), x("za://foo.com", s, "bar" ))
+ assertEquals("present element (unprefix) 3", null, x("bar"))
+
+ assertEquals("present element (prefixed) 4", Some(new Atom(42)), x.get("za://foo.com", s, "bar" ))
+ assertEquals("present element (unprefix) 4", None, x.get("bar"))
+
+ x = new UnprefixedAttribute("bar","meaning", x)
+
+ assertEquals("present element (prefixed) 5", null, x(null, s, "bar" ))
+ assertEquals("present element (unprefix) 5", Text("meaning"), x("bar"))
+
+ assertEquals("present element (prefixed) 6", None, x.get(null, s, "bar" ))
+ assertEquals("present element (unprefix) 6", Some(Text("meaning")), x.get("bar"))
+
+ }
+ }
+
+ def main(args:Array[String]) = {
+ val ts = new TestSuite(
+ new MetaDataTest //,
+ )
+ val tr = new TestResult()
+ ts.run(tr)
+ for(val failure <- tr.failures) {
+ Console.println(failure)
+ }
+ }
+}