diff options
author | Burak Emir <emir@epfl.ch> | 2006-09-07 16:54:57 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2006-09-07 16:54:57 +0000 |
commit | ff389f693c06fb5db50c17b8d7d3c7a3b505420f (patch) | |
tree | 98a2a1cde5b5ca735f890fed87e94647632fd07a /test/files/jvm/xml03syntax.scala | |
parent | fe6e0afa5cd320250be567ae31da77cc19e24d44 (diff) | |
download | scala-ff389f693c06fb5db50c17b8d7d3c7a3b505420f.tar.gz scala-ff389f693c06fb5db50c17b8d7d3c7a3b505420f.tar.bz2 scala-ff389f693c06fb5db50c17b8d7d3c7a3b505420f.zip |
xml changes
Diffstat (limited to 'test/files/jvm/xml03syntax.scala')
-rw-r--r-- | test/files/jvm/xml03syntax.scala | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/files/jvm/xml03syntax.scala b/test/files/jvm/xml03syntax.scala new file mode 100644 index 0000000000..7ae6473302 --- /dev/null +++ b/test/files/jvm/xml03syntax.scala @@ -0,0 +1,62 @@ +object Test { + + import scala.testing.UnitTest._ + import scala.xml._ + + def handle[A](x:Node): A = { + Console println x + x.child(0).asInstanceOf[Atom[A]].data + } + + def main(args:Array[String]) = { + import scala.xml.NodeSeq + import NodeSeq.view + import testing.UnitTest._ + + val x0 = <hello>{}</hello> + val x00 = <hello>{ }</hello> + val xa = <hello>{ "world" }</hello> + + + assertEquals( handle[Unit](x0), {} ) + assertEquals( handle[Unit](x00), {} ) + assertEquals( handle[String](xa),"world" ) + + val xb = <hello>{ 1.5 }</hello> + + assertEquals( handle[Double](xb), 1.5 ) + + val xc = <hello>{ 5 }</hello> + + assertEquals( handle[Int](xc), 5 ) + + val xd = <hello>{ true }</hello> + + assertEquals( handle[Boolean](xd), true ) + + val xe = <hello>{ 5:short }</hello> + + assertEquals( handle[Short](xe), 5:short ) + + val xf = <hello>{ val x = 27; x }</hello> + + assertEquals( handle[Int](xf), 27 ) + + val xg = <hello>{ List(1,2,3,4) }</hello> + + Console println xg + for(val z <- xg.child) { + Console 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> + + Console println xh + for(val z <- xh.child) { + Console println z.toString() + {if (z.isInstanceOf[Text]) "(is text node ' ')" else ""} + } + + +} + +} |