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 ae15450  Add more tests
ae15450 is described below

commit ae154509c6cd371d1a642b9738e4c6f7e2d22e5f
Author: Daniel Sun <[email protected]>
AuthorDate: Sat Nov 28 15:22:50 2020 +0800

    Add more tests
---
 .../test/org/apache/groovy/ginq/GinqTest.groovy    | 27 +++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

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 12e488e..c0b8955 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
@@ -3007,9 +3007,10 @@ class GinqTest {
     void "testGinq - agg function - 1"() {
         assertScript '''
 // tag::ginq_aggfunction_01[]
-            assert [[1, 3, 2, 3, 3]] == GQ {
+            assert [[1, 3, 2, 6, 3, 3, 6]] == GQ {
                 from n in [1, 2, 3]
-                select min(n), max(n), avg(n), count(n), count()
+                select min(n), max(n), avg(n), sum(n), count(n), count(), 
+                        agg(_g.stream().map(r -> r.n).reduce(BigDecimal.ZERO, 
BigDecimal::add))
             }.toList()
 // end::ginq_aggfunction_01[]
         '''
@@ -3050,6 +3051,16 @@ class GinqTest {
     @Test
     void "testGinq - agg function - 5"() {
         assertScript '''
+            assert [6] == GQ {
+                from n in [1, 2, 3]
+                select sum(n)
+            }.toList()
+        '''
+    }
+
+    @Test
+    void "testGinq - agg function - 6"() {
+        assertScript '''
             assert [3] == GQ {
                 from n in [1, 2, 3]
                 select count(n)
@@ -3058,7 +3069,7 @@ class GinqTest {
     }
 
     @Test
-    void "testGinq - agg function - 6"() {
+    void "testGinq - agg function - 7"() {
         assertScript '''
             assert [3] == GQ {
                 from n in [1, 2, 3]
@@ -3066,4 +3077,14 @@ class GinqTest {
             }.toList()
         '''
     }
+
+    @Test
+    void "testGinq - agg function - 8"() {
+        assertScript '''
+            assert [6] == GQ {
+                from n in [1, 2, 3]
+                select agg(_g.stream().map(r -> r.n).reduce(BigDecimal.ZERO, 
BigDecimal::add))
+            }.toList()
+        '''
+    }
 }

Reply via email to