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 2022/06/26 16:31:40 UTC
[groovy] branch master updated: Add 2 more test cases 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 4aad1632f4 Add 2 more test cases for lambda
4aad1632f4 is described below
commit 4aad1632f467bd67cca6b4608eec83cc3f4a1858
Author: Daniel Sun <su...@apache.org>
AuthorDate: Mon Jun 27 00:19:01 2022 +0800
Add 2 more test cases for lambda
---
src/test/groovy/transform/stc/LambdaTest.groovy | 32 +++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/src/test/groovy/transform/stc/LambdaTest.groovy b/src/test/groovy/transform/stc/LambdaTest.groovy
index a0165db6a7..fab0a303f4 100644
--- a/src/test/groovy/transform/stc/LambdaTest.groovy
+++ b/src/test/groovy/transform/stc/LambdaTest.groovy
@@ -309,6 +309,38 @@ final class LambdaTest {
'''
}
+ @Test
+ void testCollectors1() {
+ assertScript '''
+ import groovy.transform.CompileStatic
+ import java.util.stream.Collectors
+
+ @CompileStatic
+ def test() {
+ Set<String> set = ['a', 'b', 'c'] as Set
+ assert [a: 'a', b: 'b', c: 'c'] == set.stream().collect(Collectors.toMap(e -> e, e -> e))
+ }
+
+ test()
+ '''
+ }
+
+ @Test
+ void testCollectors2() {
+ assertScript '''
+ import groovy.transform.CompileStatic
+ import java.util.stream.Collectors
+
+ @CompileStatic
+ def test() {
+ Set<String> set = ['a', 'b', 'c'] as Set
+ assert [a: 'a', b: 'b', c: 'c'] == set.stream().collect(Collectors.toMap(e -> e, e -> e, (o1, o2) -> o2))
+ }
+
+ test()
+ '''
+ }
+
@Test
void testFunctionWithLocalVariables() {
assertScript '''