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/11 07:21:36 UTC
[groovy] branch master updated: Add one more test for lambda
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 51b3289 Add one more test for lambda
51b3289 is described below
commit 51b3289dc7373b7bdf35d3c9e7fcbf0c990ca503
Author: Daniel Sun <su...@apache.org>
AuthorDate: Wed Dec 11 15:21:10 2019 +0800
Add one more test for lambda
---
src/test/groovy/transform/stc/LambdaTest.groovy | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/test/groovy/transform/stc/LambdaTest.groovy b/src/test/groovy/transform/stc/LambdaTest.groovy
index 672aab3..734ca65 100644
--- a/src/test/groovy/transform/stc/LambdaTest.groovy
+++ b/src/test/groovy/transform/stc/LambdaTest.groovy
@@ -975,6 +975,26 @@ class LambdaTest extends GroovyTestCase {
'''
}
+ void testNestedLambdaAccessingInstanceFields() {
+ assertScript '''
+ @groovy.transform.CompileStatic
+ class Test1 {
+ private List<String> strList = ['a', 'e', 'f']
+ private Map<String, List<String>> strListHolder = ['strList': strList]
+ private String b = 'b'
+ def p() {
+ ['abc', 'def', 'ghi'].stream().filter(e -> strList.stream().anyMatch(c -> e.contains(c + b))).toList()
+ }
+ def p2() {
+ ['abc', 'def', 'ghi'].stream().filter(e -> strListHolder.strList.stream().anyMatch(c -> e.contains(c + b))).toList()
+ }
+ }
+
+ assert ['abc'] == new Test1().p()
+ assert ['abc'] == new Test1().p2()
+ '''
+ }
+
void testSerialize() {
assertScript '''
import java.util.function.Function