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 2020/11/25 13:13:04 UTC

[groovy] branch master updated: Tweak tests and add one more test

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 03073c6  Tweak tests and add one more test
03073c6 is described below

commit 03073c655ef34911a5de2854eaad668a06e8084b
Author: Daniel Sun <su...@apache.org>
AuthorDate: Wed Nov 25 21:12:41 2020 +0800

    Tweak tests and add one more test
---
 .../test/org/apache/groovy/ginq/GinqTest.groovy    | 36 +++++++++++++++++-----
 1 file changed, 28 insertions(+), 8 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 71aacdc..803c507 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
@@ -2659,7 +2659,7 @@ class GinqTest {
             assert 0 == cnt
             def stream = result.stream()
             assert 0 == cnt
-            stream.toList()
+            assert [[1, 0], [2, 1], [3, 2]] == stream.toList()
             assert cnt > 0
         '''
     }
@@ -2676,7 +2676,7 @@ class GinqTest {
             assert 0 == cnt
             def stream = result.stream()
             assert 0 == cnt
-            stream.toList()
+            assert [[2, 0], [3, 1]] == stream.toList()
             assert cnt > 0
         '''
     }
@@ -2694,7 +2694,7 @@ class GinqTest {
             assert 0 == cnt
             def stream = result.stream()
             assert 0 == cnt
-            stream.toList()
+            assert [[2, 2, 0], [3, 3, 1]] == stream.toList()
             assert cnt > 0
         '''
     }
@@ -2713,7 +2713,7 @@ class GinqTest {
             assert 0 == cnt
             def stream = result.stream()
             assert 0 == cnt
-            stream.toList()
+            assert [[3, 3, 6], [2, 2, 5]] == stream.toList()
             assert cnt > 0
         '''
     }
@@ -2733,7 +2733,7 @@ class GinqTest {
             assert 0 == cnt
             def stream = result.stream()
             assert 0 == cnt
-            stream.toList()
+            assert [[3, 3, 6], [2, 2, 5]] == stream.toList()
             assert cnt > 0
         '''
     }
@@ -2758,7 +2758,7 @@ class GinqTest {
             assert 0 == cnt
             def stream = result.stream()
             assert 0 == cnt
-            stream.toList()
+            assert [[3, 3, 6], [2, 2, 5]] == stream.toList()
             assert cnt > 0
         '''
     }
@@ -2784,7 +2784,7 @@ class GinqTest {
             assert 0 == cnt
             def stream = result.stream()
             assert 0 == cnt
-            stream.toList()
+            assert [[3, 3, 6]] == stream.toList()
             assert cnt > 0
         '''
     }
@@ -2805,7 +2805,27 @@ class GinqTest {
             assert 0 == cnt
             def stream = result.stream()
             assert 0 == cnt
-            stream.toList()
+            assert [[2, 1], [3, 3]] == stream.toList()
+            assert cnt > 0
+        '''
+    }
+
+    @Test
+    void "testGinq - lazy - 9"() {
+        assertScript '''
+            int cnt = 0
+            def result = GQ {
+                from n in [0, 1, 2, 3, 4, 5]
+                where n in (
+                    from k in [0, 1, 2, 3, 4]
+                    select cnt++ - k
+                )
+                select n, cnt++
+            }
+            assert 0 == cnt
+            def stream = result.stream()
+            assert 0 == cnt
+            assert [[0, 5]] == stream.toList()
             assert cnt > 0
         '''
     }