groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] branch master updated: Add a test for `with` under STC mode
Date Sat, 02 Nov 2019 14:38:41 GMT
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 6a38f52  Add a test for `with` under STC mode
6a38f52 is described below

commit 6a38f524ecbba56673521613557da2e647a6c9c3
Author: Daniel Sun <sunlan@apache.org>
AuthorDate: Sat Nov 2 22:38:29 2019 +0800

    Add a test for `with` under STC mode
---
 src/test/groovy/transform/stc/WithSTCTest.groovy | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/test/groovy/transform/stc/WithSTCTest.groovy b/src/test/groovy/transform/stc/WithSTCTest.groovy
index afae05c..083346a 100644
--- a/src/test/groovy/transform/stc/WithSTCTest.groovy
+++ b/src/test/groovy/transform/stc/WithSTCTest.groovy
@@ -48,5 +48,18 @@ class WithSTCTest extends StaticTypeCheckingTestCase {
             assert Test.a( 'TIM' ) == 'tim'
         '''
     }
-}
 
+    void testIntReturnType() {
+        assertScript '''
+            class Test {
+               static int a(String s) {
+                    s.toCharArray().with {
+                        length
+                    }
+                }
+            }
+
+            assert Test.a( 'Daniel' ) == 6 
+        '''
+    }
+}


Mime
View raw message