summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoraleksandar <aleksandar@lampmac14.epfl.ch>2012-01-23 18:47:04 +0100
committeraleksandar <aleksandar@lampmac14.epfl.ch>2012-01-23 18:51:35 +0100
commita6fcd70b6047ab56cb3415f378ffc8d72a524a8d (patch)
treefa83abdb558fe4551440c5e24dd470982f34c7fa /test
parent9a20086495e7734b636c5ee625d305a3fbaea476 (diff)
downloadscala-a6fcd70b6047ab56cb3415f378ffc8d72a524a8d.tar.gz
scala-a6fcd70b6047ab56cb3415f378ffc8d72a524a8d.tar.bz2
scala-a6fcd70b6047ab56cb3415f378ffc8d72a524a8d.zip
Fix for SI-5374.
Lists are now serialized so that the entire list structure is serialized, including list nodes. This is different from the previous behaviour where only the elements were serialized. List buffers are now optimized so that only the elements of the list are serialized, and not the nodes of the internally maintained list.
Diffstat (limited to 'test')
-rw-r--r--test/files/run/si5374.check3
-rw-r--r--test/files/run/si5374.scala42
2 files changed, 45 insertions, 0 deletions
diff --git a/test/files/run/si5374.check b/test/files/run/si5374.check
new file mode 100644
index 0000000000..cdf0bc7e5b
--- /dev/null
+++ b/test/files/run/si5374.check
@@ -0,0 +1,3 @@
+ListBuffer(1, 2, 3, 1)
+ListBuffer(1, 2, 3, 1)
+ListBuffer() \ No newline at end of file
diff --git a/test/files/run/si5374.scala b/test/files/run/si5374.scala
new file mode 100644
index 0000000000..a5678c3a81
--- /dev/null
+++ b/test/files/run/si5374.scala
@@ -0,0 +1,42 @@
+
+
+
+import collection.mutable.ListBuffer
+import java.io._
+
+
+
+object Test {
+
+ def main(args: Array[String]) {
+ ticketExample()
+ emptyListBuffer()
+ }
+
+ def ticketExample() {
+ val baos = new ByteArrayOutputStream
+ val oos = new ObjectOutputStream(baos)
+ oos.writeObject( ListBuffer(1,2,3) )
+ val bais = new ByteArrayInputStream( baos.toByteArray )
+ val ois = new ObjectInputStream(bais)
+ val lb = ois.readObject.asInstanceOf[ListBuffer[Int]]
+ val lb2 = ListBuffer[Int]() ++= lb
+
+ lb2 ++= List(1)
+ lb ++= List(1)
+ println(lb)
+ println(lb2)
+ }
+
+ def emptyListBuffer() {
+ val baos = new ByteArrayOutputStream
+ val oos = new ObjectOutputStream(baos)
+ oos.writeObject( ListBuffer() )
+ val bais = new ByteArrayInputStream( baos.toByteArray )
+ val ois = new ObjectInputStream(bais)
+ val lb = ois.readObject.asInstanceOf[ListBuffer[Int]]
+
+ println(lb)
+ }
+
+}