This is an automated email from the ASF dual-hosted git repository.
paulk 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 5aa4a0edd7 minor refactor: junit5 changes (tests weren't running)
5aa4a0edd7 is described below
commit 5aa4a0edd78357045b9e20591b4557a81fd40c61
Author: Paul King <[email protected]>
AuthorDate: Sat Apr 4 17:09:35 2026 +1000
minor refactor: junit5 changes (tests weren't running)
---
src/test/groovy/bugs/Groovy4116Bug.groovy | 4 ++++
src/test/groovy/bugs/Groovy5396Bug.groovy | 3 +++
src/test/groovy/bugs/Groovy6722Bug.groovy | 3 +++
src/test/groovy/bugs/Groovy7520Bug.groovy | 3 +++
.../AnnotationClosureExhaustiveTestSupport.groovy | 6 ++++++
src/test/groovy/gls/syntax/Gep3OrderDslTest.groovy | 2 ++
src/test/groovy/groovy/lang/GroovyShellTest2.groovy | 6 ++++++
src/test/groovy/groovy/lang/MapOfClosureTest.groovy | 10 ++++++++++
.../groovy/lang/ReferenceSerializationTest.groovy | 6 ++++++
.../groovy/groovy/util/ProxyGeneratorAdapterTest.groovy | 17 +++++++++++++++++
src/test/groovy/groovy/util/ProxyGeneratorTest.groovy | 17 +++++++++++++++++
.../org/codehaus/groovy/classgen/GenericsGenTest.groovy | 2 ++
.../runtime/memoize/AbstractMemoizeTestCase.groovy | 8 ++++++++
.../groovy/runtime/memoize/MemoizeAtLeastTest.groovy | 4 ++++
.../groovy/runtime/memoize/MemoizeAtMostTest.groovy | 5 +++++
.../groovy/runtime/memoize/MemoizeBetweenTest.groovy | 6 ++++++
.../codehaus/groovy/runtime/memoize/MemoizeTest.groovy | 9 +++++++++
17 files changed, 111 insertions(+)
diff --git a/src/test/groovy/bugs/Groovy4116Bug.groovy
b/src/test/groovy/bugs/Groovy4116Bug.groovy
index c090656f33..e99e400b2e 100644
--- a/src/test/groovy/bugs/Groovy4116Bug.groovy
+++ b/src/test/groovy/bugs/Groovy4116Bug.groovy
@@ -20,10 +20,13 @@ package bugs
import org.codehaus.groovy.control.MultipleCompilationErrorsException
+import org.junit.jupiter.api.Test
+
import static groovy.test.GroovyAssert.shouldFail
final class Groovy4116Bug {
+ @Test
void testAnInterfaceMethodNotImplementedPublic() {
def err = shouldFail MultipleCompilationErrorsException, '''
class C4116 implements I4116 {
@@ -36,6 +39,7 @@ final class Groovy4116Bug {
assert err.message =~ /The method foo should be public as it
implements the corresponding method from interface I4116/
}
+ @Test
void testAnInterfaceMethodNotImplementedPublicV2SuperClassInterface() {
def err = shouldFail MultipleCompilationErrorsException, '''
abstract class A4116 implements I4116 {
diff --git a/src/test/groovy/bugs/Groovy5396Bug.groovy
b/src/test/groovy/bugs/Groovy5396Bug.groovy
index b435d922ad..7e781b7651 100644
--- a/src/test/groovy/bugs/Groovy5396Bug.groovy
+++ b/src/test/groovy/bugs/Groovy5396Bug.groovy
@@ -19,10 +19,13 @@
package bugs
+import org.junit.jupiter.api.Test
+
import static groovy.test.GroovyAssert.assertScript
class Groovy5396Bug {
+ @Test
void testClassAccessToPackageLocalPropertyInSuper() {
assertScript """
class GroovyBase extends AbstractBase {
diff --git a/src/test/groovy/bugs/Groovy6722Bug.groovy
b/src/test/groovy/bugs/Groovy6722Bug.groovy
index 9a6c10bcb7..96d3ac0855 100644
--- a/src/test/groovy/bugs/Groovy6722Bug.groovy
+++ b/src/test/groovy/bugs/Groovy6722Bug.groovy
@@ -19,10 +19,13 @@
package bugs
+import org.junit.jupiter.api.Test
+
import static groovy.test.GroovyAssert.assertScript
class Groovy6722Bug {
+ @Test
void testThatCompilerRecognizesCovariantArray() {
assertScript '''
abstract class Top<Elem,Result> {
diff --git a/src/test/groovy/bugs/Groovy7520Bug.groovy
b/src/test/groovy/bugs/Groovy7520Bug.groovy
index 21beaf583a..c778a204bc 100644
--- a/src/test/groovy/bugs/Groovy7520Bug.groovy
+++ b/src/test/groovy/bugs/Groovy7520Bug.groovy
@@ -19,10 +19,13 @@
package bugs
+import org.junit.jupiter.api.Test
+
import static groovy.test.GroovyAssert.shouldFail
class Groovy7520Bug {
+ @Test
void testShouldSeeConflictUsingAbstractMethod() {
def msg = shouldFail '''
abstract class DefinesMethod {
diff --git
a/src/test/groovy/gls/annotations/closures/AnnotationClosureExhaustiveTestSupport.groovy
b/src/test/groovy/gls/annotations/closures/AnnotationClosureExhaustiveTestSupport.groovy
index 88d6dd092f..ac65b9e3fa 100644
---
a/src/test/groovy/gls/annotations/closures/AnnotationClosureExhaustiveTestSupport.groovy
+++
b/src/test/groovy/gls/annotations/closures/AnnotationClosureExhaustiveTestSupport.groovy
@@ -18,6 +18,8 @@
*/
package gls.annotations.closures
+import org.junit.jupiter.api.Test
+
abstract class AnnotationClosureExhaustiveTestSupport {
abstract Class getAnnotationClass()
@@ -25,18 +27,22 @@ abstract class AnnotationClosureExhaustiveTestSupport {
abstract void verify(Class closureClass)
+ @Test
void testWorksOnClassLevel() {
worksOn(annotatedClass)
}
+ @Test
void testWorksOnMethodLevel() {
worksOn(annotatedClass.getDeclaredMethod("aMethod", Object))
}
+ @Test
void testWorksOnFieldLevel() {
worksOn(annotatedClass.getDeclaredField("aField"))
}
+ @Test
void testWorksOnPropertyLevel() {
worksOn(annotatedClass.getDeclaredField("aProperty"))
}
diff --git a/src/test/groovy/gls/syntax/Gep3OrderDslTest.groovy
b/src/test/groovy/gls/syntax/Gep3OrderDslTest.groovy
index 8b5708d4f4..1d6f3738b1 100644
--- a/src/test/groovy/gls/syntax/Gep3OrderDslTest.groovy
+++ b/src/test/groovy/gls/syntax/Gep3OrderDslTest.groovy
@@ -21,6 +21,7 @@ package gls.syntax
import org.codehaus.groovy.control.CompilerConfiguration
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
+import org.junit.jupiter.api.Test
class Gep3OrderDslTest {
@BeforeEach
@@ -37,6 +38,7 @@ class Gep3OrderDslTest {
}
+ @Test
void testDsl() {
// use the script binding for silent sentence words like "to", "the"
def binding = new CustomBinding()
diff --git a/src/test/groovy/groovy/lang/GroovyShellTest2.groovy
b/src/test/groovy/groovy/lang/GroovyShellTest2.groovy
index ef2b9df845..5eedd2c066 100644
--- a/src/test/groovy/groovy/lang/GroovyShellTest2.groovy
+++ b/src/test/groovy/groovy/lang/GroovyShellTest2.groovy
@@ -18,7 +18,10 @@
*/
package groovy.lang
+import org.junit.jupiter.api.Test
+
class GroovyShellTest2 {
+ @Test
void testBindingsInBaseScriptInitializers() {
def shell = new GroovyShell();
def scriptText = '''
@@ -40,6 +43,7 @@ class GroovyShellTest2 {
assert result == arg0
}
+ @Test
void testBindingsInScriptFieldInitializers() {
def shell = new GroovyShell();
def scriptText = '''
@@ -54,6 +58,7 @@ class GroovyShellTest2 {
assert result == arg0
}
+ @Test
void testEvalBindingsInBaseScriptInitializers() {
def context = new Binding()
def arg0 = 'Hello Groovy Eval'
@@ -76,6 +81,7 @@ class GroovyShellTest2 {
assert result == arg0
}
+ @Test
void testEvalBindingsInScriptFieldInitializers() {
def context = new Binding()
def arg0 = 'Rehi Groovy Eval'
diff --git a/src/test/groovy/groovy/lang/MapOfClosureTest.groovy
b/src/test/groovy/groovy/lang/MapOfClosureTest.groovy
index 117e86900e..7685d966f2 100644
--- a/src/test/groovy/groovy/lang/MapOfClosureTest.groovy
+++ b/src/test/groovy/groovy/lang/MapOfClosureTest.groovy
@@ -19,13 +19,17 @@
package groovy.lang
+import org.junit.jupiter.api.Test
+
import static groovy.test.GroovyAssert.shouldFail
+import static org.junit.jupiter.api.Assertions.assertEquals
/**
* Tests maps of closures coerced to classes by asType()
*/
class MapOfClosureTest {
+ @Test
void testInterfaceProxy() {
def outer = 1
def x = [run: { outer++ }] as Runnable
@@ -35,6 +39,7 @@ class MapOfClosureTest {
assert outer == 2
}
+ @Test
void testInterfaceProxyWithoutAllMethods() {
def proxy = [methodOne: { 'some string' }] as MultiMethodInterface
@@ -47,6 +52,7 @@ class MapOfClosureTest {
}
}
+ @Test
void testObject() {
def m = [bar: { "foo" }]
def x = m as Object
@@ -55,6 +61,7 @@ class MapOfClosureTest {
assert "foo" == x.bar()
}
+ @Test
void testAbstractClassSubclassing() {
def outer = 1
def x = [run: { outer++ }] as TimerTask
@@ -66,6 +73,7 @@ class MapOfClosureTest {
/**
* Checks public and protected methods from parents can also be overridden
by the Map coercion to classes.
*/
+ @Test
void testOverrideProtectedMethods() {
def b = [pub: { "map pub" }, prot: { "map prot" }, child: { "map
child" }] as B
@@ -78,6 +86,7 @@ class MapOfClosureTest {
/**
* Checks that abstract methods can also be overridden.
*/
+ @Test
void testAbstractMethodIsOverrided() {
def a = [abstractMethod: { "map abstract" }] as A
@@ -87,6 +96,7 @@ class MapOfClosureTest {
/**
* Verify that complex method signatures, even with primitive types and
arrays, can be overridden.
*/
+ @Test
void testComplexMethodSignature() {
def c = [foo: { int a, List b, Double[] c -> ["map foo"] as String[]
}] as C
diff --git a/src/test/groovy/groovy/lang/ReferenceSerializationTest.groovy
b/src/test/groovy/groovy/lang/ReferenceSerializationTest.groovy
index 9df09b4c65..485b140003 100644
--- a/src/test/groovy/groovy/lang/ReferenceSerializationTest.groovy
+++ b/src/test/groovy/groovy/lang/ReferenceSerializationTest.groovy
@@ -17,6 +17,9 @@
* under the License.
*/
package groovy.lang
+
+import org.junit.jupiter.api.Test
+
/**
* GROOVY-4305: Make groovy.lang.Reference implement Serializable
*/
@@ -40,6 +43,7 @@ class ReferenceSerializationTest implements Serializable {
return ois.readObject()
}
+ @Test
void testSimplePogoSerializationToObjectOutputStream() {
int age = 33
String name = "Guillaume"
@@ -54,6 +58,7 @@ class ReferenceSerializationTest implements Serializable {
assert personDeserialized.pet.kind == "cat"
}
+ @Test
void testClosureSerializationWithAReferenceToALocalVariable() {
int number = 2
def doubler = { it * number }
@@ -64,6 +69,7 @@ class ReferenceSerializationTest implements Serializable {
assert closure(3) == 6
}
+ @Test
void testAICReferencingLocalVariableTest() {
long count = 0
def button = new Button()
diff --git a/src/test/groovy/groovy/util/ProxyGeneratorAdapterTest.groovy
b/src/test/groovy/groovy/util/ProxyGeneratorAdapterTest.groovy
index 10b4295304..73830e1f2d 100644
--- a/src/test/groovy/groovy/util/ProxyGeneratorAdapterTest.groovy
+++ b/src/test/groovy/groovy/util/ProxyGeneratorAdapterTest.groovy
@@ -19,10 +19,12 @@
package groovy.util
import org.codehaus.groovy.runtime.ProxyGeneratorAdapter
+import org.junit.jupiter.api.Test
import static groovy.test.GroovyAssert.assertScript
class ProxyGeneratorAdapterTest {
+ @Test
void testShouldCreateProxy() {
def map = ['toString': { 'HELLO' }]
ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, Object,
null, this.class.classLoader, false, null)
@@ -31,11 +33,13 @@ class ProxyGeneratorAdapterTest {
assert obj.toString() == 'HELLO'
}
+ @Test
void testShouldCreateProxyWithArrayDelegate() {
def adapter = new ProxyGeneratorAdapter([:], Map$Entry, [Map$Entry] as
Class[], null, false, String[])
assert adapter.proxyName() =~ /String_array\d+_groovyProxy/
}
+ @Test
void testImplementSingleAbstractMethod() {
def map = ['m': { 'HELLO' }]
ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, Foo,
null, this.class.classLoader, false, null)
@@ -45,6 +49,7 @@ class ProxyGeneratorAdapterTest {
assert obj.m() == 'HELLO'
}
+ @Test
void testImplementSingleAbstractMethodReturningVoid() {
def map = ['bar': { println 'HELLO' }]
ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, Bar,
null, this.class.classLoader, false, null)
@@ -54,6 +59,7 @@ class ProxyGeneratorAdapterTest {
obj.bar()
}
+ @Test
void testImplementSingleAbstractMethodReturningVoidAndSharedVariable() {
def x = null
def map = ['bar': { x = 'HELLO' }]
@@ -66,6 +72,7 @@ class ProxyGeneratorAdapterTest {
assert x == 'HELLO'
}
+ @Test
void testImplementMethodFromInterface() {
def map = ['foo': { 'HELLO' }]
ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, Object,
[FooInterface] as Class[], this.class.classLoader, false, null)
@@ -75,6 +82,7 @@ class ProxyGeneratorAdapterTest {
assert obj.foo() == 'HELLO'
}
+ @Test
void testImplementMethodFromInterfaceUsingInterfaceAsSuperClass() {
def map = ['foo': { 'HELLO' }]
ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map,
FooInterface, null, this.class.classLoader, false, null)
@@ -84,6 +92,7 @@ class ProxyGeneratorAdapterTest {
assert obj.foo() == 'HELLO'
}
+ @Test
void testImplementMethodFromInterfaceAndSuperClass() {
def x = null
def map = ['foo': { 'HELLO' }, 'bar': { x='WORLD'} ]
@@ -98,6 +107,7 @@ class ProxyGeneratorAdapterTest {
assert x == 'WORLD'
}
+ @Test
void testImplementMethodFromInterfaceWithPrimitiveTypes() {
def map = ['calc': { x -> x*2 } ]
ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, Bar,
[OtherInterface] as Class[], this.class.classLoader, false, null)
@@ -107,6 +117,7 @@ class ProxyGeneratorAdapterTest {
assert obj.calc(3) == 6
}
+ @Test
void testWildcardProxy() {
def map = ['*': { '1' } ]
ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, Foo,
null, this.class.classLoader, false, null)
@@ -116,6 +127,7 @@ class ProxyGeneratorAdapterTest {
assert obj.m() == '1'
}
+ @Test
void testDelegatingProxy() {
assertScript '''
public abstract class A { abstract protected String doIt() }
@@ -131,6 +143,7 @@ class ProxyGeneratorAdapterTest {
}
// GROOVY-5925
+ @Test
void testProxyForLongConstructor() {
def map = [nextInt: { x -> return 0 }]
@@ -142,6 +155,7 @@ class ProxyGeneratorAdapterTest {
assert proxy.nextInt() == 0
}
+ @Test
void testProxyForDoubleConstructor() {
assertScript '''
public class A {
@@ -162,6 +176,7 @@ class ProxyGeneratorAdapterTest {
}
// GROOVY-7146
+ @Test
void testShouldNotThrowVerifyErrorBecauseOfStackSize() {
assertScript '''
interface DoStuff {
@@ -178,6 +193,7 @@ class ProxyGeneratorAdapterTest {
static trait Trait1 { def method1() { 'Trait1 method' } }
// GROOVY-7443
+ @Test
void testTraitFromDifferentClassloader() {
def aWith1 = new ClassA().withTraits(Trait1)
assert aWith1.method1() == 'Trait1 method'
@@ -192,6 +208,7 @@ class ProxyGeneratorAdapterTest {
assert aWith2.method2() == 'Trait2 method'
}
+ @Test
void testGetTypeArgsRegisterLength() {
def types = { list -> list as org.objectweb.asm.Type[] }
def proxyGeneratorAdapter = new ProxyGeneratorAdapter([:], Object, []
as Class[], null, false, Object)
diff --git a/src/test/groovy/groovy/util/ProxyGeneratorTest.groovy
b/src/test/groovy/groovy/util/ProxyGeneratorTest.groovy
index a62b2a2eb6..b29d7129bf 100644
--- a/src/test/groovy/groovy/util/ProxyGeneratorTest.groovy
+++ b/src/test/groovy/groovy/util/ProxyGeneratorTest.groovy
@@ -19,12 +19,16 @@
package groovy.util
+import org.junit.jupiter.api.Test
+
import static groovy.test.GroovyAssert.shouldFail
+import static org.junit.jupiter.api.Assertions.assertEquals
class ProxyGeneratorTest {
ProxyGenerator generator = ProxyGenerator.INSTANCE
+ @Test
void testAggregateFromBaseClass() {
Map map = [myMethodB: {"the new B"}, myMethodX: {"the injected X"}]
def testClass = generator.instantiateAggregateFromBaseClass(map,
TestClass)
@@ -34,6 +38,7 @@ class ProxyGeneratorTest {
assert testClass.myMethodX() == "the injected X"
}
+ @Test
void testAggregateFromAbstractBaseClass() {
Map map = [myMethodG: {"the concrete G"}, myMethodX: {"the injected
X"}]
def testClass = generator.instantiateAggregateFromBaseClass(map,
AbstractClass)
@@ -43,6 +48,7 @@ class ProxyGeneratorTest {
assert testClass.myMethodX() == "the injected X"
}
+ @Test
void testAggregateFromInterface() {
Map map = [myMethodC: {"the injected C"}]
def testClass = generator.instantiateAggregateFromInterface(map,
TestInterface)
@@ -51,6 +57,7 @@ class ProxyGeneratorTest {
assert testClass.myMethodC() == "the injected C"
}
+ @Test
void testAggregate() {
Map map = [myMethodE: {"the injected E"}, myMethodB: {"the new B"},
myMethodX: {"the injected X"}]
def testClass = generator.instantiateAggregate(map, [TestInterface,
TestOtherInterface], TestClass)
@@ -63,6 +70,7 @@ class ProxyGeneratorTest {
assert testClass.myMethodE() == "the injected E"
}
+ @Test
void testDelegate() {
def delegate = new TestClass()
Map map = [myMethodE: {"the injected E"}, myMethodB: {"the new B"},
myMethodX: {"the injected X"}]
@@ -75,6 +83,7 @@ class ProxyGeneratorTest {
assert testClass.myMethodE() == "the injected E"
}
+ @Test
void testDelegateWithBaseClass() {
def delegate = new TestClass()
Map map = [myMethodE: {"the injected E"}, myMethodB: {"the new B"},
myMethodX: {"the injected X"}]
@@ -87,6 +96,7 @@ class ProxyGeneratorTest {
assert testClass.myMethodE() == "the injected E"
}
+ @Test
void testDelegateForGROOVY_2705() {
def delegate = [1, 2, 3, 4, 5]
def testClass = generator.instantiateDelegate([List], delegate)
@@ -101,6 +111,7 @@ class ProxyGeneratorTest {
assert [1, 99, 5] == testClass
}
+ @Test
void testUnknownMethodThrowsUnsupportedOperationException() {
def map = [ myMethodA: { 'some string' } ]
def proxy = ProxyGenerator.instantiateAggregateFromInterface(map,
TestInterface)
@@ -111,6 +122,7 @@ class ProxyGeneratorTest {
}
}
+ @Test
void testUnknownMethodWithBlankBody() {
def map = [ myMethodA: { 'some string' } ]
def gen = new ProxyGenerator()
@@ -121,6 +133,7 @@ class ProxyGeneratorTest {
proxy.myMethodC()
}
+ @Test
void testProxyWithToString() {
def map = [ toString: {'hello'} ]
def gen = new ProxyGenerator()
@@ -128,6 +141,7 @@ class ProxyGeneratorTest {
assert proxy.toString() == 'hello'
}
+ @Test
void testProxyWithClosureChangedAfterCreation() {
def map = [ toString: { 'hello'} ]
def gen = new ProxyGenerator()
@@ -137,6 +151,7 @@ class ProxyGeneratorTest {
assert proxy.toString() == 'world'
}
+ @Test
void testProxyMethodUsingLongAsParameter() {
def map = [ foo: { a,b -> a*b }]
def gen = new ProxyGenerator()
@@ -144,6 +159,7 @@ class ProxyGeneratorTest {
assert proxy.foo(3,3) == 9
}
+ @Test
void testProxyMethodUsingDoubleAsParameter() {
def map = [ foo: { a,b -> a*b }]
def gen = new ProxyGenerator()
@@ -151,6 +167,7 @@ class ProxyGeneratorTest {
assert proxy.foo(3d,3d) == 9d
}
+ @Test
void testProxyMethodUsingVariousTypesAsParameters() {
def map = [ foo: { a,b,c,d -> a*b+c-d }]
def gen = new ProxyGenerator()
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/GenericsGenTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/GenericsGenTest.groovy
index ec00a5f57c..fc1c4a744e 100644
--- a/src/test/groovy/org/codehaus/groovy/classgen/GenericsGenTest.groovy
+++ b/src/test/groovy/org/codehaus/groovy/classgen/GenericsGenTest.groovy
@@ -21,11 +21,13 @@ package org.codehaus.groovy.classgen
import org.codehaus.groovy.control.CompilerConfiguration
import org.codehaus.groovy.tools.FileSystemCompiler
import org.junit.jupiter.api.AfterEach
+import org.junit.jupiter.api.Test
import static org.junit.jupiter.api.Assertions.assertNotNull
class GenericsGenTest {
+ @Test
void testCompile() {
File dir = createTempDir("groovy-src-", "-src")
assertNotNull dir
diff --git
a/src/test/groovy/org/codehaus/groovy/runtime/memoize/AbstractMemoizeTestCase.groovy
b/src/test/groovy/org/codehaus/groovy/runtime/memoize/AbstractMemoizeTestCase.groovy
index a34ef845d5..605961171f 100644
---
a/src/test/groovy/org/codehaus/groovy/runtime/memoize/AbstractMemoizeTestCase.groovy
+++
b/src/test/groovy/org/codehaus/groovy/runtime/memoize/AbstractMemoizeTestCase.groovy
@@ -19,6 +19,8 @@
package org.codehaus.groovy.runtime.memoize
+import org.junit.jupiter.api.Test
+
import static org.junit.jupiter.api.Assertions.assertEquals
@@ -30,6 +32,7 @@ abstract class AbstractMemoizeTestCase {
super()
}
+ @Test
void testCorrectness() {
Closure cl = { it * 2 }
Closure mem = buildMemoizeClosure(cl)
@@ -39,6 +42,7 @@ abstract class AbstractMemoizeTestCase {
abstract Closure buildMemoizeClosure(Closure cl)
+ @Test
void testNullParams() {
Closure cl = { 2 }
Closure mem = cl.memoize()
@@ -47,6 +51,7 @@ abstract class AbstractMemoizeTestCase {
assert 2 == mem(null)
}
+ @Test
void testNullResult() {
Closure cl = { counter++; if (it == 5) return null else return 2 }
Closure mem = cl.memoize()
@@ -60,6 +65,7 @@ abstract class AbstractMemoizeTestCase {
assert counter == 2
}
+ @Test
void testNoParams() {
Closure cl = { -> 2 }
Closure mem = cl.memoize()
@@ -67,6 +73,7 @@ abstract class AbstractMemoizeTestCase {
assert 2 == mem()
}
+ @Test
void testCaching() {
def flag = false
Closure cl = {
@@ -93,6 +100,7 @@ abstract class AbstractMemoizeTestCase {
assert !flag
}
+ @Test
void testComplexParameter() {
def callFlag = []
diff --git
a/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeAtLeastTest.groovy
b/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeAtLeastTest.groovy
index 6060110a93..94c9318463 100644
---
a/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeAtLeastTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeAtLeastTest.groovy
@@ -18,6 +18,8 @@
*/
package org.codehaus.groovy.runtime.memoize
+import org.junit.jupiter.api.Test
+
import java.util.concurrent.atomic.AtomicInteger
class MemoizeAtLeastTest extends AbstractMemoizeTestCase {
@@ -26,6 +28,7 @@ class MemoizeAtLeastTest extends AbstractMemoizeTestCase {
cl.memoizeAtLeast(100)
}
+ @Test
void testZeroCache() {
def flag = false
Closure cl = {
@@ -37,6 +40,7 @@ class MemoizeAtLeastTest extends AbstractMemoizeTestCase {
assert flag
}
+ @Test
void testMemoizeAtLeastConcurrently() {
AtomicInteger cnt = new AtomicInteger(0)
Closure cl = {
diff --git
a/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeAtMostTest.groovy
b/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeAtMostTest.groovy
index 403ee85ceb..4c9a855503 100644
---
a/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeAtMostTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeAtMostTest.groovy
@@ -18,6 +18,8 @@
*/
package org.codehaus.groovy.runtime.memoize
+import org.junit.jupiter.api.Test
+
import java.util.concurrent.atomic.AtomicInteger
import static org.junit.jupiter.api.Assertions.assertEquals
@@ -28,6 +30,7 @@ class MemoizeAtMostTest extends AbstractMemoizeTestCase {
cl.memoizeAtMost(100)
}
+ @Test
void testZeroCache() {
def flag = false
Closure cl = {
@@ -42,6 +45,7 @@ class MemoizeAtMostTest extends AbstractMemoizeTestCase {
assert flag
}
+ @Test
void testLRUCache() {
def flag = false
Closure cl = {
@@ -71,6 +75,7 @@ class MemoizeAtMostTest extends AbstractMemoizeTestCase {
assert flag
}
+ @Test
void testMemoizeAtMostConcurrently() {
AtomicInteger cnt = new AtomicInteger(0)
Closure cl = {
diff --git
a/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeBetweenTest.groovy
b/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeBetweenTest.groovy
index 244a488ad2..d6c107714b 100644
---
a/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeBetweenTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeBetweenTest.groovy
@@ -18,6 +18,8 @@
*/
package org.codehaus.groovy.runtime.memoize
+import org.junit.jupiter.api.Test
+
import java.util.concurrent.atomic.AtomicInteger
import static groovy.test.GroovyAssert.shouldFail
@@ -28,6 +30,7 @@ class MemoizeBetweenTest extends AbstractMemoizeTestCase {
cl.memoizeBetween(50, 100)
}
+ @Test
void testParameters() {
Closure cl = {}
shouldFail(IllegalArgumentException) {
@@ -41,6 +44,7 @@ class MemoizeBetweenTest extends AbstractMemoizeTestCase {
}
}
+ @Test
void testZeroCache() {
def flag = false
Closure cl = {
@@ -55,6 +59,7 @@ class MemoizeBetweenTest extends AbstractMemoizeTestCase {
assert flag
}
+ @Test
void testLRUCache() {
def flag = false
Closure cl = {
@@ -84,6 +89,7 @@ class MemoizeBetweenTest extends AbstractMemoizeTestCase {
assert flag
}
+ @Test
void testMemoizeBetweenConcurrently() {
AtomicInteger cnt = new AtomicInteger(0)
Closure cl = {
diff --git
a/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeTest.groovy
b/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeTest.groovy
index 9ab9798974..a13b8b3af6 100644
--- a/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeTest.groovy
+++ b/src/test/groovy/org/codehaus/groovy/runtime/memoize/MemoizeTest.groovy
@@ -18,12 +18,17 @@
*/
package org.codehaus.groovy.runtime.memoize
+import org.junit.jupiter.api.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
class MemoizeTest extends AbstractMemoizeTestCase {
Closure buildMemoizeClosure(Closure cl) {
cl.memoize()
}
+ @Test
void testMemoizeWithInject() {
int maxExecutionCount = 0
Closure max = { int a, int b ->
@@ -46,6 +51,7 @@ class MemoizeTest extends AbstractMemoizeTestCase {
}
// GROOVY-6584
+ @Test
void testMemoizeFunctionClosure() {
int timesMethodBodyExecuted = 0
def lst = []
@@ -91,6 +97,7 @@ class MemoizeTest extends AbstractMemoizeTestCase {
assert timesMethodBodyExecuted == 4
}
+ @Test
void testMemoizeClosureParameters() {
def clo = { String a, Date b, c -> 42 }.memoize()
assert clo.maximumNumberOfParameters == 3
@@ -107,6 +114,7 @@ class MemoizeTest extends AbstractMemoizeTestCase {
}
// GROOVY-6175
+ @Test
void testMemoizeClosureAsProperty() {
def c = new ClassWithMemoizeClosureProperty();
@@ -118,6 +126,7 @@ class MemoizeTest extends AbstractMemoizeTestCase {
}
// GROOVY-8486
+ @Test
void testMemoizeConcurrently() {
assertScript '''
//
http://groovy.329449.n5.nabble.com/ConcurrentModificationException-with-use-of-memoize-tp5736788.html