aboutsummaryrefslogtreecommitdiff
path: root/tests/pending/run/t5018.scala
blob: 147d69cf867a74e6f1bb6c38eb731fb8b4f7caef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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]): Unit = {
    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)
  }

}