summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorburaq <buraq@epfl.ch>2004-06-14 13:16:00 +0000
committerburaq <buraq@epfl.ch>2004-06-14 13:16:00 +0000
commit2ce4da740250ae118e9edac8093ea0873911de82 (patch)
tree25cda7245858072c6e0cb03c5d6669839c4991db
parent3b26120ff86f1ca66e7b92c8ae9df085940e4d39 (diff)
downloadscala-2ce4da740250ae118e9edac8093ea0873911de82.tar.gz
scala-2ce4da740250ae118e9edac8093ea0873911de82.tar.bz2
scala-2ce4da740250ae118e9edac8093ea0873911de82.zip
new example of for comprehensions
-rw-r--r--test/files/jvm/xmlstuff.check7
-rw-r--r--test/files/jvm/xmlstuff.scala38
2 files changed, 45 insertions, 0 deletions
diff --git a/test/files/jvm/xmlstuff.check b/test/files/jvm/xmlstuff.check
index f8bab77aac..b348451a28 100644
--- a/test/files/jvm/xmlstuff.check
+++ b/test/files/jvm/xmlstuff.check
@@ -31,3 +31,10 @@ passed ok
<remarks>rem 2</remarks>
</result>
List(<book><title>Blabla</title></book>)
+<result>
+ <name>John</name>
+ <street>Elm Street</street>
+ <city>Dolphin City</city>
+ <phone where="work">+41 21 693 68 67</phone>
+ <phone where="mobile">+41 79 602 23 23</phone>
+</result>
diff --git a/test/files/jvm/xmlstuff.scala b/test/files/jvm/xmlstuff.scala
index 09bfcd084b..bf08aa348e 100644
--- a/test/files/jvm/xmlstuff.scala
+++ b/test/files/jvm/xmlstuff.scala
@@ -237,4 +237,42 @@ object Test with Application {
yield t
);
+val phoneBook =
+ <phonebook>
+ <descr>
+ This is the <b>phonebook</b> of the
+ <a href="http://acme.org">ACME</a> corporation.
+ </descr>
+ <entry>
+ <name>John</name>
+ <phone where="work"> +41 21 693 68 67</phone>
+ <phone where="mobile">+41 79 602 23 23</phone>
+ </entry>
+ </phonebook>;
+
+
+val addrBook =
+ <addrbook>
+ <descr>
+ This is the <b>addressbook</b> of the
+ <a href="http://acme.org">ACME</a> corporation.
+ </descr>
+ <entry>
+ <name>John</name>
+ <street> Elm Street</street>
+ <city>Dolphin City</city>
+ </entry>
+ </addrbook>;
+
+ Console.println( new scala.xml.PrettyPrinter(80, 5).format (
+ for( val t <- addrBook \\ "entry";
+ val r <- phoneBook \\ "entry";
+ t \ "name" == r \ "name") yield
+ <result>
+ { t.child }
+ { r \ "phone" }
+ </result>
+ ));
+
+
}