netliomax25-code commented on code in PR #2619:
URL: https://github.com/apache/groovy/pull/2619#discussion_r3461370931
##########
subprojects/groovy-json/src/test/groovy/groovy/json/JsonSlurperTest.groovy:
##########
@@ -741,6 +741,16 @@ class JsonSlurperTest {
assertNotNull(map.get("big"))
}
+ @Test
+ void testParseIntegerBeyondLongRange() {
+ // 9999999999999999999 exceeds Long.MAX_VALUE; it must round-trip as a
+ // BigInteger rather than silently overflowing to a wrong (negative)
long.
+ def raw = parser.parseText('9999999999999999999')
+ def value = raw instanceof Value ? raw.toValue() : raw
+ assertTrue(value instanceof BigInteger)
+ assertEquals(new BigInteger('9999999999999999999'), value)
+ }
Review Comment:
The test is inherited by JsonSlurperIndexOverlayTest, JsonSlurperLaxTest,
and JsonSlurperCharSourceTest, each of which sets a different parser.type in
setUp(), so the INDEX_OVERLAY/LAX/CHARACTER_SOURCE paths are asserted there
too. On an unpatched tree it fails 4 times, one per parser type. Pushed a short
comment on the method so that's clear without chasing the subclasses.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]