diff options
Diffstat (limited to 'test/files/jvm')
-rw-r--r-- | test/files/jvm/t2214.check | 3 | ||||
-rw-r--r-- | test/files/jvm/t2214.scala | 39 |
2 files changed, 42 insertions, 0 deletions
diff --git a/test/files/jvm/t2214.check b/test/files/jvm/t2214.check new file mode 100644 index 0000000000..72601bac11 --- /dev/null +++ b/test/files/jvm/t2214.check @@ -0,0 +1,3 @@ +got DEBT +got FUTURE +got EQUITY diff --git a/test/files/jvm/t2214.scala b/test/files/jvm/t2214.scala new file mode 100644 index 0000000000..db3e400bbb --- /dev/null +++ b/test/files/jvm/t2214.scala @@ -0,0 +1,39 @@ + +object InvestmentType extends Enumeration { + val Debt = Value("DEBT") + val Future = Value("FUTURE") + val Equity = Value("EQUITY") +} + +object Test { + def main(args: Array[String]) = { + val buf = new java.io.ByteArrayOutputStream + val oos = new java.io.ObjectOutputStream(buf) + InvestmentType.values.foreach {i => oos.writeObject(i)} + oos.flush + oos.close + val ois = new java.io.ObjectInputStream( + new java.io.ByteArrayInputStream(buf.toByteArray)) + var obj: Object = null + foreach(ois) { obj => + obj match { + case InvestmentType.Debt => println("got " + obj) + case InvestmentType.Equity => println("got " + obj) + case InvestmentType.Future => println("got " + obj) + case _ => println("unknown: " + obj + " of: " + obj.getClass) + } + } + } + + def foreach(os: java.io.ObjectInputStream)(f: Object => Unit) { + try { + val obj = os.readObject + if (obj != null) { + f(obj) + foreach(os)(f) + } + } catch { + case e: java.io.EOFException => //IGNORE + } + } +} |