diff options
author | Paul Phillips <paulp@improving.org> | 2009-05-09 03:53:41 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-05-09 03:53:41 +0000 |
commit | 2ea3b94ee2519e01a3e1658909afeb33e7e9ebe2 (patch) | |
tree | 9bb2044c595fe260c352a00cf98bb2ecece50437 /test/files | |
parent | f7ab13b08e085c3bf94d857fc9648ee724e4cb08 (diff) | |
download | scala-2ea3b94ee2519e01a3e1658909afeb33e7e9ebe2.tar.gz scala-2ea3b94ee2519e01a3e1658909afeb33e7e9ebe2.tar.bz2 scala-2ea3b94ee2519e01a3e1658909afeb33e7e9ebe2.zip |
Organized disabled directory so it works with p...
Organized disabled directory so it works with partest. You can run
./partest --srcpath disabled to run the tests in that location. Fixed a
few tests in disabled and pending and moved to files.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/jvm/xml01.check | 8 | ||||
-rw-r--r-- | test/files/jvm/xml01.scala | 228 | ||||
-rw-r--r-- | test/files/run/bitsets.check | 33 | ||||
-rw-r--r-- | test/files/run/bitsets.scala | 78 | ||||
-rw-r--r-- | test/files/run/bug1079.check | 1 | ||||
-rw-r--r-- | test/files/run/bug1079.scala | 3 |
6 files changed, 351 insertions, 0 deletions
diff --git a/test/files/jvm/xml01.check b/test/files/jvm/xml01.check new file mode 100644 index 0000000000..d78e6df410 --- /dev/null +++ b/test/files/jvm/xml01.check @@ -0,0 +1,8 @@ +equality +xpath \ +xpath \\ DESCENDANTS +<book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book> +-- group nodes +<f><a/><b/><c/></f> +<a/><f><a/><b/><c/></f><a/><b/><c/> +attribute value normalization diff --git a/test/files/jvm/xml01.scala b/test/files/jvm/xml01.scala new file mode 100644 index 0000000000..7246c94c5b --- /dev/null +++ b/test/files/jvm/xml01.scala @@ -0,0 +1,228 @@ +import java.io.StringReader +import org.xml.sax.InputSource + +import scala.testing.SUnit._ +import scala.util.logging._ +import scala.xml._ + + +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 c = new Node { + 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 = "" + } + + assertSameElements(List(3), List(3)) + + println("equality") + assertEquals(c, parsedxml11) + assertEquals(parsedxml1, parsedxml11) + assertSameElements(List(parsedxml1), List(parsedxml11)) + assertSameElements(Array(parsedxml1).toList, List(parsedxml11)) + + val x2 = "<book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book>"; + + val i = new InputSource(new StringReader(x2)) + val x2p = XML.load(i) + + assertEquals(x2p, Elem(null, "book" , e, sc, + Elem(null, "author", e, sc,Text("Peter Buneman")), + Elem(null, "author", e, sc,Text("Dan Suciu")), + Elem(null, "title" , e, sc,Text("Data on ze web")))); + + 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 + println("xpath \\") + + + assertSameElements(parsedxml1 \ "_" , List(Elem(null,"world", e, sc))) + + assertSameElements(parsedxml1 \ "world", List(Elem(null,"world", e, sc))) + +/* + Console.println( parsedxml2 \ "_" ); + Console.println( (parsedxml2 \ "_" ).elements); + for( val i <- (parsedxml2 \ "_" ).elements) { + Console.println( i ); + }; + */ + + assertSameElements( + parsedxml2 \ "_" , + + List( + Elem(null,"book", e, sc, + Elem(null,"author", e, sc, Text("Peter Buneman")), + Elem(null,"author", e, sc, Text("Dan Suciu")), + Elem(null,"title" , e, sc, Text("Data on ze web"))), + Elem(null,"book",e,sc, + Elem(null,"author",e,sc,Text("John Mitchell")), + Elem(null,"title",e,sc,Text("Foundations of Programming Languages")))) + ); + assertEquals( (parsedxml2 \ "author").length, 0 ); + + assertSameElements( + parsedxml2 \ "book", + + List( + Elem(null,"book",e,sc, + Elem(null,"author", e, sc, Text("Peter Buneman")), + Elem(null,"author", e, sc, Text("Dan Suciu")), + Elem(null,"title" , e, sc, Text("Data on ze web"))), + Elem(null,"book",e,sc, + Elem(null,"author", e, sc, Text("John Mitchell")), + Elem(null,"title" , e, sc, Text("Foundations of Programming Languages"))) + ) + ); + + assertSameElements( + + parsedxml2 \ "_" \ "_", + + List( + Elem(null,"author", e, sc, Text("Peter Buneman")), + Elem(null,"author", e, sc, Text("Dan Suciu")), + Elem(null,"title" , e, sc, Text("Data on ze web")), + Elem(null,"author", e, sc, Text("John Mitchell")), + Elem(null,"title" , e, sc, Text("Foundations of Programming Languages")) + ) + ); + + assertSameElements( + + parsedxml2 \ "_" \ "author", + + List( + Elem(null,"author", e, sc, Text("Peter Buneman")), + Elem(null,"author", e, sc, Text("Dan Suciu")), + Elem(null,"author", e, sc, Text("John Mitchell")) + ) + + ); + + assertSameElements( (parsedxml2 \ "_" \ "_" \ "author"), List() ); + + Console.println("xpath \\\\ DESCENDANTS"); + + assertSameElements( + + parsedxml2 \\ "author", + + List( + Elem(null,"author", e, sc, Text("Peter Buneman")), + Elem(null,"author", e, sc, Text("Dan Suciu")), + Elem(null,"author", e, sc, Text("John Mitchell")) + ) + + ); + + + assertSameElements( + + parsedxml2 \\ "title", + + List( + Elem(null,"title", e, sc, Text("Data on ze web")), + Elem(null,"title", e, sc, Text("Foundations of Programming Languages"))) + ); + + + println( + (parsedxml2 \\ "book" ){ n:Node => n \ "title" == "Data on ze web" } + ); + + assertEquals( + + (new NodeSeq { val theSeq = List( parsedxml2 ) }) \\ "_", + + List( + Elem(null,"bib",e,sc, + Elem(null,"book",e,sc, + Elem(null, "author", e, sc, Text("Peter Buneman")), + Elem(null, "author", e, sc, Text("Dan Suciu")), + Elem(null, "title" , e, sc, Text("Data on ze web"))), + Elem(null,"book",e,sc, + Elem(null,"author",e,sc,Text("John Mitchell")), + Elem(null,"title",e,sc,Text("Foundations of Programming Languages")))), + Elem(null,"book",e,sc, + Elem(null,"author",e,sc,Text("Peter Buneman")), + Elem(null,"author",e,sc,Text("Dan Suciu")), + Elem(null,"title",e,sc,Text("Data on ze web"))), + Elem(null,"author",e,sc,Text("Peter Buneman")), + //Text("Peter Buneman"), + Elem(null,"author",e,sc,Text("Dan Suciu")), + //Text("Dan Suciu"), + Elem(null,"title",e,sc,Text("Data on ze web")), + //Text("Data on ze web"), + Elem(null,"book",e,sc, + Elem(null,"author",e,sc,Text("John Mitchell")), + Elem(null,"title",e,sc,Text("Foundations of Programming Languages"))), + Elem(null,"author",e,sc,Text("John Mitchell")), + //Text("John Mitchell"), + Elem(null,"title",e,sc,Text("Foundations of Programming Languages")) + //Text("Foundations of Programming Languages") + ) + ); + + // test group node + Console println "-- group nodes" + val zx1: Node = Group { <a/><b/><c/> } + val zy1 = <f>{zx1}</f> + Console println zy1.toString() + + val zx2: Node = Group { List(<a/>,zy1,zx1) } + Console println zx2.toString() + + val zz1 = <xml:group><a/><b/><c/></xml:group> + + assertTrue(zx1 == zz1) + assertTrue(zz1.length == 3) + + // unparsed + + val uup = <xml:unparsed>&<<>""^%@$!#</xml:unparsed> + assertTrue(uup == "&<<>\"\"^%@$!#") + // test unicode escapes backslash u + + println("attribute value normalization") + val xmlAttrValueNorm = "<personne id='p0003' nom='Şahingöz' />"; + { + val isrcA = new InputSource( new StringReader(xmlAttrValueNorm) ); + val parsedxmlA = XML.load(isrcA); + val c = (parsedxmlA \ "@nom").text.charAt(0); + //Console.println("char '"+c+"' \u015e"); + assertTrue(c == '\u015e'); + } + // buraq: if the following test fails with 'character x not allowed', it is + // related to the mutable variable in a closures in MarkupParser.parsecharref + { + val isr = scala.io.Source.fromString(xmlAttrValueNorm); + val pxmlB = scala.xml.parsing.ConstructingParser.fromSource(isr,false); + val parsedxmlB = pxmlB.element(TopScope); + val c = (parsedxmlB \ "@nom").text.charAt(0); + //Console.println("char '"+c+"' \u015e"); + assertTrue(c == '\u015e'); + } + + // #60 test by round trip + + val p = scala.xml.parsing.ConstructingParser.fromSource(scala.io.Source.fromString("<foo bar:attr='&'/>"),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/run/bitsets.check b/test/files/run/bitsets.check new file mode 100644 index 0000000000..388535dcf5 --- /dev/null +++ b/test/files/run/bitsets.check @@ -0,0 +1,33 @@ +ms0 = Set(2) +ms1 = Set(2) +ms2 = Set(2) +mb0 = false +mb1 = true +mb2 = false +xs0 = List(2) +xs1 = List(2) +xs2 = List(2) +ma0 = List(2) +ma1 = List(2) +ma2 = List(2) +mi0 = Set(2) +mi1 = Set(2) +mi2 = Set(2) + +is0 = Set() +is1 = Set() +is2 = Set(2) +is3 = Set() +ib0 = false +ib1 = false +ib2 = true +ib3 = false +ys0 = List() +ys1 = List() +ys2 = List(2) +ys3 = List() +ia0 = List() +ia1 = List() +ia2 = List(2) +ia3 = List() + diff --git a/test/files/run/bitsets.scala b/test/files/run/bitsets.scala new file mode 100644 index 0000000000..abe3d18501 --- /dev/null +++ b/test/files/run/bitsets.scala @@ -0,0 +1,78 @@ +//############################################################################ +// Bitsets +//############################################################################ +// $Id$ + +//############################################################################ + +object TestMutable { + import scala.collection.mutable.BitSet + + val ms0 = new BitSet + val ms1 = new BitSet(8) + val ms2 = new BitSet(0) + ms0 += 2 + ms1 ++= List(1, 2) + ms1 -= 1 + ms1 --= List(1) + ms2(2) = true + ms2(3) = false + + Console.println("ms0 = " + ms0) + Console.println("ms1 = " + ms1) + Console.println("ms2 = " + ms2) + + Console.println("mb0 = " + ms0.contains(-1)) + Console.println("mb1 = " + ms1.contains(2)) + Console.println("mb2 = " + ms2.contains(3)) + + Console.println("xs0 = " + ms0.elements.toList) + Console.println("xs1 = " + ms1.elements.toList) + Console.println("xs2 = " + ms2.elements.toList) + + Console.println("ma0 = " + ms0.toList) + Console.println("ma1 = " + ms1.toList) + Console.println("ma2 = " + ms2.toList) + + Console.println("mi0 = " + ms0.toImmutable) + Console.println("mi1 = " + ms1.toImmutable) + Console.println("mi2 = " + ms2.toImmutable) + Console.println +} + +object TestImmutable { + import scala.collection.immutable.BitSet + + val is0 = BitSet() + val is1 = BitSet.fromArray(Array()) + val is2 = BitSet.fromArray(Array(4)) + val is3 = BitSet.empty + + Console.println("is0 = " + is0) + Console.println("is1 = " + is1) + Console.println("is2 = " + is2) + Console.println("is3 = " + is3) + + Console.println("ib0 = " + is0.contains(-1)) + Console.println("ib1 = " + is1.contains(0)) + Console.println("ib2 = " + is2.contains(2)) + Console.println("ib3 = " + is3.contains(2)) + + Console.println("ys0 = " + is0.elements.toList) + Console.println("ys1 = " + is1.elements.toList) + Console.println("ys2 = " + is2.elements.toList) + Console.println("ys3 = " + is3.elements.toList) + + Console.println("ia0 = " + is0.toList) + Console.println("ia1 = " + is1.toList) + Console.println("ia2 = " + is2.toList) + Console.println("ia3 = " + is3.toList) + Console.println +} + +object Test extends Application { + TestMutable + TestImmutable +} + +//############################################################################ diff --git a/test/files/run/bug1079.check b/test/files/run/bug1079.check new file mode 100644 index 0000000000..c508d5366f --- /dev/null +++ b/test/files/run/bug1079.check @@ -0,0 +1 @@ +false diff --git a/test/files/run/bug1079.scala b/test/files/run/bug1079.scala new file mode 100644 index 0000000000..5e7f2fc42b --- /dev/null +++ b/test/files/run/bug1079.scala @@ -0,0 +1,3 @@ +object Test extends Application { + println(<t user:tag=""/> == <t user:tag="X"/>) +}
\ No newline at end of file |