Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.6-rc-1
-
None
Description
The following test case fails with Groovy version 1.5.6.
NEWLINE = System.getProperty("line.separator") void doTest(def param) { try { StringWriter sw1 = new StringWriter() StringWriter sw2 = new StringWriter() StringWriter sw3 = new StringWriter() sw1.write(String.valueOf(param)) sw2.print(String.valueOf(param)) new PrintWriter(sw3).print(param) assert sw1.toString() == sw2.toString() assert sw1.toString() == sw3.toString() sw1 = new StringWriter() sw2 = new StringWriter() sw3 = new StringWriter() sw1.write(String.valueOf(param)) sw1.write(NEWLINE) sw2.println(param) new PrintWriter(sw3).println(param) assert sw1.toString() == sw2.toString() assert sw1.toString() == sw3.toString() } catch (AssertionError e) { System.err.println(param) throw e } } doTest(null) doTest("foo") doTest(true) doTest(false) doTest((byte)123) doTest((short)1234) doTest(new Integer(1234)) doTest(new Long(9999999999)) doTest(new Float(1234.5678)) doTest(new Double(1234.5678)) doTest(new BigInteger("123456789012345678901234567890")) doTest(new BigDecimal("12345678901234567890.1234567890123456789")) doTest(new Date()) doTest(new StringBuffer("bar")) doTest([null, "foo", true, false, new Integer(1234)]) doTest(["foo" : "bar", "true": true, "int": new Integer(1234)])
Attachments
Attachments
Issue Links
- depends upon
-
GROOVY-3238 String.valueOf(BigInteger) doesn't call String.valueOf(Object)
- Closed
- relates to
-
GROOVY-3253 Change array formatting to be uniform
- Closed