summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2008-01-29 10:51:30 +0000
committermichelou <michelou@epfl.ch>2008-01-29 10:51:30 +0000
commitf913d796772ae3956702f0d96ca30a7992b8c396 (patch)
treee0e1627e251e54257f0c7b85f59d968d5cae66eb /test
parent9d7b414f6cbb16d87fefb96e28d4c07afde7c65b (diff)
downloadscala-f913d796772ae3956702f0d96ca30a7992b8c396.tar.gz
scala-f913d796772ae3956702f0d96ca30a7992b8c396.tar.bz2
scala-f913d796772ae3956702f0d96ca30a7992b8c396.zip
added test for optional attributes
Diffstat (limited to 'test')
-rw-r--r--test/files/jvm/xml03syntax.check3
-rw-r--r--test/files/jvm/xml03syntax.scala19
2 files changed, 21 insertions, 1 deletions
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 @@
<hello>2 4</hello>
2
4
+
+node=<elem key="<b>hello</b>"></elem>, key=Some(<b>hello</b>)
+node=<elem ></elem>, 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 = <hello>{null}</hello> // 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 = <hello>{ for(val x <- List(1,2,3,4); x % 2 == 0) yield x }</hello>
+ val xh = <hello>{ for(x <- List(1,2,3,4) if x % 2 == 0) yield x }</hello>
println(xh)
for (z <- xh.child) {
println(z.toString() + {if (z.isInstanceOf[Text]) "(is text node ' ')" else ""})
}
+ println
+ }
+ /** see SVN r13821 (emir): support for <elem key={x:Option[Seq[Node]]} />,
+ * so that Options can be used for optional attributes.
+ */
+ private def test2 {
+ val x1: Option[Seq[Node]] = Some(<b>hello</b>)
+ val n1 = <elem key={x1} />;
+ println("node="+n1+", key="+n1.attribute("key"))
+
+ val x2: Option[Seq[Node]] = None
+ val n2 = <elem key={x2} />;
+ println("node="+n2+", key="+n2.attribute("key"))
}
}