You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2021/04/26 03:20:55 UTC
[groovy] branch master updated: GROOVY-5893: add test cases
This is an automated email from the ASF dual-hosted git repository.
emilles 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 6935e1a GROOVY-5893: add test cases
6935e1a is described below
commit 6935e1a79cec79229b431f12dc5449bf0f8ad864
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sun Apr 25 22:20:31 2021 -0500
GROOVY-5893: add test cases
re-organize some test cases
---
.../groovy/transform/stc/GenericsSTCTest.groovy | 33 +++++------
src/test/groovy/transform/stc/LambdaTest.groovy | 66 +++++++++++-----------
2 files changed, 47 insertions(+), 52 deletions(-)
diff --git a/src/test/groovy/transform/stc/GenericsSTCTest.groovy b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
index 386de4e..80cf7ad 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -2148,29 +2148,24 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
}
// GROOVY-5893
- @NotYetImplemented
void testPlusInClosure() {
- assertScript '''
- def list = [1, 2, 3]
+ ['def', 'var', 'Object', 'Number', 'Integer', 'Comparable'].each { type ->
+ assertScript """
+ List<Integer> list = [1, 2, 3]
- @ASTTest(phase=INSTRUCTION_SELECTION,value={
- assert node.getNodeMetaData(INFERRED_TYPE) == int_TYPE
- })
- def sum = 0
- list.each { int i -> sum = sum+i }
- assert sum == 6
+ int sum = 0
+ list.each { int i -> sum = sum + i }
+ assert sum == 6
- sum = 0
- list.each { int i -> sum += i }
- assert sum == 6
+ sum = 0
+ list.each { int i -> sum += i }
+ assert sum == 6
- @ASTTest(phase=INSTRUCTION_SELECTION, value={
- assert node.getNodeMetaData(INFERRED_TYPE) == Integer_TYPE
- })
- def sumWithInject = list.inject(0, { int x, int y -> x + y })
- sum = sumWithInject
- assert sum == 6
- '''
+ $type sumWithInject = list.inject(0, { int x, int y -> x + y })
+ // ^^^^^^^^^^^^^ T ^^^^ E[] ^ U ^ U ^ E ^^^^^ V
+ assert sumWithInject == 6
+ """
+ }
}
void testShouldNotCreateStackOverflow() {
diff --git a/src/test/groovy/transform/stc/LambdaTest.groovy b/src/test/groovy/transform/stc/LambdaTest.groovy
index 093ad64..e1b8f2b 100644
--- a/src/test/groovy/transform/stc/LambdaTest.groovy
+++ b/src/test/groovy/transform/stc/LambdaTest.groovy
@@ -176,39 +176,6 @@ final class LambdaTest {
}
@Test
- void testConsumer() {
- assertScript '''
- @groovy.transform.CompileStatic
- class Test1 {
- static main(args) {
- p()
- }
-
- static void p() {
- [1, 2, 3].stream().forEach(e -> { System.out.println(e + 1); })
- }
- }
- '''
- }
-
- @Test // GROOVY-9340
- void testConsumerWithSelfType() {
- assertScript '''
- @groovy.transform.CompileStatic
- class Test1 {
- static main(args) {
- p()
- }
-
- static void p() {
- java.util.function.Consumer<Test1> c = t -> null
- c.accept(this.newInstance())
- }
- }
- '''
- }
-
- @Test
void testPredicate() {
assertScript '''
import groovy.transform.CompileStatic
@@ -822,6 +789,39 @@ final class LambdaTest {
'''
}
+ @Test // GROOVY-9340
+ void testConsumer8() {
+ assertScript '''
+ @groovy.transform.CompileStatic
+ class Test1 {
+ static main(args) {
+ p()
+ }
+
+ static void p() {
+ java.util.function.Consumer<Test1> c = t -> null
+ c.accept(this.newInstance())
+ }
+ }
+ '''
+ }
+
+ @Test
+ void testConsumer9() {
+ assertScript '''
+ @groovy.transform.CompileStatic
+ class Test1 {
+ static main(args) {
+ p()
+ }
+
+ static void p() {
+ [1, 2, 3].stream().forEach(e -> { System.out.println(e + 1); })
+ }
+ }
+ '''
+ }
+
@Test
void testFunctionalInterface1() {
assertScript '''