groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Add a test for GROOVY-8337
Date Sun, 26 Aug 2018 02:25:33 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X 5a1807d9c -> 40b632943


Add a test for GROOVY-8337

(cherry picked from commit e82bd2654536675c7abcf51f250921f44b5c44f1)


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

Branch: refs/heads/GROOVY_2_5_X
Commit: 40b63294379073af2ad56f8132fd3e4c358930d9
Parents: 5a1807d
Author: Daniel Sun <sunlan@apache.org>
Authored: Sun Aug 26 10:07:11 2018 +0800
Committer: Daniel Sun <sunlan@apache.org>
Committed: Sun Aug 26 10:25:28 2018 +0800

----------------------------------------------------------------------
 src/test/groovy/bugs/Groovy8337Bug.groovy | 52 ++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/40b63294/src/test/groovy/bugs/Groovy8337Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy8337Bug.groovy b/src/test/groovy/bugs/Groovy8337Bug.groovy
new file mode 100644
index 0000000..87c166e
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy8337Bug.groovy
@@ -0,0 +1,52 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package groovy.bugs
+
+import gls.CompilableTestSupport
+import groovy.transform.NotYetImplemented
+
+class Groovy8337Bug extends CompilableTestSupport {
+    void testGroovy8337() {
+        assertScript '''
+            import groovy.transform.CompileStatic
+            @CompileStatic
+            class Static {
+              private Number n
+              BigDecimal meth() {
+                return n == null || n instanceof BigDecimal ? n : new BigDecimal(n.toString())
+              }
+            }
+            assert null == new Static().meth()
+        '''
+    }
+
+    void testGroovy8337WithFieldValue() {
+        assertScript '''
+            import groovy.transform.CompileStatic
+            @CompileStatic
+            class Static {
+              private Number n = new BigDecimal('1.23')
+              BigDecimal meth() {
+                return n == null || n instanceof BigDecimal ? n : new BigDecimal(n.toString())
+              }
+            }
+            assert new BigDecimal('1.23') == new Static().meth()
+        '''
+    }
+}


Mime
View raw message