You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2023/05/01 20:09:07 UTC

[groovy] branch GROOVY_3_0_X updated: GROOVY-11024: STC: add test case

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
     new d939c7cd7a GROOVY-11024: STC: add test case
d939c7cd7a is described below

commit d939c7cd7a9bad649ecebae04deede05f268dc84
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Mon May 1 13:05:37 2023 -0500

    GROOVY-11024: STC: add test case
---
 .../transform/stc/MethodReferenceTest.groovy       | 28 ++++++++++++++++------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/test/groovy/transform/stc/MethodReferenceTest.groovy b/src/test/groovy/transform/stc/MethodReferenceTest.groovy
index 3340306b06..6dce2f7ea7 100644
--- a/src/test/groovy/transform/stc/MethodReferenceTest.groovy
+++ b/src/test/groovy/transform/stc/MethodReferenceTest.groovy
@@ -24,6 +24,7 @@ import org.junit.Test
 import static groovy.test.GroovyAssert.assertScript
 import static groovy.test.GroovyAssert.isAtLeastJdk
 import static groovy.test.GroovyAssert.shouldFail
+import static org.junit.Assume.assumeTrue
 
 final class MethodReferenceTest {
 
@@ -720,7 +721,7 @@ final class MethodReferenceTest {
             void test() {
                 IntFunction<Integer[]> f = Integer[]::new;
                 def result = [1, 2, 3].stream().toArray(f)
-                result == new Integer[] {1, 2, 3}
+                assert result == new Integer[] {1, 2, 3}
             }
 
             test()
@@ -733,7 +734,7 @@ final class MethodReferenceTest {
             @CompileStatic
             void test() {
                 def result = [1, -2, 3].stream().map(Math::abs).collect(Collectors.toList())
-                assert [1, 2, 3] == result
+                assert result == [1, 2, 3]
             }
 
             test()
@@ -744,13 +745,26 @@ final class MethodReferenceTest {
     void testFunctionCS2() {
         assertScript imports + '''
             @CompileStatic
-            void test() {
-                List<String> list = ['x','y','z']
-                def map = list.stream().collect(Collectors.toMap(Function.identity(), Collections::singletonList))
-                assert map == [x: ['x'], y: ['y'], z: ['z']]
+            def test(List<String> list) {
+                list.stream().collect(Collectors.toMap(Function.identity(), Collections::singletonList))
             }
 
-            test()
+            assert test(['x','y','z']) == [x: ['x'], y: ['y'], z: ['z']]
+        '''
+    }
+
+    @NotYetImplemented
+    @Test // class::staticMethod -- GROOVY-11024
+    void testFunctionCS2x() {
+        assumeTrue(isAtLeastJdk('9.0'))
+
+        assertScript imports + '''
+            @CompileStatic
+            def test(List<String> list) {
+                list.stream().collect(Collectors.toMap(Function.identity(), List::of))
+            }
+
+            assert test(['x','y','z']) == [x: ['x'], y: ['y'], z: ['z']]
         '''
     }