This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY-8258
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY-8258 by this push:
new cbf4d0d GROOVY-8258: add more test cases
cbf4d0d is described below
commit cbf4d0d7a7e05bf5c4c8414936ccb490c802724e
Author: Daniel Sun <[email protected]>
AuthorDate: Wed Oct 7 01:21:53 2020 +0800
GROOVY-8258: add more test cases
---
.../groovy/org/apache/groovy/linq/GinqTest.groovy | 52 ++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git
a/subprojects/groovy-linq/src/test/groovy/org/apache/groovy/linq/GinqTest.groovy
b/subprojects/groovy-linq/src/test/groovy/org/apache/groovy/linq/GinqTest.groovy
index 87d3a5f..e10301d 100644
---
a/subprojects/groovy-linq/src/test/groovy/org/apache/groovy/linq/GinqTest.groovy
+++
b/subprojects/groovy-linq/src/test/groovy/org/apache/groovy/linq/GinqTest.groovy
@@ -325,4 +325,56 @@ class GinqTest {
}.toList()
'''
}
+
+ @Test
+ void "testGinq - from innerJoin where select - 4"() {
+ assertScript '''
+ class Person {
+ String name
+ int age
+
+ Person(String name, int age) {
+ this.name = name
+ this.age = age
+ }
+ }
+
+ def persons1 = [new Person('Daniel', 35), new Person('Linda', 21),
new Person('David', 30)]
+ def persons2 = [new Person('Jack', 35), new Person('Rose', 21),
new Person('Smith', 30)]
+ assert [['Daniel', 'Jack']] == GINQ {
+ from p1 in persons1
+ innerJoin p2 in persons2
+ on p1.age == p2.age
+ where p1.name.startsWith('D') && p2.name.endsWith('k')
+ select p1.name, p2.name
+ }.toList()
+ '''
+ }
+
+ @Test
+ void "testGinq - from innerJoin where select - 5"() {
+ assertScript '''
+ class Person {
+ String name
+ int age
+
+ Person(String name, int age) {
+ this.name = name
+ this.age = age
+ }
+ }
+
+ def same(obj) {obj}
+
+ def persons1 = [new Person('Daniel', 35), new Person('Linda', 21),
new Person('David', 30)]
+ def persons2 = [new Person('Jack', 35), new Person('Rose', 21),
new Person('Smith', 30)]
+ assert [['Daniel', 'Jack']] == GINQ {
+ from p1 in persons1
+ innerJoin p2 in persons2
+ on p1.age == p2.age
+ where same(p1.name.startsWith('D')) &&
same(p2.name.endsWith('k'))
+ select p1.name, p2.name
+ }.toList()
+ '''
+ }
}