summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorAntonio Cunei <antonio.cunei@epfl.ch>2009-11-06 19:06:35 +0000
committerAntonio Cunei <antonio.cunei@epfl.ch>2009-11-06 19:06:35 +0000
commit5d25e9334d6dfd492cb5312a43b3d3f36042401a (patch)
treef3740e52f6439d41a0969880aa2a7abd92115141 /test/files
parentd42f62bbd76df85ed57162118a8c720f50bbd5c5 (diff)
downloadscala-5d25e9334d6dfd492cb5312a43b3d3f36042401a.tar.gz
scala-5d25e9334d6dfd492cb5312a43b3d3f36042401a.tar.bz2
scala-5d25e9334d6dfd492cb5312a43b3d3f36042401a.zip
Moved disabled tests back into their original p...
Moved disabled tests back into their original place. Expect 7 tests to fail.
Diffstat (limited to 'test/files')
-rw-r--r--test/files/jvm/reactor-exceptionOnSend.check2
-rw-r--r--test/files/jvm/reactor-exceptionOnSend.scala44
-rw-r--r--test/files/jvm/serialization.check186
-rw-r--r--test/files/jvm/serialization.scala401
-rw-r--r--test/files/pos/t0851.scala (renamed from test/files/pos/t0851.scala.disabled)0
-rw-r--r--test/files/pos/t0872.scala (renamed from test/files/pos/t0872.scala.disabled)2
-rw-r--r--test/files/run/collection-stacks.check14
-rw-r--r--test/files/run/collection-stacks.scala38
-rw-r--r--test/files/run/deeps.check83
-rw-r--r--test/files/run/deeps.scala111
-rw-r--r--test/files/run/t0485.check32
-rw-r--r--test/files/run/t0485.scala54
-rw-r--r--test/files/run/unittest_collection.scala103
-rw-r--r--test/files/script/fact.args1
-rwxr-xr-xtest/files/script/fact.bat17
-rw-r--r--test/files/script/fact.check1
-rw-r--r--test/files/script/fact.scala30
17 files changed, 1118 insertions, 1 deletions
diff --git a/test/files/jvm/reactor-exceptionOnSend.check b/test/files/jvm/reactor-exceptionOnSend.check
new file mode 100644
index 0000000000..45d62e26a7
--- /dev/null
+++ b/test/files/jvm/reactor-exceptionOnSend.check
@@ -0,0 +1,2 @@
+receiver handles exception
+process
diff --git a/test/files/jvm/reactor-exceptionOnSend.scala b/test/files/jvm/reactor-exceptionOnSend.scala
new file mode 100644
index 0000000000..3684943b9b
--- /dev/null
+++ b/test/files/jvm/reactor-exceptionOnSend.scala
@@ -0,0 +1,44 @@
+import scala.actors.Reactor
+import scala.actors.Actor._
+
+case class MyException(text: String) extends Exception(text)
+
+object A extends Reactor {
+ override def exceptionHandler = {
+ case MyException(text) =>
+ println("receiver handles exception")
+ }
+
+ def guard(): Boolean =
+ if (state == 0) {
+ state = 1
+ throw MyException("illegal state")
+ } else
+ true
+
+ var state = 0
+
+ def act() {
+ loop {
+ react {
+ case 'hello if guard() =>
+ println("process")
+ exit()
+ }
+ }
+ }
+}
+
+object B extends Reactor {
+ def act() {
+ A.start()
+ A ! 'hello
+ A ! 'hello
+ }
+}
+
+object Test {
+ def main(args: Array[String]) {
+ B.start()
+ }
+}
diff --git a/test/files/jvm/serialization.check b/test/files/jvm/serialization.check
new file mode 100644
index 0000000000..7125d4bfab
--- /dev/null
+++ b/test/files/jvm/serialization.check
@@ -0,0 +1,186 @@
+x0 = List(1, 2, 3)
+y0 = List(1, 2, 3)
+x0 eq y0: false - y0 eq x0: false
+x0 equals y0: true - y0 equals x0: true
+
+x1 = List()
+y1 = List()
+x1 eq y1: true - y1 eq x1: true
+
+x2 = None
+y2 = None
+x2 eq y2: true - y2 eq x2: true
+
+x3 = Array[1,2,3]
+y3 = Array[1,2,3]
+arrayEquals(x3, y3): true
+
+x4 = <na>
+y4 = <na>
+x4(2): 4 - y4(2): 4
+
+x5 = 'hello
+y5 = 'hello
+x5 eq y5: true - y5 eq x5: true
+x5 equals y5: true - y5 equals x5: true
+
+x6 = (BannerLimit,12345)
+y6 = (BannerLimit,12345)
+x6 eq y6: false - y6 eq x6: false
+x6 equals y6: true - y6 equals x6: true
+
+x7 = {scala.BigDecimal$RoundingMode(0), scala.BigDecimal$RoundingMode(1), scala.BigDecimal$RoundingMode(2), scala.BigDecimal$RoundingMode(3), scala.BigDecimal$RoundingMode(4), scala.BigDecimal$RoundingMode(5), scala.BigDecimal$RoundingMode(6), scala.BigDecimal$RoundingMode(7)}
+y7 = {scala.BigDecimal$RoundingMode(0), scala.BigDecimal$RoundingMode(1), scala.BigDecimal$RoundingMode(2), scala.BigDecimal$RoundingMode(3), scala.BigDecimal$RoundingMode(4), scala.BigDecimal$RoundingMode(5), scala.BigDecimal$RoundingMode(6), scala.BigDecimal$RoundingMode(7)}
+x7 eq y7: true - y7 eq x7: true
+x7 equals y7: true - y7 equals x7: true
+
+x8 = {Test1_scala$WeekDay(0), Test1_scala$WeekDay(1), Test1_scala$WeekDay(2), Test1_scala$WeekDay(3), Test1_scala$WeekDay(4), Test1_scala$WeekDay(5), Test1_scala$WeekDay(6)}
+y8 = {Test1_scala$WeekDay(0), Test1_scala$WeekDay(1), Test1_scala$WeekDay(2), Test1_scala$WeekDay(3), Test1_scala$WeekDay(4), Test1_scala$WeekDay(5), Test1_scala$WeekDay(6)}
+x8 eq y8: true - y8 eq x8: true
+x8 equals y8: true - y8 equals x8: true
+
+x9 = scala.BigDecimal$RoundingMode(0)
+y9 = scala.BigDecimal$RoundingMode(0)
+x9 eq y9: true - y9 eq x9: true
+x9 equals y9: true - y9 equals x9: true
+
+x10 = Test1_scala$WeekDay(0)
+y10 = Test1_scala$WeekDay(0)
+x10 eq y10: true - y10 eq x10: true
+x10 equals y10: true - y10 equals x10: true
+
+x9 eq x10: false - x10 eq x9: false
+x9 equals x10: false - x10 equals x9: false
+x9 eq y10: false - y10 eq x9: false
+x9 equals y10: false - y10 equals x9: false
+
+x = List((buffers,20), (layers,2), (title,3))
+y = List((buffers,20), (layers,2), (title,3))
+x equals y: true - y equals x: true
+
+x = Map(buffers -> 20, layers -> 2, title -> 3)
+y = Map(buffers -> 20, layers -> 2, title -> 3)
+x equals y: true - y equals x: true
+
+x = Set(2, 3)
+y = Set(2, 3)
+x equals y: true - y equals x: true
+
+x = Set(5, 3)
+y = Set(5, 3)
+x equals y: true - y equals x: true
+
+x = Queue(a, b, c)
+y = Queue(a, b, c)
+x equals y: true - y equals x: true
+
+x = Stack(a, b, c)
+y = Stack(a, b, c)
+x equals y: true - y equals x: true
+
+x = Map(42 -> FortyTwo)
+y = Map(42 -> FortyTwo)
+x equals y: true - y equals x: true
+
+x = Set(0, 2)
+y = Set(0, 2)
+x equals y: true - y equals x: true
+
+x = ArrayBuffer(one, two)
+y = ArrayBuffer(one, two)
+x equals y: true - y equals x: true
+
+x = Map(title -> 3, buffers -> 20, layers -> 2)
+y = Map(title -> 3, buffers -> 20, layers -> 2)
+x equals y: true - y equals x: true
+
+x = Set(0, 8, 9)
+y = Set(0, 8, 9)
+x equals y: true - y equals x: true
+
+x = Set(layers, buffers, title)
+y = Set(layers, buffers, title)
+x equals y: true - y equals x: true
+
+x = LinkedList(2, 3)
+y = LinkedList(2, 3)
+x equals y: true - y equals x: true
+
+x = Queue(20, 2, 3)
+y = Queue(20, 2, 3)
+x equals y: true - y equals x: true
+
+x = Stack(20, 2, 3)
+y = Stack(20, 2, 3)
+x equals y: true - y equals x: true
+
+x = ListBuffer(white, black)
+y = ListBuffer(white, black)
+x equals y: true - y equals x: true
+
+x = <html><title>title</title><body></body></html>
+y = <html><title>title</title><body></body></html>
+x equals y: true - y equals x: true
+
+x = <html>
+ <body>
+ <table cellpadding="2" cellspacing="0">
+ <tr>
+ <th>Last Name</th>
+ <th>First Name</th>
+ </tr>
+ <tr>
+ <td> Tom </td>
+ <td> 20 </td>
+ </tr><tr>
+ <td> Bob </td>
+ <td> 22 </td>
+ </tr><tr>
+ <td> James </td>
+ <td> 19 </td>
+ </tr>
+ </table>
+ </body>
+ </html>
+y = <html>
+ <body>
+ <table cellpadding="2" cellspacing="0">
+ <tr>
+ <th>Last Name</th>
+ <th>First Name</th>
+ </tr>
+ <tr>
+ <td> Tom </td>
+ <td> 20 </td>
+ </tr><tr>
+ <td> Bob </td>
+ <td> 22 </td>
+ </tr><tr>
+ <td> James </td>
+ <td> 19 </td>
+ </tr>
+ </table>
+ </body>
+ </html>
+x equals y: true - y equals x: true
+
+x = Tim
+y = Tim
+x equals y: true - y equals x: true
+
+x = Bob
+y = Bob
+x equals y: true - y equals x: true
+
+x = John
+y = John
+x equals y: true - y equals x: true
+
+x = Bill
+y = Bill
+x equals y: true - y equals x: true
+
+x = Paul
+y = Paul
+x equals y: true - y equals x: true
+
diff --git a/test/files/jvm/serialization.scala b/test/files/jvm/serialization.scala
new file mode 100644
index 0000000000..3d2adc418f
--- /dev/null
+++ b/test/files/jvm/serialization.scala
@@ -0,0 +1,401 @@
+//############################################################################
+// Serialization
+//############################################################################
+
+import java.lang.System
+
+object EqualityTest {
+ def check[A, B](x: A, y: B) {
+ println("x = " + x)
+ println("y = " + y)
+ println("x equals y: " + (x equals y) + " - y equals x: " + (y equals x))
+ println()
+ }
+}
+
+object Serialize {
+ @throws(classOf[java.io.IOException])
+ def write[A](o: A): Array[Byte] = {
+ val ba = new java.io.ByteArrayOutputStream(512)
+ val out = new java.io.ObjectOutputStream(ba)
+ out.writeObject(o)
+ out.close()
+ ba.toByteArray()
+ }
+ @throws(classOf[java.io.IOException])
+ @throws(classOf[ClassNotFoundException])
+ def read[A](buffer: Array[Byte]): A = {
+ val in =
+ new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(buffer))
+ in.readObject().asInstanceOf[A]
+ }
+}
+
+//############################################################################
+// Test classes in package "scala"
+
+object Test1_scala {
+
+ private def arrayToString[A](arr: Array[A]): String =
+ arr.mkString("Array[",",","]")
+
+ private def arrayEquals[A, B](a1: Array[A], a2: Array[B]): Boolean =
+ (a1.length == a2.length) &&
+ (Iterator.range(0, a1.length) forall { i => a1(i) == a2(i) })
+
+ @serializable
+ object WeekDay extends Enumeration {
+ type WeekDay = Value
+ val Monday, Tuesday, Wednesday, Thusday, Friday, Saturday, Sunday = Value
+ }
+ import WeekDay._, BigDecimal._, RoundingMode._
+
+ val x0 = List(1, 2, 3)
+ val x1 = Nil
+ val x2 = None
+ val x3 = Array(1, 2, 3)
+ val x4 = { x: Int => 2 * x }
+ val x5 = 'hello
+ val x6 = ("BannerLimit", 12345)
+ val x7 = BigDecimal.RoundingMode
+ val x8 = WeekDay
+ val x9 = ROUND_UP
+ val x10 = Monday
+
+ try {
+ val y0: List[Int] = Serialize.read(Serialize.write(x0))
+ val y1: List[Nothing] = Serialize.read(Serialize.write(x1))
+ val y2: Option[Nothing] = Serialize.read(Serialize.write(x2))
+ val y3: Array[Int] = Serialize.read(Serialize.write(x3))
+ val y4: Function[Int, Int] = Serialize.read(Serialize.write(x4))
+ val y5: Symbol = Serialize.read(Serialize.write(x5))
+ val y6: (String, Int) = Serialize.read(Serialize.write(x6))
+ val y7: RoundingMode.type = Serialize.read(Serialize.write(x7))
+ val y8: WeekDay.type = Serialize.read(Serialize.write(x8))
+ val y9: RoundingMode = Serialize.read(Serialize.write(x9))
+ val y10: WeekDay = Serialize.read(Serialize.write(x10))
+
+ println("x0 = " + x0)
+ println("y0 = " + y0)
+ println("x0 eq y0: " + (x0 eq y0) + " - y0 eq x0: " + (y0 eq x0))
+ println("x0 equals y0: " + (x0 equals y0) + " - y0 equals x0: " + (y0 equals x0))
+ println()
+ println("x1 = " + x1)
+ println("y1 = " + y1)
+ println("x1 eq y1: " + (x1 eq y1) + " - y1 eq x1: " + (y1 eq x1))
+ println()
+ println("x2 = " + x2)
+ println("y2 = " + y2)
+ println("x2 eq y2: " + (x2 eq y2) + " - y2 eq x2: " + (y2 eq x2))
+ println()
+ println("x3 = " + arrayToString(x3))
+ println("y3 = " + arrayToString(y3))
+ println("arrayEquals(x3, y3): " + arrayEquals(x3, y3))
+ println()
+ println("x4 = <na>")
+ println("y4 = <na>")
+ println("x4(2): " + x4(2) + " - y4(2): " + y4(2))
+ println()
+ println("x5 = " + x5)
+ println("y5 = " + y5)
+ println("x5 eq y5: " + (x5 eq y5) + " - y5 eq x5: " + (y5 eq x5))
+ println("x5 equals y5: " + (x5 equals y5) + " - y5 equals x5: " + (y5 equals x5))
+ println()
+ println("x6 = " + x6)
+ println("y6 = " + y6)
+ println("x6 eq y6: " + (x6 eq y6) + " - y6 eq x6: " + (y6 eq x6))
+ println("x6 equals y6: " + (x6 equals y6) + " - y6 equals x6: " + (y6 equals x6))
+ println()
+ println("x7 = " + x7)
+ println("y7 = " + y7)
+ println("x7 eq y7: " + (x7 eq y7) + " - y7 eq x7: " + (y7 eq x7))
+ println("x7 equals y7: " + (x7 equals y7) + " - y7 equals x7: " + (y7 equals x7))
+ println()
+ println("x8 = " + x8)
+ println("y8 = " + y8)
+ println("x8 eq y8: " + (x8 eq y8) + " - y8 eq x8: " + (y8 eq x8))
+ println("x8 equals y8: " + (x8 equals y8) + " - y8 equals x8: " + (y8 equals x8))
+ println()
+ println("x9 = " + x9)
+ println("y9 = " + y9)
+ println("x9 eq y9: " + (x9 eq y9) + " - y9 eq x9: " + (y9 eq x9))
+ println("x9 equals y9: " + (x9 equals y9) + " - y9 equals x9: " + (y9 equals x9))
+ println()
+ println("x10 = " + x10)
+ println("y10 = " + y10)
+ println("x10 eq y10: " + (x10 eq y10) + " - y10 eq x10: " + (y10 eq x10))
+ println("x10 equals y10: " + (x10 equals y10) + " - y10 equals x10: " + (y10 equals x10))
+ println()
+ println("x9 eq x10: " + (x9 eq x10) + " - x10 eq x9: " + (x10 eq x9))
+ println("x9 equals x10: " + (x9 equals x10) + " - x10 equals x9: " + (x10 equals x9))
+ println("x9 eq y10: " + (x9 eq y10) + " - y10 eq x9: " + (y10 eq x9))
+ println("x9 equals y10: " + (x9 equals y10) + " - y10 equals x9: " + (y10 equals x9))
+ println()
+ }
+ catch {
+ case e: Exception =>
+ e.printStackTrace()
+ println("Error in Test1_scala: " + e)
+ }
+}
+
+//############################################################################
+// Test classes in package "scala.collection.immutable"
+
+@serializable
+object Test2_immutable {
+ import scala.collection.immutable.{
+ BitSet, ListMap, ListSet, Queue, Stack, TreeSet, TreeMap}
+
+ val x1 = List(
+ Pair("buffers", 20),
+ Pair("layers", 2),
+ Pair("title", 3)
+ )
+
+ val x2 = new ListMap[String, Int] + ("buffers" -> 20, "layers" -> 2, "title" -> 3)
+
+ val x3 = {
+ val bs = new collection.mutable.BitSet()
+ bs += 2; bs += 3
+ bs.toImmutable
+ }
+
+ val x4 = new ListSet[Int]() + 3 + 5
+
+ val x5 = new Queue("a", "b", "c")
+
+ val x6 = new Stack().push("a", "b", "c")
+
+ val x7 = new TreeMap[Int, String] + (42 -> "FortyTwo")
+
+ val x8 = new TreeSet[Int]() + 2 + 0
+
+ try {
+ val y1: List[Pair[String, Int]] = Serialize.read(Serialize.write(x1))
+ val y2: ListMap[String, Int] = Serialize.read(Serialize.write(x2))
+ val y3: BitSet = Serialize.read(Serialize.write(x3))
+ val y4: ListSet[Int] = Serialize.read(Serialize.write(x4))
+ val y5: Queue[String] = Serialize.read(Serialize.write(x5))
+ val y6: Stack[String] = Serialize.read(Serialize.write(x6))
+ val y7: TreeMap[Int, String] = Serialize.read(Serialize.write(x7))
+ val y8: TreeSet[Int] = Serialize.read(Serialize.write(x8))
+
+ EqualityTest.check(x1, y1)
+ EqualityTest.check(x2, y2)
+ EqualityTest.check(x3, y3)
+ EqualityTest.check(x4, y4)
+ EqualityTest.check(x5, y5)
+ EqualityTest.check(x6, y6)
+ EqualityTest.check(x7, y7)
+ EqualityTest.check(x8, y8)
+ }
+ catch {
+ case e: Exception =>
+ println("Error in Test2_immutable: " + e)
+ throw e
+ }
+}
+
+//############################################################################
+// Test classes in package "scala.collection.mutable"
+
+object Test3_mutable {
+ import scala.collection.mutable.{
+ ArrayBuffer, BitSet, HashMap, HashSet, History, LinkedList, ListBuffer,
+ Publisher, Queue, RevertableHistory, Stack}
+
+ val x0 = new ArrayBuffer[String]
+ x0 ++= List("one", "two")
+
+ val x2 = new BitSet()
+ x2 += 0
+ x2 += 8
+ x2 += 9
+
+ val x1 = new HashMap[String, Int]
+ x1 ++= Test2_immutable.x1
+
+ val x3 = new HashSet[String]
+ x3 ++= Test2_immutable.x1.map(p => p._1)
+
+ @serializable
+ class Feed extends Publisher[String, Feed]
+
+ val x8 = new History[String, Feed]
+
+ val x4 = new LinkedList[Int](2, null)
+ x4.append(new LinkedList(3, null))
+
+ val x7 = new ListBuffer[String]
+ x7 ++= List("white", "black")
+
+ val x5 = new Queue[Int]
+ x5 ++= Test2_immutable.x1.map(p => p._2)
+
+ val x6 = new Stack[Int]
+ x6 ++= x5
+
+ try {
+ val y0: ArrayBuffer[String] = Serialize.read(Serialize.write(x0))
+ val y1: HashMap[String, Int] = Serialize.read(Serialize.write(x1))
+ val y2: BitSet = Serialize.read(Serialize.write(x2))
+ val y3: HashSet[String] = Serialize.read(Serialize.write(x3))
+ val y4: LinkedList[Int] = Serialize.read(Serialize.write(x4))
+ val y5: Queue[Int] = Serialize.read(Serialize.write(x5))
+ val y6: Stack[Int] = Serialize.read(Serialize.write(x6))
+ val y7: ListBuffer[String] = Serialize.read(Serialize.write(x7))
+ val y8: History[String, Feed] = Serialize.read(Serialize.write(x8))
+
+ EqualityTest.check(x0, y0)
+ EqualityTest.check(x1, y1)
+ EqualityTest.check(x2, y2)
+ EqualityTest.check(x3, y3)
+ EqualityTest.check(x4, y4)
+ EqualityTest.check(x5, y5)
+ EqualityTest.check(x6, y6)
+ EqualityTest.check(x7, y7)
+ //EqualityTest.check(x8, y8) //todo
+ }
+ catch {
+ case e: Exception =>
+ println("Error in Test3_mutable: " + e)
+ }
+}
+
+//############################################################################
+// Test classes in package "scala.xml"
+
+object Test4_xml {
+ import scala.xml.Elem
+
+ val x1 = <html><title>title</title><body></body></html>;
+
+ case class Person(name: String, age: Int)
+
+ class AddressBook(a: Person*) {
+ private val people: List[Person] = a.toList
+ def toXHTML =
+ <table cellpadding="2" cellspacing="0">
+ <tr>
+ <th>Last Name</th>
+ <th>First Name</th>
+ </tr>
+ { for (p <- people) yield
+ <tr>
+ <td> { p.name } </td>
+ <td> { p.age.toString() } </td>
+ </tr> }
+ </table>;
+ }
+
+ val people = new AddressBook(
+ Person("Tom", 20),
+ Person("Bob", 22),
+ Person("James", 19))
+
+ val x2 =
+ <html>
+ <body>
+ { people.toXHTML }
+ </body>
+ </html>;
+
+ try {
+ val y1: scala.xml.Elem = Serialize.read(Serialize.write(x1))
+ val y2: scala.xml.Elem = Serialize.read(Serialize.write(x2))
+
+ EqualityTest.check(x1, y1)
+ EqualityTest.check(x2, y2)
+ }
+ catch {
+ case e: Exception =>
+ println("Error in Test4_xml: " + e)
+ }
+}
+
+//############################################################################
+// Test user-defined classes WITHOUT nesting
+
+@serializable
+class Person(_name: String) {
+ private var name = _name
+ override def toString() = name
+ override def equals(that: Any): Boolean =
+ that.isInstanceOf[Person] &&
+ (name == that.asInstanceOf[Person].name)
+}
+
+@serializable
+class Employee(_name: String) {
+ private var name = _name
+ override def toString() = name
+}
+@serializable
+object bob extends Employee("Bob")
+
+object Test5 {
+ val x1 = new Person("Tim")
+ val x2 = bob
+
+ try {
+ val y1: Person = Serialize.read(Serialize.write(x1))
+ val y2: Employee = Serialize.read(Serialize.write(x2))
+
+ EqualityTest.check(x1, y1)
+ EqualityTest.check(x2, y2)
+ }
+ catch {
+ case e: Exception =>
+ println("Error in Test5: " + e)
+ }
+}
+
+//############################################################################
+// Test user-defined classes WITH nesting
+
+@serializable
+object Test6 {
+ @serializable
+ object bill extends Employee("Bill") {
+ val x = paul
+ }
+ @serializable
+ object paul extends Person("Paul") {
+ val x = 4 // bill; => StackOverflowException !!!
+ }
+ val x1 = new Person("John")
+ val x2 = bill
+ val x3 = paul
+
+ try {
+ val y1: Person = Serialize.read(Serialize.write(x1))
+ val y2: Employee = Serialize.read(Serialize.write(x2))
+ val y3: Person = Serialize.read(Serialize.write(x3))
+
+ EqualityTest.check(x1, y1)
+ EqualityTest.check(x2, y2)
+ EqualityTest.check(x3, y3)
+ }
+ catch {
+ case e: Exception =>
+ println("Error in Test6: " + e)
+ }
+}
+
+//############################################################################
+// Test code
+
+object Test {
+ def main(args: Array[String]) {
+ Test1_scala
+ Test2_immutable
+ Test3_mutable
+ Test4_xml
+ Test5
+ Test6
+ }
+}
+
+//############################################################################
+
diff --git a/test/files/pos/t0851.scala.disabled b/test/files/pos/t0851.scala
index fc7109dcd4..fc7109dcd4 100644
--- a/test/files/pos/t0851.scala.disabled
+++ b/test/files/pos/t0851.scala
diff --git a/test/files/pos/t0872.scala.disabled b/test/files/pos/t0872.scala
index 6dc02497ab..8f4c1c4436 100644
--- a/test/files/pos/t0872.scala.disabled
+++ b/test/files/pos/t0872.scala
@@ -3,6 +3,6 @@ object Main {
val fn = (a : Int, str : String) => "a: " + a + ", str: " + str
implicit def fx[T](f : (T,String) => String) = (x:T) => f(x,null)
println(fn(1))
- ()
+ ()
}
}
diff --git a/test/files/run/collection-stacks.check b/test/files/run/collection-stacks.check
new file mode 100644
index 0000000000..fcb39c460c
--- /dev/null
+++ b/test/files/run/collection-stacks.check
@@ -0,0 +1,14 @@
+1-2-3: true
+1-2-3: true
+apply
+1: true
+1: true
+3: true
+3: true
+top
+3: true
+3: true
+pop
+1-2: true
+3: true
+1-2: true
diff --git a/test/files/run/collection-stacks.scala b/test/files/run/collection-stacks.scala
new file mode 100644
index 0000000000..b159be07aa
--- /dev/null
+++ b/test/files/run/collection-stacks.scala
@@ -0,0 +1,38 @@
+import scala.collection._
+
+object Test extends Application {
+ def mutableStack[T](xs: T*): mutable.Stack[T] = {
+ val s = new mutable.Stack[T]
+ s.pushAll(xs)
+ s
+ }
+
+ def immutableStack[T](xs: T*): immutable.Stack[T] = {
+ immutable.Stack.Empty pushAll xs
+ }
+
+ def check[T](expected: T, got: T) {
+ println(got + ": " + (expected == got))
+ }
+
+ // check #957
+ check("1-2-3", immutableStack(1, 2, 3).iterator.mkString("-"))
+ check("1-2-3", mutableStack(1, 2, 3).iterator.mkString("-"))
+
+ println("apply")
+ check(1, immutableStack(1, 2, 3).apply(0))
+ check(1, mutableStack(1, 2, 3).apply(0))
+ check(3, immutableStack(1, 2, 3).apply(2))
+ check(3, mutableStack(1, 2, 3).apply(2))
+
+ println("top")
+ check(3, immutableStack(1, 2, 3).top)
+ check(3, mutableStack(1, 2, 3).top)
+
+ println("pop")
+ check("1-2", immutableStack(1, 2, 3).pop.mkString("-"))
+ check(3, mutableStack(1, 2, 3).pop())
+ check("1-2", { val s = mutableStack(1, 2, 3); s.pop(); s.toList.mkString("-") })
+}
+
+// vim: set ts=2 sw=2 et:
diff --git a/test/files/run/deeps.check b/test/files/run/deeps.check
new file mode 100644
index 0000000000..f1925fcbc1
--- /dev/null
+++ b/test/files/run/deeps.check
@@ -0,0 +1,83 @@
+false
+false
+true
+
+false
+false
+true
+
+x=Array(1)
+y=Array(1)
+false
+false
+true
+
+x=Array(Array(1), Array(1))
+y=Array(Array(1), Array(1))
+false
+false
+true
+
+x=Array(Array(Array(1), Array(1)), Array(Array(1), Array(1)))
+y=Array(Array(Array(1), Array(1)), Array(Array(1), Array(1)))
+false
+false
+true
+
+false
+false
+true
+false
+false
+true
+Array(true, false)
+Array(true, false)
+[true;false]
+true;false
+
+Array([Z@0000000, [Z@0000000)
+Array(Array(true, false), Array(true, false))
+[[true;false];[true;false]]
+true;false;true;false
+
+Array([[Z@0000000, [[Z@0000000)
+Array(Array(Array(true, false), Array(true, false)), Array(Array(true, false), Array(true, false)))
+[[[true;false];[true;false]];[[true;false];[true;false]]]
+true;false;true;false;true;false;true;false
+
+Array(1.0, 0.0)
+Array(1.0, 0.0)
+[1.0;0.0]
+1.0;0.0
+
+Array([D@0000000, [D@0000000)
+Array(Array(1.0, 0.0), Array(1.0, 0.0))
+[[1.0;0.0];[1.0;0.0]]
+1.0;0.0;1.0;0.0
+
+Array([[D@0000000, [[D@0000000)
+Array(Array(Array(1.0, 0.0), Array(1.0, 0.0)), Array(Array(1.0, 0.0), Array(1.0, 0.0)))
+[[[1.0;0.0];[1.0;0.0]];[[1.0;0.0];[1.0;0.0]]]
+1.0;0.0;1.0;0.0;1.0;0.0;1.0;0.0
+
+Array(a, b)
+Array(a, b)
+[a;b]
+a;b
+
+Array([Ljava.lang.String;@0000000, [Ljava.lang.String;@0000000)
+Array(Array(a, b), Array(a, b))
+[[a;b];[a;b]]
+a;b;a;b
+
+Array([[Ljava.lang.String;@0000000, [[Ljava.lang.String;@0000000)
+Array(Array(Array(a, b), Array(a, b)), Array(Array(a, b), Array(a, b)))
+[[[a;b];[a;b]];[[a;b];[a;b]]]
+a;b;a;b;a;b;a;b
+
+[[true; false]; [false]]
+[[1; 2]; [3]]
+[[1; 2]; [3]]
+
+Array(boo, and, foo)
+Array(a)
diff --git a/test/files/run/deeps.scala b/test/files/run/deeps.scala
new file mode 100644
index 0000000000..c93c040ef8
--- /dev/null
+++ b/test/files/run/deeps.scala
@@ -0,0 +1,111 @@
+//############################################################################
+// deepEquals / deepToString
+//############################################################################
+
+//############################################################################
+// need to revisit array equqality
+object Test extends Application {
+
+ def testEquals1 {
+ println(Array(1) == Array(1))
+ println(Array(1) equals Array(1))
+ println(Array(1) deepEquals Array(1))
+ println
+ }
+
+ def testEquals2 {
+ println(Array(Array(1), Array(2)) == Array(Array(1), Array(2)))
+ println(Array(Array(1), Array(2)) equals Array(Array(1), Array(2)))
+ println(Array(Array(1), Array(2)) deepEquals Array(Array(1), Array(2)))
+ println
+ }
+
+ def testEquals3 {
+ val a1 = Array(1)
+ val b1 = Array(1)
+ val a2 = Array(a1, b1)
+ val b2 = Array(a1, b1)
+ val a3 = Array(a2, b2)
+ val b3 = Array(a2, b2)
+ def test[T](x: Array[T], y: Array[T]) {
+ println("x=" + x.deepToString)
+ println("y=" + y.deepToString)
+ println(x == y)
+ println(x equals y)
+ println(x deepEquals y)
+ println
+ }
+ test(a1, b1)
+ test(a2, b2)
+ test(a3, b3)
+ }
+
+ def testEquals4 {
+ println("boo:and:foo".split(':') == "boo:and:foo".split(':'))
+ println("boo:and:foo".split(':') equals "boo:and:foo".split(':'))
+ println("boo:and:foo".split(':') deepEquals "boo:and:foo".split(':'))
+
+ val xs = new java.util.ArrayList[String](); xs.add("a")
+ val ys = new java.util.ArrayList[String](); ys.add("a")
+ println(xs.toArray == ys.toArray)
+ println(xs.toArray equals ys.toArray)
+ println(xs.toArray deepEquals ys.toArray)
+ }
+
+ def testToString1 {
+ def sweep(s: String) =
+ s.replaceAll("D@[0-9a-fA-F]+", "D@0000000")
+ .replaceAll("Z@[0-9a-fA-F]+", "Z@0000000")
+ .replaceAll(";@[0-9a-fA-F]+", ";@0000000")
+ def test[T](a: Array[T]) {
+ println(sweep(a.toString))
+ println(a.deepToString)
+ println(a.deepMkString("[", ";", "]"))
+ println(a.deepMkString(";"))
+ println
+ }
+
+ val ba1 = Array(true, false)
+ val ba2 = Array(ba1, ba1)
+ val ba3 = Array(ba2, ba2)
+ test(ba1)
+ test(ba2)
+ test(ba3)
+
+ val da1 = Array(1.0d, 0.0d)
+ val da2 = Array(da1, da1)
+ val da3 = Array(da2, da2)
+ test(da1)
+ test(da2)
+ test(da3)
+
+ val sa1 = Array("a", "b")
+ val sa2 = Array(sa1, sa1)
+ val sa3 = Array(sa2, sa2)
+ test(sa1)
+ test(sa2)
+ test(sa3)
+ }
+
+ def testToString2 {
+ println(Array(Array(true, false), Array(false)).deepMkString("[", "; ", "]"))
+ println(Array(Array('1', '2'), Array('3')).deepMkString("[", "; ", "]"))
+ println(Array(Array(1, 2), Array(3)).deepMkString("[", "; ", "]"))
+ println
+ }
+
+ def testToString3 {
+ println("boo:and:foo".split(':').deepToString)
+
+ val xs = new java.util.ArrayList[String](); xs.add("a")
+ println(xs.toArray.deepToString)
+ }
+
+ testEquals1
+ testEquals2
+ testEquals3
+ testEquals4
+ testToString1
+ testToString2
+ testToString3
+}
diff --git a/test/files/run/t0485.check b/test/files/run/t0485.check
new file mode 100644
index 0000000000..3a462cfdc1
--- /dev/null
+++ b/test/files/run/t0485.check
@@ -0,0 +1,32 @@
+m1={(10,20), (20,30)}
+m2={(10,20)}
+m1.size > m2.size is true
+m1 equals m2 is true
+
+m1={(10,20), (20,30)}
+m2={(10,20)}
+m1.size > m2.size is true
+m1 equals m2 is true
+
+m1={(10,20), (20,30)}
+m2={(10,20)}
+m1.size > m2.size is true
+m1 equals m2 is true
+
+java.lang.CloneNotSupportedException: The underlying map doesn't implement the Cloneable interface
+
+s1=[10, 20]
+s2=[10]
+s1.size > s2 is true
+s1 equals s2 is true
+
+s1=[10, 20]
+s2=[10]
+s1.size > s2 is true
+s1 equals s2 is true
+
+s1=[10, 20]
+s2=[10]
+s1.size > s2 is true
+s1 equals s2 is true
+
diff --git a/test/files/run/t0485.scala b/test/files/run/t0485.scala
new file mode 100644
index 0000000000..9e2017aacc
--- /dev/null
+++ b/test/files/run/t0485.scala
@@ -0,0 +1,54 @@
+import scala.collection.jcl
+
+object Test extends Application {
+ testMap
+ testSet
+}
+
+object testMap {
+ def toString(m1: collection.Map[Int, Int]): String =
+ m1.toList.sort((x, y) => x < y).mkString("{", ", ", "}")
+ def test(m1: jcl.Map[Int, Int]) {
+ try {
+ m1.put(10, 20)
+ val m2 = m1.clone()
+ m1.put(20, 30)
+ println("m1="+toString(m1))
+ println("m2="+toString(m2))
+ println("m1.size > m2.size is "+ (m1.size > m2.size))
+ m1.remove((20, 30))
+ println("m1 equals m2 is "+ (m1 equals m2))
+ println()
+ }
+ catch {
+ case e: Exception =>
+ println(e); println()
+ }
+ }
+ test(new jcl.HashMap[Int, Int])
+ // Clone on IdentityHashMap of java-ibm-1.6 behaves differently than all others
+ // Therefore, for now we will not perform this test on it.
+ // test(new jcl.IdentityHashMap[Int, Int])
+ test(new jcl.LinkedHashMap[Int, Int])
+ test(new jcl.TreeMap[Int, Int])
+ test(new jcl.WeakHashMap[Int, Int])
+}
+
+object testSet {
+ def toString(s1: collection.Set[Int]): String =
+ s1.toList.sort((x, y) => x < y).mkString("[", ", ", "]")
+ def test(s1: jcl.Set[Int]) {
+ s1.add(10)
+ val s2 = s1.clone()
+ s1.add(20)
+ println("s1="+toString(s1))
+ println("s2="+toString(s2))
+ println("s1.size > s2 is "+ (s1.size > s2.size))
+ s1.remove(20)
+ println("s1 equals s2 is "+ (s1 equals s2))
+ println()
+ }
+ test(new jcl.HashSet[Int])
+ test(new jcl.LinkedHashSet[Int])
+ test(new jcl.TreeSet[Int])
+}
diff --git a/test/files/run/unittest_collection.scala b/test/files/run/unittest_collection.scala
new file mode 100644
index 0000000000..5d7ab97425
--- /dev/null
+++ b/test/files/run/unittest_collection.scala
@@ -0,0 +1,103 @@
+
+object Test {
+
+ import scala.testing.SUnit._
+ import scala.collection.mutable.{ArrayBuffer, Buffer, BufferProxy, ListBuffer}
+
+ trait BufferTest extends Assert {
+ def doTest(x:Buffer[String]) = {
+ // testing method +=
+ x += "one"
+ assertEquals("retrieving 'one'", x(0), "one")
+ assertEquals("length A ", x.length, 1)
+ x += "two"
+ assertEquals("retrieving 'two'", x(1), "two")
+ assertEquals("length B ", x.length, 2)
+
+ // testing method -= (removing last element)
+ x -= "two"
+
+ assertEquals("length C ", x.length, 1)
+
+ try { x(1); fail("no exception for removed element") }
+ catch { case i:IndexOutOfBoundsException => }
+
+ try { x.remove(1); fail("no exception for removed element") }
+ catch { case i:IndexOutOfBoundsException => }
+
+ x += "two2"
+ assertEquals("length D ", x.length, 2)
+
+ // removing first element
+ x.remove(0)
+ assertEquals("length E ", x.length, 1)
+
+ // toList
+ assertEquals("toList ", x.toList, List("two2"))
+
+ // clear
+ x.clear
+ assertEquals("length F ", x.length, 0)
+
+ // copyToBuffer
+ x += "a"
+ x += "b"
+ val dest = new ArrayBuffer[String]
+ x copyToBuffer dest
+ assertEquals("dest", List("a", "b"), dest.toList)
+ assertEquals("source", List("a", "b"), x.toList)
+ }
+ }
+
+ class TArrayBuffer extends TestCase("collection.mutable.ArrayBuffer") with Assert with BufferTest {
+
+ var x: ArrayBuffer[String] = _
+
+ override def runTest = { setUp; doTest(x); tearDown }
+
+ override def setUp = { x = new scala.collection.mutable.ArrayBuffer }
+
+ override def tearDown = { x.clear; x = null }
+ }
+
+ class TListBuffer extends TestCase("collection.mutable.ListBuffer") with Assert with BufferTest {
+
+ var x: ListBuffer[String] = _
+
+ override def runTest = { setUp; doTest(x); tearDown }
+
+ override def setUp = { x = new scala.collection.mutable.ListBuffer }
+
+ override def tearDown = { x.clear; x = null }
+
+ }
+
+ class TBufferProxy extends TestCase("collection.mutable.BufferProxy") with Assert with BufferTest {
+
+ class BBuf(z:ListBuffer[String]) extends BufferProxy[String] {
+ def self = z
+ }
+
+ var x: BufferProxy[String] = _
+
+ override def runTest = { setUp; doTest(x); tearDown }
+
+ override def setUp = { x = new BBuf(new scala.collection.mutable.ListBuffer) }
+
+ override def tearDown = { x.clear; x = null }
+
+ }
+
+ def main(args:Array[String]) = {
+ val ts = new TestSuite(
+ //new TArrayBuffer,
+ new TListBuffer//,
+ //new TBufferProxy
+ )
+ val tr = new TestResult()
+ ts.run(tr)
+ for(val failure <- tr.failures) {
+ Console.println(failure)
+ }
+ }
+}
diff --git a/test/files/script/fact.args b/test/files/script/fact.args
new file mode 100644
index 0000000000..7ed6ff82de
--- /dev/null
+++ b/test/files/script/fact.args
@@ -0,0 +1 @@
+5
diff --git a/test/files/script/fact.bat b/test/files/script/fact.bat
new file mode 100755
index 0000000000..bee0ba25c6
--- /dev/null
+++ b/test/files/script/fact.bat
@@ -0,0 +1,17 @@
+::#!
+:: fact - A simple Scala batch file that prints out the factorial
+:: of the argument specified on the command line.
+
+@echo off
+call scala -nocompdaemon %0 %*
+goto :eof
+::!#
+
+
+val x = argv(0).toInt
+
+def fact(x: Int):Int =
+ if(x==0) 1
+ else x*fact(x-1)
+
+Console.println("fact(" + x + ") = " + fact(x))
diff --git a/test/files/script/fact.check b/test/files/script/fact.check
new file mode 100644
index 0000000000..22aa60821e
--- /dev/null
+++ b/test/files/script/fact.check
@@ -0,0 +1 @@
+fact(5) = 120
diff --git a/test/files/script/fact.scala b/test/files/script/fact.scala
new file mode 100644
index 0000000000..d48dac6f0f
--- /dev/null
+++ b/test/files/script/fact.scala
@@ -0,0 +1,30 @@
+#!/bin/sh
+# fact - A simple Scala script that prints out the factorial of
+# the argument specified on the command line.
+
+cygwin=false;
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+esac
+
+SOURCE="$0";
+if $cygwin; then
+ if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
+ format=mixed
+ else
+ format=windows
+ fi
+ SOURCE=`cygpath --$format "$SOURCE"`;
+fi
+
+exec scala -nocompdaemon "$SOURCE" "$@"
+!#
+
+
+val x = argv(0).toInt
+
+def fact(x: Int):Int =
+ if(x==0) 1
+ else x*fact(x-1)
+
+Console.println("fact(" + x + ") = " + fact(x))