summaryrefslogtreecommitdiff
path: root/test/files/jvm
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-12-19 16:52:40 +0000
committermichelou <michelou@epfl.ch>2007-12-19 16:52:40 +0000
commit8ad43107f52b278930a663874943de9eda0c8df0 (patch)
tree2e7fa80109cdd1a2ba1053aad0ff951132f71251 /test/files/jvm
parent999d30eea73cc19ff1603fc57c13d937c4fc6ce2 (diff)
downloadscala-8ad43107f52b278930a663874943de9eda0c8df0.tar.gz
scala-8ad43107f52b278930a663874943de9eda0c8df0.tar.bz2
scala-8ad43107f52b278930a663874943de9eda0c8df0.zip
removed deprecated features
Diffstat (limited to 'test/files/jvm')
-rw-r--r--test/files/jvm/xml01.check23
-rw-r--r--test/files/jvm/xml01.scala51
-rw-r--r--test/files/jvm/xml03syntax.check9
-rw-r--r--test/files/jvm/xml03syntax.scala48
-rw-r--r--test/files/jvm/xml04embed.check3
-rw-r--r--test/files/jvm/xml04embed.scala14
-rw-r--r--test/files/jvm/xmlstuff.check14
-rw-r--r--test/files/jvm/xmlstuff.scala164
8 files changed, 109 insertions, 217 deletions
diff --git a/test/files/jvm/xml01.check b/test/files/jvm/xml01.check
index cafdd6e2fc..5e82e9a729 100644
--- a/test/files/jvm/xml01.check
+++ b/test/files/jvm/xml01.check
@@ -1,31 +1,8 @@
-passed ok
equality
-passed ok
-passed ok
-passed ok
-passed ok
-passed ok
xpath \
-passed ok
-passed ok
-passed ok
-passed ok
-passed ok
-passed ok
-passed ok
-passed ok
xpath \\ DESCENDANTS
-passed ok
-passed ok
<book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book>
-passed ok
-- group nodes
<f><a></a><b></b><c></c></f>
<a></a><f><a></a><b></b><c></c></f><a></a><b></b><c></c>
-passed ok
-passed ok
-passed ok
attribute value normalization
-passed ok
-passed ok
-passed ok
diff --git a/test/files/jvm/xml01.scala b/test/files/jvm/xml01.scala
index 1f69e6969a..2804513ce0 100644
--- a/test/files/jvm/xml01.scala
+++ b/test/files/jvm/xml01.scala
@@ -1,37 +1,37 @@
-import java.io.StringReader;
-import org.xml.sax.InputSource;
-import scala.xml._;
-import scala.util.logging._;
+import java.io.StringReader
+import org.xml.sax.InputSource
-import scala.testing.UnitTest._ ;
+import scala.xml._
+import scala.util.logging._
-object Test {
- def main(args:Array[String]) = {
- val e: scala.xml.MetaData = Null; //Node.NoAttributes;
- val sc: scala.xml.NamespaceBinding = TopScope;
+import scala.testing.SUnit._
+
+object Test extends Application with Assert {
+ val e: scala.xml.MetaData = Null //Node.NoAttributes
+ val sc: scala.xml.NamespaceBinding = TopScope
val xmlFile1 = "<hello><world/></hello>";
- val isrc1 = new InputSource( new StringReader(xmlFile1) );
- val parsedxml1 = XML.load(isrc1);
- val isrc11 = new InputSource( new StringReader( xmlFile1 ) );
- val parsedxml11 = XML.load(isrc11);
+ val isrc1 = new InputSource(new StringReader(xmlFile1))
+ val parsedxml1 = XML.load(isrc1)
+ val isrc11 = new InputSource(new StringReader(xmlFile1))
+ val parsedxml11 = XML.load(isrc11)
val c = new Node {
- def label = "hello";
+ def label = "hello"
override def hashCode() =
Utility.hashCode(prefix, label, attributes.hashCode(), scope.hashCode(), child);
def child = Elem(null, "world", e, sc);
//def attributes = e;
- override def text = "";
- };
+ override def text = ""
+ }
- assertSameElements( List( 3 ), List( 3 ));
+ assertSameElements(List(3), List(3))
- Console.println("equality");
- assertEquals(c, parsedxml11);
- assertEquals(parsedxml1, parsedxml11);
- assertSameElements( List(parsedxml1), List(parsedxml11));
- assertSameElements( Iterator.fromArray(Array(parsedxml1)).toList, List(parsedxml11));
+ println("equality")
+ assertEquals(c, parsedxml11)
+ assertEquals(parsedxml1, parsedxml11)
+ assertSameElements(List(parsedxml1), List(parsedxml11))
+ assertSameElements(Iterator.fromArray(Array(parsedxml1)).toList, List(parsedxml11))
val x2 = "<book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book>";
@@ -200,7 +200,7 @@ object Test {
assertTrue(uup == "&<<>\"\"^%@$!#")
// test unicode escapes backslash u
- Console println ("attribute value normalization");
+ println("attribute value normalization")
val xmlAttrValueNorm = "<personne id='p0003' nom='&#x015e;ahingöz' />";
{
val isrcA = new InputSource( new StringReader(xmlAttrValueNorm) );
@@ -225,9 +225,4 @@ object Test {
val p = scala.xml.parsing.ConstructingParser.fromSource(scala.io.Source.fromString("<foo bar:attr='&amp;'/>"),true)
val n = p.element(new scala.xml.NamespaceBinding("bar","BAR",scala.xml.TopScope))(0)
assertFalse( n.attributes.get("BAR", n, "attr").isEmpty)
-
- }
-
-
-
}
diff --git a/test/files/jvm/xml03syntax.check b/test/files/jvm/xml03syntax.check
index 992f71d3bd..7b2eb1310c 100644
--- a/test/files/jvm/xml03syntax.check
+++ b/test/files/jvm/xml03syntax.check
@@ -1,18 +1,9 @@
-passed ok
-passed ok
-passed ok
<hello>world</hello>
-passed ok
<hello>1.5</hello>
-passed ok
<hello>5</hello>
-passed ok
<hello>true</hello>
-passed ok
<hello>5</hello>
-passed ok
<hello>27</hello>
-passed ok
<hello>1 2 3 4</hello>
1
2
diff --git a/test/files/jvm/xml03syntax.scala b/test/files/jvm/xml03syntax.scala
index e193af24d3..fd3fbfaf8f 100644
--- a/test/files/jvm/xml03syntax.scala
+++ b/test/files/jvm/xml03syntax.scala
@@ -1,21 +1,18 @@
-object Test {
+import scala.testing.SUnit._
+import scala.xml._
- import scala.testing.UnitTest._
- import scala.xml._
+object Test extends AnyRef with Assert {
- def handle[A](x:Node): A = {
- Console println x
+ private def handle[A](x: Node): A = {
+ println(x)
x.child(0).asInstanceOf[Atom[A]].data
}
- def main(args:Array[String]) = {
- import scala.xml.NodeSeq
- import NodeSeq.view
- import testing.UnitTest._
+ def main(args: Array[String]) {
val xNull = <hello>{null}</hello> // these used to be Atom(unit), changed to empty children
- assertSameElements( xNull.child, Nil )
+ assertSameElements(xNull.child, Nil)
val x0 = <hello>{}</hello> // these used to be Atom(unit), changed to empty children
val x00 = <hello>{ }</hello> // dto.
@@ -23,45 +20,44 @@ object Test {
val xa = <hello>{ "world" }</hello>
- assertSameElements( x0.child, Nil )
- assertSameElements( x00.child, Nil )
- assertEquals( handle[String](xa),"world" )
+ assertSameElements(x0.child, Nil)
+ assertSameElements(x00.child, Nil)
+ assertEquals(handle[String](xa), "world")
val xb = <hello>{ 1.5 }</hello>
- assertEquals( handle[Double](xb), 1.5 )
+ assertEquals(handle[Double](xb), 1.5)
val xc = <hello>{ 5 }</hello>
- assertEquals( handle[Int](xc), 5 )
+ assertEquals(handle[Int](xc), 5)
val xd = <hello>{ true }</hello>
- assertEquals( handle[Boolean](xd), true )
+ assertEquals(handle[Boolean](xd), true)
val xe = <hello>{ 5:short }</hello>
- assertEquals( handle[Short](xe), 5:short )
+ assertEquals(handle[Short](xe), 5:short)
val xf = <hello>{ val x = 27; x }</hello>
- assertEquals( handle[Int](xf), 27 )
+ 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 ""}
+ println(xg)
+ for (z <- xg.child) {
+ 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 ""}
+ println(xh)
+ for (z <- xh.child) {
+ println(z.toString() + {if (z.isInstanceOf[Text]) "(is text node ' ')" else ""})
}
-
-}
+ }
}
diff --git a/test/files/jvm/xml04embed.check b/test/files/jvm/xml04embed.check
index 9c9ba2b8d5..e69de29bb2 100644
--- a/test/files/jvm/xml04embed.check
+++ b/test/files/jvm/xml04embed.check
@@ -1,3 +0,0 @@
-passed ok
-passed ok
-passed ok
diff --git a/test/files/jvm/xml04embed.scala b/test/files/jvm/xml04embed.scala
index 807610a3b1..249e8ceb06 100644
--- a/test/files/jvm/xml04embed.scala
+++ b/test/files/jvm/xml04embed.scala
@@ -1,17 +1,15 @@
-object Test {
+import scala.testing.SUnit._
- import scala.testing.UnitTest._
- import scala.xml._
-
- def main(args:Array[String]) = {
+object Test extends AnyRef with Assert {
+ def main(args: Array[String]) {
val ya = <x>{{</x>
- assertEquals(ya.text, "{");
+ assertEquals(ya.text, "{")
val ua = <x>}}</x>
- assertEquals(ua.text, "}");
+ assertEquals(ua.text, "}")
val za = <x>{{}}{{}}{{}}</x>
- assertEquals(za.text, "{}{}{}");
+ assertEquals(za.text, "{}{}{}")
}
}
diff --git a/test/files/jvm/xmlstuff.check b/test/files/jvm/xmlstuff.check
index 1963498001..e1222479f7 100644
--- a/test/files/jvm/xmlstuff.check
+++ b/test/files/jvm/xmlstuff.check
@@ -1,6 +1,4 @@
NodeSeq
-passed ok
-passed ok
<result>
<title>Blabla</title>
<remarks> Hallo Welt. </remarks>
@@ -20,17 +18,5 @@ List(<book><title>Blabla</title></book>)
<phone where="mobile">+41 79 602 23 23</phone>
</result>
namespaces
-passed ok
-passed ok
-passed ok
validation - elements
-passed ok
-passed ok
-passed ok
-passed ok
validation - attributes
-passed ok
-passed ok
-passed ok
-passed ok
-passed ok
diff --git a/test/files/jvm/xmlstuff.scala b/test/files/jvm/xmlstuff.scala
index df0e129248..46faf283dc 100644
--- a/test/files/jvm/xmlstuff.scala
+++ b/test/files/jvm/xmlstuff.scala
@@ -1,24 +1,25 @@
-import java.io.StringReader;
-import org.xml.sax.InputSource;
-import scala.testing.UnitTest._ ;
-import scala.xml.{Node, NodeSeq, Elem, Text, XML};
+import java.io.StringReader
+import org.xml.sax.InputSource
-object Test {
+import scala.testing.SUnit.Assert
+import scala.xml.{Node, NodeSeq, Elem, Text, XML}
+
+object Test extends AnyRef with Assert {
/** returns true if exception was thrown */
- def catcher(att:Function1[Unit,scala.xml.MetaData]): Boolean = {
- var ex = false;
- try {
- val x = att.apply({});
- } catch {
- case scala.xml.MalformedAttributeException(msg) =>
- Console.println(msg);
- ex = true;
- }
- return ex;
+ def catcher(att: Function1[Unit, scala.xml.MetaData]): Boolean = {
+ var ex = false
+ try {
+ att.apply({})
+ } catch {
+ case scala.xml.MalformedAttributeException(msg) =>
+ println(msg)
+ ex = true
+ }
+ ex
}
- def main(args:Array[String]) = {
+ def main(args: Array[String]) {
//val e: scala.xml.MetaData = null; //Node.NoAttributes;
//val sc: scala.xml.NamespaceBinding = null;
@@ -26,7 +27,7 @@ object Test {
// ------------------------------------------ tests for class NodeSeq
/**
- Console.println("checking wellformed attributes");
+ println("checking wellformed attributes");
{
import scala.xml.{ UnprefixedAttribute, Null }
assertTrue(catcher {x:Unit => new UnprefixedAttribute("key", "<", Null)}); // < illegal
@@ -51,8 +52,7 @@ passed ok
passed ok
*/
- Console.println("NodeSeq");
- import scala.xml.Utility.view ;
+ println("NodeSeq")
val p = <foo>
<bar gt='ga' value="3"/>
@@ -64,35 +64,9 @@ passed ok
Text(x.attributes("value").toString + y.attributes("bazValue").toString+ "!")
};
val pelems_2 = new NodeSeq { val theSeq = List(Text("38!"),Text("58!")) };
- assertSameElements(pelems_1, pelems_2);
+ assertSameElements(pelems_1, pelems_2)
assertEquals(p \\ "@bazValue", Text("8"))
- // the following won't work anymore because of group nodes
- //assertSameElements(
- // p \\ "@value", new NodeSeq { val theSeq = List(Text("3"), Text("5")) }
- //);
-
-
- /* // more test cases !!!
- val test = <a name="bar"/>;
-
- Console.println(test \ "@name");
-
- val x = test.attributes.nodes;
- Console.println("trying to print");
- val it = x.elements;
- while(it.hasNext) {
- val c = it.next;
- Console.println(c);
- Console.println("c.label == @name? "+(c.label == "@name"));
- }
- */
-
- /*
- for(val c <- x) {
- Console.println(x);
- }
- */
val books =
<bks>
@@ -120,10 +94,10 @@ passed ok
</entry>
</reviews>;
- Console.println( new scala.xml.PrettyPrinter(80, 5).formatNodes (
- for( val t <- books \\ "title";
- val r <- reviews \\ "entry";
- r \ "title" == t) yield
+ println( new scala.xml.PrettyPrinter(80, 5).formatNodes (
+ for (t <- books \\ "title";
+ r <- reviews \\ "entry"
+ if r \ "title" == t) yield
<result>
{ t }
{ r \ "remarks" }
@@ -131,8 +105,8 @@ passed ok
));
// example
- Console.println(
- for( val t @ <book><title>Blabla</title></book> <- new NodeSeq { val theSeq = books.child }.toList)
+ println(
+ for (t @ <book><title>Blabla</title></book> <- new NodeSeq { val theSeq = books.child }.toList)
yield t
);
val phoneBook =
@@ -162,10 +136,10 @@ val addrBook =
</entry>
</addrbook>;
- Console.println( new scala.xml.PrettyPrinter(80, 5).formatNodes (
- for( val t <- addrBook \\ "entry";
- val r <- phoneBook \\ "entry";
- t \ "name" == r \ "name") yield
+ println( new scala.xml.PrettyPrinter(80, 5).formatNodes (
+ for (t <- addrBook \\ "entry";
+ r <- phoneBook \\ "entry"
+ if t \ "name" == r \ "name") yield
<result>
{ t.child }
{ r \ "phone" }
@@ -175,46 +149,24 @@ val addrBook =
/* namespaces */
// begin tmp
- Console.println("namespaces");
+ println("namespaces")
val cuckoo = <cuckoo xmlns="http://cuckoo.com">
<foo/>
<bar/>
</cuckoo>;
- assertEquals( cuckoo.namespace, "http://cuckoo.com");
- for( val n <- cuckoo \ "_" ) {
- //Console.println("n = "+n);
- //Console.println("n.prefix = "+n.prefix);
- //Console.println("n.scope = "+n.scope);
- assertEquals( n.namespace, "http://cuckoo.com");
+ assertEquals(cuckoo.namespace, "http://cuckoo.com")
+ for (n <- cuckoo \ "_" ) {
+ //println("n = "+n);
+ //println("n.prefix = "+n.prefix);
+ //.println("n.scope = "+n.scope);
+ assertEquals( n.namespace, "http://cuckoo.com")
}
- // end tmp
- /*
-DEPRECATED, don't support namespaces in pattern match anymore
-*/
- /*
- assertEquals( true, cuckoo match {
- case <cuckoo xmlns="http://cuckoo.com">
- <foo/>
- <bar/>
- </cuckoo> => true;
- case _ => false; });
-*/
- /*
- // begin tmp
- assertEquals( false, cuckoo match {
- case <cuckoo>
- <foo/>
- <bar/>
- </cuckoo> => true;
- case _ => false; });
- // end tmp
- */
- Console.println("validation - elements");
+ println("validation - elements")
val vtor = new scala.xml.dtd.ElementValidator();
{
- import scala.xml.dtd.ELEMENTS;
- import scala.xml.dtd.ContentModel._;
+ import scala.xml.dtd.ELEMENTS
+ import scala.xml.dtd.ContentModel._
vtor.setContentModel(
ELEMENTS(
Sequ(
@@ -222,10 +174,10 @@ DEPRECATED, don't support namespaces in pattern match anymore
Star(Letter(ElemName("baz"))) )));
}
- assertEquals( vtor( <foo><bar/><baz/><baz/></foo> ), true );
+ assertEquals(vtor( <foo><bar/><baz/><baz/></foo> ), true);
{
- import scala.xml.dtd.MIXED;
- import scala.xml.dtd.ContentModel._;
+ import scala.xml.dtd.MIXED
+ import scala.xml.dtd.ContentModel._
vtor.setContentModel(
MIXED(
@@ -234,28 +186,28 @@ DEPRECATED, don't support namespaces in pattern match anymore
Letter(ElemName("bal")))));
}
- assertEquals( vtor( <foo><bar/><baz/><baz/></foo> ), true );
- assertEquals( vtor( <foo>ab<bar/>cd<baz/>ed<baz/>gh</foo> ), true );
- assertEquals( vtor( <foo> <ugha/> <bugha/> </foo> ), false );
+ assertEquals(vtor(<foo><bar/><baz/><baz/></foo> ), true)
+ assertEquals(vtor(<foo>ab<bar/>cd<baz/>ed<baz/>gh</foo> ), true)
+ assertEquals(vtor(<foo> <ugha/> <bugha/> </foo> ), false)
- Console.println("validation - attributes");
- vtor.setContentModel(null);
- vtor.setMetaData(List());
- assertEquals( vtor( <foo bar="hello"/> ), false );
+ println("validation - attributes")
+ vtor.setContentModel(null)
+ vtor.setMetaData(List())
+ assertEquals(vtor( <foo bar="hello"/> ), false)
{
- import scala.xml.dtd._ ;
- vtor.setMetaData(List(AttrDecl("bar","CDATA",IMPLIED)));
+ import scala.xml.dtd._
+ vtor setMetaData List(AttrDecl("bar", "CDATA", IMPLIED))
}
- assertEquals( vtor( <foo href="http://foo.com" bar="hello"/> ), false );
- assertEquals( vtor( <foo bar="hello"/> ), true );
+ assertEquals(vtor(<foo href="http://foo.com" bar="hello"/>), false)
+ assertEquals(vtor(<foo bar="hello"/>), true)
{
- import scala.xml.dtd._ ;
- vtor.setMetaData(List(AttrDecl("bar","CDATA",REQUIRED)));
+ import scala.xml.dtd._
+ vtor.setMetaData(List(AttrDecl("bar","CDATA",REQUIRED)))
}
- assertEquals( vtor( <foo href="http://foo.com" /> ), false );
- assertEquals( vtor( <foo bar="http://foo.com" /> ), true );
+ assertEquals( vtor( <foo href="http://foo.com" /> ), false )
+ assertEquals( vtor( <foo bar="http://foo.com" /> ), true )
}
}