From 628eaa5aca0117823327571a1384f0d717fd7b4e Mon Sep 17 00:00:00 2001 From: Aleksandar Prokopec Date: Fri, 4 May 2012 10:46:29 +0200 Subject: Fix for si-5018. Methods keySet, values and withDefault now return serializable collections. --- test/files/run/t5018.scala | 37 +++++++++++++++++++++++++++++++++++++ test/pending/run/t5018.scala | 34 ---------------------------------- 2 files changed, 37 insertions(+), 34 deletions(-) create mode 100644 test/files/run/t5018.scala delete mode 100644 test/pending/run/t5018.scala (limited to 'test') diff --git a/test/files/run/t5018.scala b/test/files/run/t5018.scala new file mode 100644 index 0000000000..bb67a252e5 --- /dev/null +++ b/test/files/run/t5018.scala @@ -0,0 +1,37 @@ + + + +import java.io._ +import collection._ + + + +object Test { + + def serializeDeserialize[T <: AnyRef](obj: T) = { + val buffer = new ByteArrayOutputStream + val out = new ObjectOutputStream(buffer) + out.writeObject(obj) + val in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray)) + in.readObject.asInstanceOf[T] + } + + def main(args: Array[String]) { + val values = mutable.Map(1 -> 1).values + assert(serializeDeserialize(values).toList == values.toList) + + val keyset = mutable.Map(1 -> 1).keySet + assert(serializeDeserialize(keyset) == keyset) + + val imkeyset = immutable.Map(1 -> 1).keySet + assert(serializeDeserialize(imkeyset) == imkeyset) + + val defaultmap = immutable.Map(1 -> 1).withDefaultValue(1) + assert(serializeDeserialize(defaultmap) == defaultmap) + + val minusmap = mutable.Map(1 -> 1).withDefault(x => -x) + assert(serializeDeserialize(minusmap) == minusmap) + } + +} + diff --git a/test/pending/run/t5018.scala b/test/pending/run/t5018.scala deleted file mode 100644 index 30c0d5ac94..0000000000 --- a/test/pending/run/t5018.scala +++ /dev/null @@ -1,34 +0,0 @@ - - - -import java.io._ -import collection._ - - - -object Test { - - def serializeDeserialize[T <: AnyRef](obj: T) = { - val buffer = new ByteArrayOutputStream - val out = new ObjectOutputStream(buffer) - out.writeObject(obj) - val in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray)) - in.readObject.asInstanceOf[T] - } - - def main(args: Array[String]) { - val values = mutable.Map(1 -> 1).values - assert(serializeDeserialize(values) == values) - - val keyset = mutable.Map(1 -> 1).keySet - assert(serializeDeserialize(keyset) == keyset) - - val imkeyset = immutable.Map(1 -> 1).keySet - assert(serializeDeserialize(imkeyset) == imkeyset) - - val defaultmap = immutable.Map(1 -> 1).withDefaultValue(1) - assert(serializeDeserialize(defaultmap) == defaultmap) - } - -} - -- cgit v1.2.3