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 a584e00934 Add `switch` test cases for GINQ
a584e00934 is described below

commit a584e0093467dd49e3908b4cdc57121ac944052d
Author: Daniel Sun <sun...@apache.org>
AuthorDate: Sat Jun 7 12:17:07 2025 +0900

    Add `switch` test cases for GINQ
---
 .../test/org/apache/groovy/ginq/GinqTest.groovy    | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git 
a/subprojects/groovy-ginq/src/spec/test/org/apache/groovy/ginq/GinqTest.groovy 
b/subprojects/groovy-ginq/src/spec/test/org/apache/groovy/ginq/GinqTest.groovy
index d22bc5e67b..7ca916932f 100644
--- 
a/subprojects/groovy-ginq/src/spec/test/org/apache/groovy/ginq/GinqTest.groovy
+++ 
b/subprojects/groovy-ginq/src/spec/test/org/apache/groovy/ginq/GinqTest.groovy
@@ -6304,6 +6304,48 @@ class GinqTest {
         '''
     }
 
+    @Test
+    void "testGinq - switch - 2"() {
+        assertGinqScript '''
+            assert [4, 1, 2, 3] == GQ {
+                from n in [1, 2, 3, 4]
+                orderby switch (n) {
+                    case 4 -> 0
+                    default -> n
+                }
+                select n
+            }.toList()
+        '''
+    }
+
+    @Test
+    void "testGinq - switch - 3"() {
+        assertGinqScript '''
+            assert [[1, 2], [2, 1], [3, 1]] == GQ {
+                from n in [1, 2, 3, 4]
+                groupby switch (n) {
+                    case 4 -> 1
+                    default -> n
+                } as g
+                select g, count()
+            }.toList()
+        '''
+    }
+
+    @Test
+    void "testGinq - switch - 4"() {
+        assertGinqScript '''
+            assert [2, 3] == GQ {
+                from n in [1, 2, 3, 4]
+                where switch (n) {
+                    case 4 -> 1
+                    default -> n
+                } > 1
+                select n
+            }.toList()
+        '''
+    }
+
     @Test
     void "testGinqMethod - GQ - 0"() {
         assertScript '''

Reply via email to