You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2015/11/09 23:09:35 UTC

[2/2] incubator-groovy git commit: GROOVY-7665 - JsonSlurperCharSource decimal parsing producing unexpected results (closes #183)

GROOVY-7665 - JsonSlurperCharSource decimal parsing producing unexpected results (closes #183)


Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/93e30896
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/93e30896
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/93e30896

Branch: refs/heads/pr/176
Commit: 93e30896048c262387b911b74df0f1e7f9711723
Parents: 1a900a6
Author: John Wagenleitner <jo...@gmail.com>
Authored: Mon Nov 9 13:13:20 2015 -0800
Committer: pascalschumacher <pa...@gmx.net>
Committed: Mon Nov 9 23:08:48 2015 +0100

----------------------------------------------------------------------
 .../src/main/java/groovy/json/internal/CharScanner.java        | 2 +-
 .../test/groovy/groovy/json/JsonSlurperCharSourceTest.groovy   | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/93e30896/subprojects/groovy-json/src/main/java/groovy/json/internal/CharScanner.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-json/src/main/java/groovy/json/internal/CharScanner.java b/subprojects/groovy-json/src/main/java/groovy/json/internal/CharScanner.java
index 156bd06..f140cf6 100644
--- a/subprojects/groovy-json/src/main/java/groovy/json/internal/CharScanner.java
+++ b/subprojects/groovy-json/src/main/java/groovy/json/internal/CharScanner.java
@@ -684,7 +684,7 @@ public class CharScanner {
     }
 
     public static BigDecimal parseBigDecimal(char[] buffer, int from, int to) {
-        return new BigDecimal(parseDouble(buffer, from, to));
+        return new BigDecimal(buffer, from, to);
     }
 
     public static float parseFloat(char[] buffer, int from, int to) {

http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/93e30896/subprojects/groovy-json/src/test/groovy/groovy/json/JsonSlurperCharSourceTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-json/src/test/groovy/groovy/json/JsonSlurperCharSourceTest.groovy b/subprojects/groovy-json/src/test/groovy/groovy/json/JsonSlurperCharSourceTest.groovy
index 9bf1265..19bff4b 100644
--- a/subprojects/groovy-json/src/test/groovy/groovy/json/JsonSlurperCharSourceTest.groovy
+++ b/subprojects/groovy-json/src/test/groovy/groovy/json/JsonSlurperCharSourceTest.groovy
@@ -26,4 +26,10 @@ class JsonSlurperCharSourceTest extends JsonSlurperTest {
     void setUp() {
         parser = new JsonSlurper().setType(JsonParserType.CHARACTER_SOURCE)
     }
+
+    void testParsingDecimalValue() {
+        def num = parser.parseText('{"num": 123.40}').num
+        assert num instanceof BigDecimal
+        assert 123.40G == num
+    }
 }