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 0e89696ef0 GROOVY-11915: add more test cases
0e89696ef0 is described below
commit 0e89696ef074daa1d8ce113548a2b4af2dec41c2
Author: Daniel Sun <[email protected]>
AuthorDate: Sun Apr 12 00:45:30 2026 +0900
GROOVY-11915: add more test cases
---
.../test/org/apache/groovy/ginq/GinqTest.groovy | 60 +++++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
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 aab1a872bc..d27bcd8e53 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
@@ -3502,6 +3502,28 @@ class GinqTest {
'''
}
+ @Test
+ void "testGinq - from groupby into select - 4"() {
+ assertGinqScript '''
+ assert [[1, 2], [3, 6], [6, 18]] == GQ {
+ from n in [1, 1, 3, 3, 6, 6, 6]
+ groupby n into g
+ select g.n, g.sum(n -> n)
+ }.toList()
+ '''
+ }
+
+ @Test
+ void "testGinq - from groupby into select - 5"() {
+ assertGinqScript '''
+ assert [[1, 2], [3, 6], [6, 18]] == GQ {
+ from n in [1, 1, 3, 3, 6, 6, 6]
+ groupby n as m into g
+ select g.m, g.sum(m -> m)
+ }.toList()
+ '''
+ }
+
@Test
void "testGinq - from groupby into having select - 1"() {
assertGinqScript '''
@@ -3515,7 +3537,7 @@ class GinqTest {
}
@Test
- void "testGinq - from groupby into select - multi-key with property
access"() {
+ void "testGinq - from groupby into select - multi-key with property access
- 1"() {
assertGinqScript '''
def result = GQ {
from n in [[name: 'a', val: 1], [name: 'b', val: 2]]
@@ -3526,6 +3548,42 @@ class GinqTest {
'''
}
+ @Test
+ void "testGinq - from groupby into select - multi-key with property access
- 2"() {
+ assertGinqScript '''
+ def result = GQ {
+ from n in [[name: 'a', val: 1], [name: 'b', val: 2]]
+ groupby n.name, n.val as val into g
+ select g.name, g.val, g.count()
+ }.toList().collect { it.toList() }.sort()
+ assert result == [['a', 1, 1], ['b', 2, 1]]
+ '''
+ }
+
+ @Test
+ void "testGinq - from groupby into select - multi-key with property access
- 3"() {
+ assertGinqScript '''
+ def result = GQ {
+ from n in [[name: 'a', val: 1], [name: 'b', val: 2]]
+ groupby n.name as name, n.val into g
+ select g.name, g.val, g.count()
+ }.toList().collect { it.toList() }.sort()
+ assert result == [['a', 1, 1], ['b', 2, 1]]
+ '''
+ }
+
+ @Test
+ void "testGinq - from groupby into select - multi-key with property access
- 4"() {
+ assertGinqScript '''
+ def result = GQ {
+ from n in [[name: 'a', val: 1], [name: 'b', val: 2]]
+ groupby n.name, n.val into g
+ select g.name, g.val, g.count()
+ }.toList().collect { it.toList() }.sort()
+ assert result == [['a', 1, 1], ['b', 2, 1]]
+ '''
+ }
+
@Test
void "testGinq - from groupby into select - multi-key with subscript"() {
assertGinqScript '''