summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorburaq <buraq@epfl.ch>2004-02-09 09:05:30 +0000
committerburaq <buraq@epfl.ch>2004-02-09 09:05:30 +0000
commit39a7f8363f5540dd185364e9eca20498fce62875 (patch)
tree52029a09c50ab11040f31620c522d5afb744f56f /test/files
parentf9d951b4e6eee55f3f9ac7026dfe564366e03213 (diff)
downloadscala-39a7f8363f5540dd185364e9eca20498fce62875.tar.gz
scala-39a7f8363f5540dd185364e9eca20498fce62875.tar.bz2
scala-39a7f8363f5540dd185364e9eca20498fce62875.zip
things to test the xml library
Diffstat (limited to 'test/files')
-rw-r--r--test/files/run/xmlstuff.check23
-rw-r--r--test/files/run/xmlstuff.scala42
2 files changed, 65 insertions, 0 deletions
diff --git a/test/files/run/xmlstuff.check b/test/files/run/xmlstuff.check
new file mode 100644
index 0000000000..af85d96257
--- /dev/null
+++ b/test/files/run/xmlstuff.check
@@ -0,0 +1,23 @@
+NodeList('world)
+NodeList('world)
+
+parsedxml2/'_
+NodeList('book('author(Text(Peter Buneman)),'author(Text(Dan Suciu)),'title(Text(Data on ze web))),'book('author(Text(John Mitchell)),'title(Text(Foundations of Programming Languages))))
+
+parsedxml2/'author
+NodeList()
+
+parsedxml2/'book:
+NodeList('book('author(Text(Peter Buneman)),'author(Text(Dan Suciu)),'title(Text(Data on ze web))),'book('author(Text(John Mitchell)),'title(Text(Foundations of Programming Languages))))
+
+parsedxml2/'_/'_
+NodeList('author(Text(Peter Buneman)),'author(Text(Dan Suciu)),'title(Text(Data on ze web)),'author(Text(John Mitchell)),'title(Text(Foundations of Programming Languages)))
+
+parsedxml2/'_/'author
+NodeList('author(Text(Peter Buneman)),'author(Text(Dan Suciu)),'author(Text(John Mitchell)))
+
+parsedxml2/'_/'_/'author
+NodeList()
+
+parsedxml2/#'author
+NodeList('author(Text(Dan Suciu)),'author(Text(Peter Buneman)),'author(Text(John Mitchell)))
diff --git a/test/files/run/xmlstuff.scala b/test/files/run/xmlstuff.scala
new file mode 100644
index 0000000000..916798e112
--- /dev/null
+++ b/test/files/run/xmlstuff.scala
@@ -0,0 +1,42 @@
+import java.io.StringReader;
+import org.xml.sax.InputSource;
+import scala.xml.nobinding.XML;
+import scala.testing.UnitTest.assertEquals ;
+
+object Test with Application {
+ val xmlFile1 = "<hello><world/></hello>";
+ val isrc1 = new InputSource( new StringReader( xmlFile1 ) );
+ val parsedxml1 = XML.load( isrc1 );
+
+ val xmlFile2 = "<bib><book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book><book><author>John Mitchell</author><title>Foundations of Programming Languages</title></book></bib>";
+ val isrc2 = new InputSource( new StringReader( xmlFile2 ) );
+ val parsedxml2 = XML.load( isrc2 );
+
+ // xmlFile2/book -> book,book
+
+ Console.println( parsedxml1/'world ); /* List('world()) */
+ Console.println( parsedxml1/'_ ); /* List('world()) */
+
+ Console.println( "\nparsedxml2/'_"); /* List(book,book) */
+ Console.println( parsedxml2/'_); /* List(book,book) */
+
+ Console.println( "\nparsedxml2/'author"); /* List() */
+ Console.println( parsedxml2/'author); /* List() */
+
+ Console.println( "\nparsedxml2/'book:");
+ Console.println( parsedxml2/'book); /* List(book,book) */
+
+ Console.println( "\nparsedxml2/'_/'_");
+ Console.println( parsedxml2/'_/'_ );
+ Console.println( "\nparsedxml2/'_/'author");
+ Console.println( parsedxml2/'_/'author );
+ Console.println( "\nparsedxml2/'_/'_/'author");
+ Console.println( parsedxml2/'_/'_/'author );
+ /* List('author(Text("Peter Buneman")),
+ 'author(Text("Dan Suciu")),
+ 'author(Text("John Mitchell")))); */
+
+ Console.println( "\nparsedxml2/#'author");
+ Console.println( parsedxml2/#'author );
+
+}