[groovy] branch master updated: Add one more test to verify GINQ's lazy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[groovy] branch master updated: Add one more test to verify GINQ's lazy

Daniel.Sun
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 3c377a4  Add one more test to verify GINQ's lazy
3c377a4 is described below

commit 3c377a4a7158570efadb3bc03fc7cf25d8bb6ddc
Author: Daniel Sun <[hidden email]>
AuthorDate: Mon Nov 23 01:27:48 2020 +0800

    Add one more test to verify GINQ's lazy
---
 .../test/org/apache/groovy/ginq/GinqTest.groovy    | 24 ++++++++++++++++++++++
 1 file changed, 24 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 3644e64..81f5821 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
@@ -2741,4 +2741,28 @@ class GinqTest {
             assert cnt > 0
         '''
     }
+
+    @Test
+    void "testGinq - lazy - 7"() {
+        assertScript '''
+            int cnt = 0
+            def result = GQ {
+                from n in [1, 2, 3]
+                innerjoin m in [2, 3, 4] on m == n
+                where n > 1 && m < 5 && (
+                    from k in [2, 3, 4, 5]
+                    select k, cnt++
+                ).exists()
+                groupby n, m
+                orderby n in desc, m in asc
+                limit 0, 1
+                select n, m, agg(_g.stream().map(r -> r.n + r.m + cnt++).reduce(BigDecimal.ZERO, BigDecimal::add))
+            }
+            assert 0 == cnt
+            def stream = result.stream()
+            assert 0 == cnt
+            stream.toList()
+            assert cnt > 0
+        '''
+    }
 }

Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun