You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/12/01 07:52:14 UTC
[groovy] branch master updated: Add 2 more tests for native lambda
expression
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 2aebd67 Add 2 more tests for native lambda expression
2aebd67 is described below
commit 2aebd677cfcd83b1d96a28e2023dac434d333a6d
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Dec 1 15:52:02 2019 +0800
Add 2 more tests for native lambda expression
---
src/test/groovy/transform/stc/LambdaTest.groovy | 46 +++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/src/test/groovy/transform/stc/LambdaTest.groovy b/src/test/groovy/transform/stc/LambdaTest.groovy
index 98d7074..f762710 100644
--- a/src/test/groovy/transform/stc/LambdaTest.groovy
+++ b/src/test/groovy/transform/stc/LambdaTest.groovy
@@ -329,6 +329,52 @@ class LambdaTest extends GroovyTestCase {
'''
}
+ void testFunctionWithLocalVariables5() {
+ assertScript '''
+ import groovy.transform.CompileStatic
+ import java.util.stream.Collectors
+ import java.util.stream.Stream
+ import java.util.function.Function
+
+ @CompileStatic
+ public class Test1 {
+ public static void main(String[] args) {
+ Function<Integer, String> f = p();
+ assert '#1' == f(1)
+ }
+
+ static Function<Integer, String> p() {
+ String x = "#"
+ Function<Integer, String> f = (Integer e) -> x + e
+ return f
+ }
+ }
+ '''
+ }
+
+ void testFunctionWithLocalVariables6() {
+ assertScript '''
+ import groovy.transform.CompileStatic
+ import java.util.stream.Collectors
+ import java.util.stream.Stream
+ import java.util.function.Function
+
+ @CompileStatic
+ public class Test1 {
+ public static void main(String[] args) {
+ Function<Integer, String> f = new Test1().p();
+ assert '#1' == f(1)
+ }
+
+ Function<Integer, String> p() {
+ String x = "#"
+ Function<Integer, String> f = (Integer e) -> x + e
+ return f
+ }
+ }
+ '''
+ }
+
void testFunctionWithStaticMethodCall() {
assertScript '''
import groovy.transform.CompileStatic