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 2021/07/19 13:41:43 UTC
[groovy] branch master updated: Add tests for `distinct`
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 6d999a7 Add tests for `distinct`
6d999a7 is described below
commit 6d999a714c9630181e015fba8245ca74bc9482bf
Author: Daniel Sun <su...@apache.org>
AuthorDate: Mon Jul 19 21:32:36 2021 +0800
Add tests for `distinct`
---
.../test/org/apache/groovy/ginq/GinqTest.groovy | 53 ++++++++++++++++++++++
1 file changed, 53 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 8d963a9..228fc08 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
@@ -290,6 +290,59 @@ class GinqTest {
}
@Test
+ void "testGinq - from select distinct - 5"() {
+ assertGinqScript '''
+ def result = GQ {
+ from v in (
+ from n in [1, 2, 2, 3, 3, 3]
+ select distinct(n)
+ )
+ join m in [1, 1, 2, 2, 3, 3] on m == v
+ select distinct(v, m)
+ }
+ assert [[1, 1], [2, 2], [3, 3]] == result.toList()
+ '''
+ }
+
+ @Test
+ void "testGinq - from select distinct - 6"() {
+ assertGinqScript '''
+ def result = GQ {
+ from n in [1, 2, 3, 4]
+ groupby n % 2 as x
+ orderby x
+ select distinct(x, count(x))
+ }
+ assert [[0, 2], [1, 2]] == result.toList()
+ '''
+ }
+
+ @Test
+ void "testGinq - from select distinct - 7"() {
+ assertGinqScript '''
+ def result = GQ {
+ from n in [1, 2, 3, 4]
+ groupby n % 2 as x
+ orderby x
+ select distinct(x)
+ }
+ assert [0, 1] == result.toList()
+ '''
+ }
+
+ @Test
+ void "testGinq - from select distinct - 8"() {
+ assertGinqScript '''
+ def result = GQ {
+ from n in [1, 2, 3, 4]
+ groupby n % 2 as x
+ select distinct(count(x))
+ }
+ assert [2] == result.toList()
+ '''
+ }
+
+ @Test
void "testGinq - from where select - 1"() {
assertGinqScript '''
def numbers = [0, 1, 2, 3, 4, 5]