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/xml02.scala | |
parent | fe6e0afa5cd320250be567ae31da77cc19e24d44 (diff) | |
download | scala-ff389f693c06fb5db50c17b8d7d3c7a3b505420f.tar.gz scala-ff389f693c06fb5db50c17b8d7d3c7a3b505420f.tar.bz2 scala-ff389f693c06fb5db50c17b8d7d3c7a3b505420f.zip |
xml changes
Diffstat (limited to 'test/files/jvm/xml02.scala')
-rw-r--r-- | test/files/jvm/xml02.scala | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/files/jvm/xml02.scala b/test/files/jvm/xml02.scala new file mode 100644 index 0000000000..cbc9b5041b --- /dev/null +++ b/test/files/jvm/xml02.scala @@ -0,0 +1,55 @@ +object Test { +def main(args:Array[String]) = { + import scala.xml.NodeSeq + import NodeSeq.view + import testing.UnitTest._ + + + val ax = <hello foo="bar"> + <world/> + </hello> + + Console.println("attributes"); + + Console.println("one"); + assertEquals(ax \ "@foo", "bar") + Console.println("two"); + assertEquals(ax \ "@foo", xml.Text("bar")) + + val bx = <hello foo="bar&x"></hello> + + Console.println("three"); + assertEquals(bx \ "@foo", "bar&x") + Console.println("four"); + assertSameElements(bx \ "@foo", List(xml.Text("bar"),xml.EntityRef("amp"),xml.Text("x"))) + + Console.println("five"); + assertEquals(bx.toString, "<hello foo=\"bar&x\"></hello>") + + + /* patterns */ + Console.println("patterns"); + assertEquals(<hello/> match { case <hello/> => true; case _ => false; }, + true); + + + + /* + assertEquals(ax match { case x @ <hello> + <world/> + </hello> if x \ "@foo" == "bar" => true; + case _ => false; }, + true); + + assertEquals( + <hello foo="bar"> + crazy text world + </hello> match { case <hello> + crazy text world + </hello> => true; + case _ => false; }, + true); + */ +} + +} |