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 2025/06/08 06:38:46 UTC
(groovy) 02/02: Add `switch` test cases for GINQ
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit bfc91459aeb48c7b14574bbc183b9dc3edc5d337
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Jun 7 14:33:05 2025 +0900
Add `switch` test cases for GINQ
(cherry picked from commit 3707260f51b65568111e70929fc82792a6b37395)
---
.../src/spec/test/org/apache/groovy/ginq/GinqTest.groovy | 15 +++++++++++++++
1 file changed, 15 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 7ca916932f..dad032f2c6 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
@@ -6346,6 +6346,21 @@ class GinqTest {
'''
}
+ @Test
+ void "testGinq - switch - 5"() {
+ assertGinqScript '''
+ assert [[1, 3], [3, 1]] == GQ {
+ from n in [1, 1, 3, 4]
+ groupby switch (n) {
+ case 4 -> 1
+ default -> n
+ } as g
+ orderby g
+ select g, count()
+ }.toList()
+ '''
+ }
+
@Test
void "testGinqMethod - GQ - 0"() {
assertScript '''