summaryrefslogtreecommitdiff
path: root/test/files/jvm
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2007-02-05 14:38:06 +0000
committermihaylov <mihaylov@epfl.ch>2007-02-05 14:38:06 +0000
commitfd8dff6dd8148e83d24f3be3f8b22b7f4b253760 (patch)
tree0d3e00aabbca154e09f89dd800c5f37cdd680e14 /test/files/jvm
parent611f4541686a87ba6d871a95951d476a288816a4 (diff)
downloadscala-fd8dff6dd8148e83d24f3be3f8b22b7f4b253760.tar.gz
scala-fd8dff6dd8148e83d24f3be3f8b22b7f4b253760.tar.bz2
scala-fd8dff6dd8148e83d24f3be3f8b22b7f4b253760.zip
MSIL-firendly test suit
Diffstat (limited to 'test/files/jvm')
-rw-r--r--test/files/jvm/unittest_io.scala30
-rw-r--r--test/files/jvm/unittest_xml.scala61
2 files changed, 91 insertions, 0 deletions
diff --git a/test/files/jvm/unittest_io.scala b/test/files/jvm/unittest_io.scala
new file mode 100644
index 0000000000..59b82ff57e
--- /dev/null
+++ b/test/files/jvm/unittest_io.scala
@@ -0,0 +1,30 @@
+object Test {
+
+ import scala.testing.SUnit._
+ import scala.io.Source
+
+ class ReadlinesTest extends TestCase("scala.io.Source method getLines") {
+
+ val src = Source.fromString("""
+This is a file
+it is split on several lines.
+
+isn't it?
+""")
+ assertEquals("wrong number of lines",src.getLines.toList.length,5) // five new lines in there
+ //for(val line <- src.getLines) {
+ // Console.print(line)
+ //}
+ }
+ def main(args:Array[String]) = {
+ val ts = new TestSuite(
+ new ReadlinesTest
+ )
+ val tr = new TestResult()
+ ts.run(tr)
+ for(val failure <- tr.failures) {
+ Console.println(failure)
+ }
+ }
+
+}
diff --git a/test/files/jvm/unittest_xml.scala b/test/files/jvm/unittest_xml.scala
new file mode 100644
index 0000000000..99284f144e
--- /dev/null
+++ b/test/files/jvm/unittest_xml.scala
@@ -0,0 +1,61 @@
+
+object Test {
+
+ import scala.testing.SUnit._
+ import scala.xml.{MetaData, Null, Parsing, PrefixedAttribute, UnprefixedAttribute }
+
+ class ParsingTest extends TestCase("scala.xml.Parsing") with Assert {
+ override def runTest = {
+ assertTrue(Parsing.isNameStart('b'))
+ }
+ }
+ class MetaDataTest extends TestCase("scala.xml.MetaData") with Assert {
+
+ import scala.xml.{TopScope, NamespaceBinding, Atom, Text }
+
+ override def runTest = {
+
+ var x: MetaData = Null
+ var s: NamespaceBinding = TopScope
+
+ // testing method def apply(uri:String, scp:NamespaceBinding, k:String): Seq[Node]
+ // def apply(k:String): Seq[Node]
+
+ assertEquals("absent element (prefixed) 1", null, x("za://foo.com", s, "bar" ))
+ assertEquals("absent element (unprefix) 1", null, x("bar"))
+
+ assertEquals("absent element (prefixed) 2", None, x.get("za://foo.com", s, "bar" ))
+ assertEquals("absent element (unprefix) 2", None, x.get("bar"))
+
+ x = new PrefixedAttribute("zo","bar", new Atom(42), x)
+ s = new NamespaceBinding("zo","za://foo.com",s)
+
+ assertEquals("present element (prefixed) 3", new Atom(42), x("za://foo.com", s, "bar" ))
+ assertEquals("present element (unprefix) 3", null, x("bar"))
+
+ assertEquals("present element (prefixed) 4", Some(new Atom(42)), x.get("za://foo.com", s, "bar" ))
+ assertEquals("present element (unprefix) 4", None, x.get("bar"))
+
+ x = new UnprefixedAttribute("bar","meaning", x)
+
+ assertEquals("present element (prefixed) 5", null, x(null, s, "bar" ))
+ assertEquals("present element (unprefix) 5", Text("meaning"), x("bar"))
+
+ assertEquals("present element (prefixed) 6", None, x.get(null, s, "bar" ))
+ assertEquals("present element (unprefix) 6", Some(Text("meaning")), x.get("bar"))
+
+ }
+ }
+
+ def main(args:Array[String]) = {
+ val ts = new TestSuite(
+ new ParsingTest,
+ new MetaDataTest //,
+ )
+ val tr = new TestResult()
+ ts.run(tr)
+ for(val failure <- tr.failures) {
+ Console.println(failure)
+ }
+ }
+}