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 2023/01/04 20:23:28 UTC
[groovy] branch master updated: GROOVY-10887: add test case
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 dc9ab04970 GROOVY-10887: add test case
dc9ab04970 is described below
commit dc9ab04970b49fdc52b7e1387f37f033dec7c1e1
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Wed Jan 4 14:08:30 2023 -0600
GROOVY-10887: add test case
---
.../groovy/transform/stc/GenericsSTCTest.groovy | 19 ++++++++++
.../transform/stc/STCExtensionMethodsTest.groovy | 41 +++++++++++-----------
2 files changed, 40 insertions(+), 20 deletions(-)
diff --git a/src/test/groovy/transform/stc/GenericsSTCTest.groovy b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
index 9ea596a5f7..7f0fb0978b 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -5100,6 +5100,25 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
'''
}
+ // GROOVY-10887
+ void testSelfReferentialTypeParameter6() {
+ assertScript '''
+ @Grab('org.springframework.integration:spring-integration-groovy:5.5.15')
+ import org.springframework.integration.channel.AbstractMessageChannel
+ import org.springframework.integration.dsl.MessageChannelSpec
+ import org.springframework.integration.dsl.MessageChannels
+ @Grab('org.springframework:spring-messaging:5.3.24')
+ import org.springframework.messaging.MessageChannel
+
+ def <AMC extends AbstractMessageChannel, MCS extends MessageChannelSpec<MCS,AMC>> MCS mark(MCS self) {
+ self.interceptor(null) // returns self
+ }
+ MessageChannel make() {
+ mark(MessageChannels.publishSubscribe(true).minSubscribers(2)).get()
+ }
+ '''
+ }
+
// GROOVY-7804
void testParameterlessClosureToGenericSAMTypeArgumentCoercion() {
assertScript '''
diff --git a/src/test/groovy/transform/stc/STCExtensionMethodsTest.groovy b/src/test/groovy/transform/stc/STCExtensionMethodsTest.groovy
index 3254e09df1..5dd70e9e9b 100644
--- a/src/test/groovy/transform/stc/STCExtensionMethodsTest.groovy
+++ b/src/test/groovy/transform/stc/STCExtensionMethodsTest.groovy
@@ -53,26 +53,27 @@ class STCExtensionMethodsTest extends StaticTypeCheckingTestCase {
def impl = new MetaClassImpl(String)
impl.initialize()
String.metaClass = impl
- ExtensionModuleRegistry registry = GroovySystem.metaClassRegistry.moduleRegistry
- // ensure that the module isn't loaded
- assert !registry.modules.any { it.name == 'Test module for Grab' && it.version == '1.3' }
-
- // find jar resource
- def jarURL = this.class.getResource('/jars')
- assert jarURL
-
- def resolver = "@GrabResolver(name='local',root='$jarURL')"
-
- assertScript resolver + """
- @Grab('module-test:module-test:1.4')
- import org.codehaus.groovy.runtime.m12n.*
-
- // the following methods are added by the Grab test module
- def str = 'This is a string'
- assert str.reverseToUpperCase2() == str.toUpperCase().reverse()
- // a static method added to String thanks to a @Grab extension
- assert String.answer2() == 42
- """
+ try {
+ ExtensionModuleRegistry registry = GroovySystem.metaClassRegistry.moduleRegistry
+ // ensure that the module isn't loaded
+ assert !registry.modules.any { it.name == 'Test module for Grab' && it.version == '1.4' }
+
+ def jarURL = this.class.getResource('/jars')
+ assert jarURL
+
+ assertScript """@GrabResolver(name='local',root='$jarURL')
+ @Grab('module-test:module-test:1.4;changing=true')
+ import org.codehaus.groovy.runtime.m12n.*
+
+ // the following methods are added by the Grab test module
+ def str = 'This is a string'
+ assert str.reverseToUpperCase2() == str.toUpperCase().reverse()
+ // a static method added to String thanks to a @Grab extension
+ assert String.answer2() == 42
+ """
+ } finally {
+ String.metaClass = null
+ }
'''
}