From f913d796772ae3956702f0d96ca30a7992b8c396 Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 29 Jan 2008 10:51:30 +0000 Subject: added test for optional attributes --- test/files/jvm/xml03syntax.check | 3 +++ test/files/jvm/xml03syntax.scala | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'test/files') diff --git a/test/files/jvm/xml03syntax.check b/test/files/jvm/xml03syntax.check index 7b2eb1310c..fd1e10cac9 100644 --- a/test/files/jvm/xml03syntax.check +++ b/test/files/jvm/xml03syntax.check @@ -12,3 +12,6 @@ 2 4 2 4 + +node=, key=Some(hello) +node=, key=None diff --git a/test/files/jvm/xml03syntax.scala b/test/files/jvm/xml03syntax.scala index fd3fbfaf8f..fab139e5e8 100644 --- a/test/files/jvm/xml03syntax.scala +++ b/test/files/jvm/xml03syntax.scala @@ -9,7 +9,11 @@ object Test extends AnyRef with Assert { } def main(args: Array[String]) { + test1 + test2 + } + private def test1 { val xNull = {null} // these used to be Atom(unit), changed to empty children assertSameElements(xNull.child, Nil) @@ -51,13 +55,26 @@ object Test extends AnyRef with Assert { println(z.toString() + {if (z.isInstanceOf[Text]) "(is text node ' ')" else ""}) } - val xh = { for(val x <- List(1,2,3,4); x % 2 == 0) yield x } + val xh = { for(x <- List(1,2,3,4) if x % 2 == 0) yield x } println(xh) for (z <- xh.child) { println(z.toString() + {if (z.isInstanceOf[Text]) "(is text node ' ')" else ""}) } + println + } + /** see SVN r13821 (emir): support for , + * so that Options can be used for optional attributes. + */ + private def test2 { + val x1: Option[Seq[Node]] = Some(hello) + val n1 = ; + println("node="+n1+", key="+n1.attribute("key")) + + val x2: Option[Seq[Node]] = None + val n2 = ; + println("node="+n2+", key="+n2.attribute("key")) } } -- cgit v1.2.3