From f9551d0c2f92ded7ef574121d89cda742e407f2d Mon Sep 17 00:00:00 2001 From: Philipp Haller Date: Mon, 26 Oct 2009 22:50:56 +0000 Subject: Fix and test for #2214. --- test/files/jvm/t2214.check | 3 +++ test/files/jvm/t2214.scala | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 test/files/jvm/t2214.check create mode 100644 test/files/jvm/t2214.scala (limited to 'test') 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 + } + } +} -- cgit v1.2.3