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 b80ac44cc5 JUnit 5
b80ac44cc5 is described below
commit b80ac44cc57d3f1d8974bd601c86bfc27f9ad348
Author: Eric Milles <[email protected]>
AuthorDate: Sun Jan 18 11:34:40 2026 -0600
JUnit 5
---
src/test/groovy/bugs/Groovy10034.groovy | 3 ++
src/test/groovy/bugs/Groovy10314.groovy | 2 +
src/test/groovy/bugs/Groovy10565.groovy | 5 ++-
src/test/groovy/bugs/Groovy10617.groovy | 2 +
src/test/groovy/bugs/Groovy11362.groovy | 2 +
src/test/groovy/bugs/Groovy6954.groovy | 5 +++
.../{Groovy8144Bug.groovy => Groovy8144.groovy} | 15 ++++---
.../{Groovy8289Bug.groovy => Groovy8289.groovy} | 6 ++-
.../{Groovy8614Bug.groovy => Groovy8614.groovy} | 9 ++--
src/test/groovy/bugs/Groovy9530.groovy | 2 +
.../classgen/asm/AbstractBytecodeTestCase.groovy | 16 +++----
.../classgen/asm/BinaryOperationsTest.groovy | 28 ++++++++----
.../asm/CovariantReturnBytecodeTest.groovy | 8 +++-
.../classgen/asm/DirectMethodCallTest.groovy | 52 +++++++++++-----------
.../groovy/classgen/asm/HotSwapTest.groovy | 9 +++-
.../groovy/classgen/asm/MethodPatternsTest.groovy | 47 ++++++++++++-------
.../classgen/asm/PrintlnLoadsAConstantTest.groovy | 8 +++-
.../groovy/classgen/asm/TypeAnnotationsTest.groovy | 16 +++++++
.../sc/CombinedIndyAndStaticCompilationTest.groovy | 9 +++-
.../asm/sc/GetAnnotationStaticCompileTest.groovy | 11 ++---
.../classgen/asm/sc/StaticCompilationTest.groovy | 50 ++++++++++++++++++++-
.../asm/sc/StaticCompileArrayLengthAndGet.groovy | 14 +++---
.../asm/sc/StaticCompileClosureCallTest.groovy | 11 +++++
.../asm/sc/StaticCompileComparisonTest.groovy | 12 +++--
.../asm/sc/StaticCompileDGMMethodTest.groovy | 9 +++-
.../asm/sc/StaticCompileInnerClassTest.groovy | 11 +++--
.../classgen/asm/sc/StaticCompileMathTest.groovy | 24 ++++++++++
...StaticCompileNullCompareOptimizationTest.groovy | 19 ++++++++
.../asm/sc/StaticCompilePostfixPrefixTest.groovy | 9 +++-
29 files changed, 313 insertions(+), 101 deletions(-)
diff --git a/src/test/groovy/bugs/Groovy10034.groovy
b/src/test/groovy/bugs/Groovy10034.groovy
index 4bce760101..bed617b7a7 100644
--- a/src/test/groovy/bugs/Groovy10034.groovy
+++ b/src/test/groovy/bugs/Groovy10034.groovy
@@ -19,8 +19,11 @@
package bugs
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
final class Groovy10034 extends AbstractBytecodeTestCase {
+
+ @Test
void testObjectArrayParam() {
def result = compile method:'test', '''
@groovy.transform.CompileStatic
diff --git a/src/test/groovy/bugs/Groovy10314.groovy
b/src/test/groovy/bugs/Groovy10314.groovy
index a8b8588691..b5fd8c20a0 100644
--- a/src/test/groovy/bugs/Groovy10314.groovy
+++ b/src/test/groovy/bugs/Groovy10314.groovy
@@ -19,9 +19,11 @@
package bugs
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
final class Groovy10314 extends AbstractBytecodeTestCase {
+ @Test
void testTryFinallyWhereAllPathsReturn() {
def result = compile method:'test', '''
def test() {
diff --git a/src/test/groovy/bugs/Groovy10565.groovy
b/src/test/groovy/bugs/Groovy10565.groovy
index c5979bbab7..18a7db122b 100644
--- a/src/test/groovy/bugs/Groovy10565.groovy
+++ b/src/test/groovy/bugs/Groovy10565.groovy
@@ -19,13 +19,16 @@
package bugs
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
import static groovy.test.GroovyAssert.isAtLeastJdk
+import static org.junit.jupiter.api.Assumptions.assumeTrue
final class Groovy10565 extends AbstractBytecodeTestCase {
+ @Test
void testPermittedSubclassName() {
- if (!isAtLeastJdk('17.0')) return
+ assumeTrue(isAtLeastJdk('17.0'))
def bytecode = compile '''
package example
diff --git a/src/test/groovy/bugs/Groovy10617.groovy
b/src/test/groovy/bugs/Groovy10617.groovy
index d2a3f358a8..f51a12081a 100644
--- a/src/test/groovy/bugs/Groovy10617.groovy
+++ b/src/test/groovy/bugs/Groovy10617.groovy
@@ -19,9 +19,11 @@
package bugs
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
final class Groovy10617 extends AbstractBytecodeTestCase {
+ @Test
void testReturnInsertion() {
def bytecode = compile '''
String m() {
diff --git a/src/test/groovy/bugs/Groovy11362.groovy
b/src/test/groovy/bugs/Groovy11362.groovy
index 500acfb460..55b7a375c1 100644
--- a/src/test/groovy/bugs/Groovy11362.groovy
+++ b/src/test/groovy/bugs/Groovy11362.groovy
@@ -19,9 +19,11 @@
package bugs
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
final class Groovy11362 extends AbstractBytecodeTestCase {
+ @Test
void testCatchException() {
def bytecode = compile method:'test', '''
void test() {
diff --git a/src/test/groovy/bugs/Groovy6954.groovy
b/src/test/groovy/bugs/Groovy6954.groovy
index de2116c900..92b07df738 100644
--- a/src/test/groovy/bugs/Groovy6954.groovy
+++ b/src/test/groovy/bugs/Groovy6954.groovy
@@ -19,10 +19,12 @@
package bugs
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
final class Groovy6954 extends AbstractBytecodeTestCase {
// GROOVY-11376
+ @Test
void testSetMapDotField() {
assertScript '''import groovy.transform.*
@CompileStatic
@@ -60,6 +62,7 @@ final class Groovy6954 extends AbstractBytecodeTestCase {
'''
}
+ @Test
void testSetMapDotProperty() {
extractionOptions.method = 'put'
@@ -81,6 +84,7 @@ final class Groovy6954 extends AbstractBytecodeTestCase {
], sequence.indexOf('--BEGIN--'))
}
+ @Test
void testSafeSetMapDotProperty() {
extractionOptions.method = 'put'
@@ -101,6 +105,7 @@ final class Groovy6954 extends AbstractBytecodeTestCase {
])
}
+ @Test
void testChainSetMapDotProperty() {
assertScript '''
@groovy.transform.CompileStatic
diff --git a/src/test/groovy/bugs/Groovy8144Bug.groovy
b/src/test/groovy/bugs/Groovy8144.groovy
similarity index 89%
rename from src/test/groovy/bugs/Groovy8144Bug.groovy
rename to src/test/groovy/bugs/Groovy8144.groovy
index 610c880ec3..7d87ec5863 100644
--- a/src/test/groovy/bugs/Groovy8144Bug.groovy
+++ b/src/test/groovy/bugs/Groovy8144.groovy
@@ -21,12 +21,14 @@ package bugs
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
import org.codehaus.groovy.control.CompilerConfiguration
import org.codehaus.groovy.control.SourceUnit
+import org.junit.jupiter.api.BeforeEach
+import org.junit.jupiter.api.Test
/**
* This test requires the test classes executed are compiled and on the
* classpath and not in the same compilation unit.
*/
-class Groovy8144Bug extends AbstractBytecodeTestCase {
+class Groovy8144 extends AbstractBytecodeTestCase {
GroovyShell shell
@@ -34,26 +36,29 @@ class Groovy8144Bug extends AbstractBytecodeTestCase {
['asmResolving': Boolean.TRUE]
}
- @Override
- void setUp() {
+ @BeforeEach
+ void moreSetUp() {
CompilerConfiguration config = new CompilerConfiguration()
config.optimizationOptions.putAll(getOptions())
shell = new GroovyShell(config)
}
+ @Test
void testMethodInheritedFromNonPublicAbstractBaseClass() {
checkAnswer('Groovy8144A')
}
+ @Test
void testMethodInheritedFromPublicAbstractBaseClass() {
checkAnswer('Groovy8144B')
}
+ @Test
void testMethodInheritedFromPublicBaseClass() {
checkAnswer('Groovy8144C')
}
- void checkAnswer(String testClassName) {
+ private void checkAnswer(String testClassName) {
String code = """
import org.codehaus.groovy.dummy.${testClassName}
@@ -81,7 +86,7 @@ class Groovy8144Bug extends AbstractBytecodeTestCase {
}
}
-class Groovy8144BugAsmResolveOff extends Groovy8144Bug {
+final class Groovy8144_AsmResolveOff extends Groovy8144 {
@Override
protected Map<String, Boolean> getOptions() {
['asmResolving': Boolean.FALSE]
diff --git a/src/test/groovy/bugs/Groovy8289Bug.groovy
b/src/test/groovy/bugs/Groovy8289.groovy
similarity index 94%
rename from src/test/groovy/bugs/Groovy8289Bug.groovy
rename to src/test/groovy/bugs/Groovy8289.groovy
index c5b993ec21..8dfa5f7edd 100644
--- a/src/test/groovy/bugs/Groovy8289Bug.groovy
+++ b/src/test/groovy/bugs/Groovy8289.groovy
@@ -19,8 +19,11 @@
package bugs
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
-class Groovy8289Bug extends AbstractBytecodeTestCase {
+final class Groovy8289 extends AbstractBytecodeTestCase {
+
+ @Test
void testNoArgCtorLines() {
def bytecode = compile '''\
@groovy.transform.CompileStatic
@@ -43,6 +46,7 @@ class Groovy8289Bug extends AbstractBytecodeTestCase {
}
// GROOVY-9199
+ @Test
void testTryFinallyLines() {
def bytecode = compile '''\
def m(p) {
diff --git a/src/test/groovy/bugs/Groovy8614Bug.groovy
b/src/test/groovy/bugs/Groovy8614.groovy
similarity index 90%
rename from src/test/groovy/bugs/Groovy8614Bug.groovy
rename to src/test/groovy/bugs/Groovy8614.groovy
index 020cfb1870..f563592761 100644
--- a/src/test/groovy/bugs/Groovy8614Bug.groovy
+++ b/src/test/groovy/bugs/Groovy8614.groovy
@@ -19,12 +19,14 @@
package bugs
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
/**
- * see Groovy3830Bug for tests when call sites are present
+ * See {@link Groovy3830Bug} for tests when call sites are present.
*/
-class Groovy8614Bug extends AbstractBytecodeTestCase {
+final class Groovy8614 extends AbstractBytecodeTestCase {
+ @Test
void testNestedInterfaceHelperClassNotGeneratedIfNoCallsites() {
def bytecode = compile('classNamePattern': 'X', '''
class X {
@@ -34,6 +36,7 @@ class Groovy8614Bug extends AbstractBytecodeTestCase {
assert !bytecode.hasSequence(['static synthetic INNERCLASS X$Y$1 X 1'])
}
+ @Test
void testDoubleNestedInterfaceHelperClassNotGeneratedIfNoCallsites() {
def bytecode = compile('classNamePattern': 'X\\$Y', '''
class X {
@@ -46,6 +49,7 @@ class Groovy8614Bug extends AbstractBytecodeTestCase {
}
//GROOVY-5082
+ @Test
void testInterfaceHelperClassNotGeneratedIfNoCallsites() {
def bytecode = compile('classNamePattern': 'X', '''
interface X {
@@ -54,5 +58,4 @@ class Groovy8614Bug extends AbstractBytecodeTestCase {
''')
assert !bytecode.hasSequence(['static synthetic INNERCLASS X$1 X 1'])
}
-
}
diff --git a/src/test/groovy/bugs/Groovy9530.groovy
b/src/test/groovy/bugs/Groovy9530.groovy
index 66ae9328f4..8aeffb1b59 100644
--- a/src/test/groovy/bugs/Groovy9530.groovy
+++ b/src/test/groovy/bugs/Groovy9530.groovy
@@ -19,6 +19,7 @@
package bugs
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
final class Groovy9530 extends AbstractBytecodeTestCase {
@@ -30,6 +31,7 @@ final class Groovy9530 extends AbstractBytecodeTestCase {
}
}
+ @Test
void testConstantInlining() {
def bytecode = compile '''import bugs.Groovy9530.StaticClass
class C {
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/AbstractBytecodeTestCase.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/AbstractBytecodeTestCase.groovy
index c21245bbad..482b59db87 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/AbstractBytecodeTestCase.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/AbstractBytecodeTestCase.groovy
@@ -18,11 +18,11 @@
*/
package org.codehaus.groovy.classgen.asm
-import groovy.test.GroovyTestCase
import org.apache.groovy.io.StringBuilderWriter
import org.codehaus.groovy.control.CompilationUnit
import org.codehaus.groovy.control.CompilerConfiguration
import org.codehaus.groovy.control.Phases
+import org.junit.jupiter.api.BeforeEach
import org.objectweb.asm.ClassReader
import org.objectweb.asm.ClassVisitor
import org.objectweb.asm.FieldVisitor
@@ -34,19 +34,17 @@ import java.security.CodeSource
/**
* Abstract test case to extend to check the instructions we generate in the
bytecode of groovy programs.
*/
-abstract class AbstractBytecodeTestCase extends GroovyTestCase {
+abstract class AbstractBytecodeTestCase {
Class clazz
Map extractionOptions
InstructionSequence sequence
- @Override
- protected void setUp() {
- super.setUp()
+ @BeforeEach
+ void setUp() {
extractionOptions = [method: 'run']
}
- @Override
protected void assertScript(final String script) throws Exception {
CompilationUnit unit = null
GroovyShell shell = new GroovyShell(new GroovyClassLoader() {
@@ -56,7 +54,7 @@ abstract class AbstractBytecodeTestCase extends
GroovyTestCase {
}
})
try {
- shell.evaluate(script, testClassName)
+ shell.evaluate(script, this.class.simpleName)
} finally {
if (unit != null) {
try {
@@ -76,7 +74,7 @@ abstract class AbstractBytecodeTestCase extends
GroovyTestCase {
* @param scriptText the script to compile
* @return the decompiled <code>InstructionSequence</code>
*/
- InstructionSequence compile(Map options = [:], final String scriptText) {
+ protected InstructionSequence compile(Map options = [:], final String
scriptText) {
options = [method: 'run', classNamePattern: '.*script', *: options]
sequence = null
clazz = null
@@ -112,7 +110,7 @@ abstract class AbstractBytecodeTestCase extends
GroovyTestCase {
sequence
}
- InstructionSequence extractSequence(final byte[] bytes, final Map options
= [method: 'run']) {
+ protected InstructionSequence extractSequence(final byte[] bytes, final
Map options = [method: 'run']) {
def out = new StringBuilderWriter()
def tcv
tcv = new TraceClassVisitor(new
ClassVisitor(CompilerConfiguration.ASM_API_VERSION) {
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/BinaryOperationsTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/BinaryOperationsTest.groovy
index 6255532e6f..2e8f751783 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/BinaryOperationsTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/BinaryOperationsTest.groovy
@@ -18,12 +18,16 @@
*/
package org.codehaus.groovy.classgen.asm
+import org.junit.jupiter.api.Test
+
import static org.codehaus.groovy.control.CompilerConfiguration.DEFAULT as
config
+import static org.junit.jupiter.api.Assumptions.assumeFalse
-class BinaryOperationsTest extends AbstractBytecodeTestCase {
+final class BinaryOperationsTest extends AbstractBytecodeTestCase {
+ @Test
void testIntPlus() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
assert compile("""\
int i = 1
int j = 2
@@ -35,8 +39,9 @@ class BinaryOperationsTest extends AbstractBytecodeTestCase {
])
}
+ @Test
void testIntCompareLessThan() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
assert compile("""\
int i = 0
if (i < 100) println "true"
@@ -47,9 +52,10 @@ class BinaryOperationsTest extends AbstractBytecodeTestCase {
])
}
+ // GROOVY-4741
+ @Test
void testCompareLessThanInClosure() {
- if (config.indyEnabled) return;
- // GROOVY-4741
+ assumeFalse(config.indyEnabled)
assert """
int a = 0
[].each {
@@ -59,8 +65,9 @@ class BinaryOperationsTest extends AbstractBytecodeTestCase {
"""
}
+ @Test
void testLongLeftShift() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
assert compile("""\
long a = 1
long b = a << 32
@@ -70,8 +77,9 @@ class BinaryOperationsTest extends AbstractBytecodeTestCase {
])
}
+ @Test
void testIntConstants() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
(0..5).each {
assert compile("""\
int a = $it
@@ -102,8 +110,9 @@ class BinaryOperationsTest extends AbstractBytecodeTestCase
{
}
}
+ @Test
void testCharXor() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
assert compile('''
int i = ('a' as char) ^ ('b' as char)
''').hasStrictSequence ([
@@ -112,6 +121,7 @@ class BinaryOperationsTest extends AbstractBytecodeTestCase
{
}
// GROOVY-10657
+ @Test
void testPutAtValue() {
def sequence = compile '''
class C {
@@ -124,6 +134,7 @@ class BinaryOperationsTest extends AbstractBytecodeTestCase
{
'''
}
+ @Test
void testPrimitiveOrAssign() {
['byte','int','short','long'].each { type ->
assertScript """
@@ -135,6 +146,7 @@ class BinaryOperationsTest extends AbstractBytecodeTestCase
{
}
}
+ @Test
void testPrimitiveAndAssign() {
['byte','int','short','long'].each { type ->
assertScript """
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/CovariantReturnBytecodeTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/CovariantReturnBytecodeTest.groovy
index eded14d93a..bebf677eb0 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/CovariantReturnBytecodeTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/CovariantReturnBytecodeTest.groovy
@@ -18,8 +18,12 @@
*/
package org.codehaus.groovy.classgen.asm
-class CovariantReturnBytecodeTest extends AbstractBytecodeTestCase {
- void testCovariance(){
+import org.junit.jupiter.api.Test
+
+final class CovariantReturnBytecodeTest extends AbstractBytecodeTestCase {
+
+ @Test
+ void testCovariance() {
def code = compile (method:'super$3$attach', classNamePattern:'C', '''
abstract class A {
A attach(){return this}
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/DirectMethodCallTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/DirectMethodCallTest.groovy
index a8e414bc70..c04e10e7f5 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/DirectMethodCallTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/DirectMethodCallTest.groovy
@@ -20,33 +20,35 @@ package org.codehaus.groovy.classgen.asm
import org.codehaus.groovy.ast.ClassHelper
import org.codehaus.groovy.ast.Parameter
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.params.ParameterizedTest
+import org.junit.jupiter.params.provider.ValueSource
-class DirectMethodCallTest extends AbstractBytecodeTestCase {
+final class DirectMethodCallTest extends AbstractBytecodeTestCase {
- void testVirtual() {
- def target = ClassHelper.Integer_TYPE.getMethod("toString", new
Parameter[0])
- def makeDirectCall = {su ->
- su. getAST().classes[0].
- getMethod("run", new Parameter[0]).code.
- statements.last().expression.methodTarget = target;
- }
+ @Test
+ void testVirtual() {
+ def target = ClassHelper.Integer_TYPE.getMethod('toString', new
Parameter[0])
+ def makeDirectCall = { su ->
+ su.getAST().classes[0].getMethod('run', new
Parameter[0]).code.statements.last().expression.methodTarget = target
+ }
- assert compile (method:"run", conversionAction: makeDirectCall, """
- def a = 1;
- a.toString()
- """).hasSequence([
- "INVOKEVIRTUAL java/lang/Integer.toString ()Ljava/lang/String;"
- ])
- }
+ assert compile (method:'run', conversionAction: makeDirectCall, '''
+ def a = 1
+ a.toString()
+ ''').hasSequence([
+ 'INVOKEVIRTUAL java/lang/Integer.toString ()Ljava/lang/String;'
+ ])
+ }
- //GROOVY-6384
- void testClassForNameAutomaticDirectCall() {
- ['"Foo"',1,null,"println(x)"].each { arg ->
- assert compile (method:"run", """
- Class.forName($arg)
- """).hasSequence([
- "INVOKESTATIC java/lang/Class.forName
(Ljava/lang/String;)Ljava/lang/Class;"
- ])
- }
- }
+ // GROOVY-6384
+ @ParameterizedTest
+ @ValueSource(strings=['"Foo"','1','null','println(x)'])
+ void testClassForNameAutomaticDirectCall(String argument) {
+ assert compile (method:'run', """
+ Class.forName($argument)
+ """).hasSequence([
+ 'INVOKESTATIC java/lang/Class.forName
(Ljava/lang/String;)Ljava/lang/Class;'
+ ])
+ }
}
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/HotSwapTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/HotSwapTest.groovy
index 0779048d00..52b670d091 100644
--- a/src/test/groovy/org/codehaus/groovy/classgen/asm/HotSwapTest.groovy
+++ b/src/test/groovy/org/codehaus/groovy/classgen/asm/HotSwapTest.groovy
@@ -18,12 +18,16 @@
*/
package org.codehaus.groovy.classgen.asm
+import org.junit.jupiter.api.Test
+
import static org.codehaus.groovy.control.CompilerConfiguration.DEFAULT as
config
+import static org.junit.jupiter.api.Assumptions.assumeFalse
-class HotSwapTest extends AbstractBytecodeTestCase {
+final class HotSwapTest extends AbstractBytecodeTestCase {
+ @Test
void testHotSwapMethodExistsAndCallsGetCallSiteArray() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
assert compile(method: '__$swapInit', '''
Long d = 123456L
''').hasSequence([
@@ -32,6 +36,7 @@ class HotSwapTest extends AbstractBytecodeTestCase {
])
}
+ @Test
void testClinitCallingHotSwapMethod() {
assert compile(method: '<clinit>', '''
Long d = 123456L
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/MethodPatternsTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/MethodPatternsTest.groovy
index bfdab11b33..e8c7163f62 100644
--- a/src/test/groovy/org/codehaus/groovy/classgen/asm/MethodPatternsTest.groovy
+++ b/src/test/groovy/org/codehaus/groovy/classgen/asm/MethodPatternsTest.groovy
@@ -18,12 +18,16 @@
*/
package org.codehaus.groovy.classgen.asm
+import org.junit.jupiter.api.Test
+
import static org.codehaus.groovy.control.CompilerConfiguration.DEFAULT as
config
+import static org.junit.jupiter.api.Assumptions.assumeFalse
-class MethodPatternsTest extends AbstractBytecodeTestCase {
+final class MethodPatternsTest extends AbstractBytecodeTestCase {
- void testUnoptimizedIfWithNestedOptimizedLoop(){
- if (config.indyEnabled) return;
+ @Test
+ void testUnoptimizedIfWithNestedOptimizedLoop() {
+ assumeFalse(config.indyEnabled)
// in this example the if block contains statements that will not be
optimized
// but we still want to optimize the for loops, which can.
// The test will check there is an optimized bytecode sequence for the
loops.
@@ -88,8 +92,9 @@ class MethodPatternsTest extends AbstractBytecodeTestCase {
// make a test for native compilation of the ackerman function
// and ensure the nested call is optimized
+ @Test
void testAckerman() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
assert compile(method: 'A', '''
int A(int x, int y) {
if (x == 0) return y+1
@@ -138,8 +143,9 @@ class MethodPatternsTest extends AbstractBytecodeTestCase {
])
}
+ @Test
void testForLoopSettingArray() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
assert compile('''
int n = 10
int[] x = new int[n]
@@ -176,8 +182,9 @@ class MethodPatternsTest extends AbstractBytecodeTestCase {
])
}
+ @Test
void testArrayIncrement() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
assert compile('''
int n = 10
int[] x = new int[n]
@@ -226,8 +233,9 @@ class MethodPatternsTest extends AbstractBytecodeTestCase {
])
}
+ @Test
void testForLoopSettingArrayWithOperatorUsedInAssignmentAndArrayRHS() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
assert compile('''
int n = 10
int[] x = new int[n]
@@ -266,8 +274,9 @@ class MethodPatternsTest extends AbstractBytecodeTestCase {
])
}
+ @Test
void testRightShiftUnsignedWithLongArgument() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
assert compile(method: "hashCode", '''
class X{
long _tagReservationDate
@@ -296,8 +305,9 @@ class MethodPatternsTest extends AbstractBytecodeTestCase {
])
}
+ @Test
void testObjectArraySet() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
assert compile(method: "foo", '''
class X {
void foo() {
@@ -311,8 +321,9 @@ class MethodPatternsTest extends AbstractBytecodeTestCase {
])
}
+ @Test
void testBooleanArraySet() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
assert compile(method: "foo", '''
class X{
void foo() {
@@ -326,8 +337,9 @@ class MethodPatternsTest extends AbstractBytecodeTestCase {
])
}
+ @Test
void testArray() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
def methods = [
"short" : [1, "sArraySet ([SIS)V", "sArrayGet ([SI)S"],
"int" : [1, "intArraySet ([III)V", "intArrayGet ([II)I"],
@@ -379,12 +391,13 @@ class MethodPatternsTest extends AbstractBytecodeTestCase
{
}
clos.call(b)
assert b.v == 3
- assert a[3] == 8
+ assert a[3] == 8
"""
}
+ @Test
void testFib() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
assert compile(method: "fib", """
int fib(int i) {
i < 2 ? 1 : fib(i - 2) + fib(i - 1)
@@ -423,8 +436,9 @@ class MethodPatternsTest extends AbstractBytecodeTestCase {
assert !seq.contains("isOrig")
}
+ @Test
void testNoBoxUnbox() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
assert compile(method: "someCode", """
public boolean someCall() {
return true;
@@ -432,7 +446,7 @@ class MethodPatternsTest extends AbstractBytecodeTestCase {
public boolean someCode() {
boolean val = someCall()
- }
+ }
""").hasSequence([
'ALOAD',
'INVOKEVIRTUAL script.someCall ()Z',
@@ -442,8 +456,9 @@ class MethodPatternsTest extends AbstractBytecodeTestCase {
])
}
+ @Test
void testDiv() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
def types = [
"byte", "short", "int", "long", "double", "float"]
types.each {type ->
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/PrintlnLoadsAConstantTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/PrintlnLoadsAConstantTest.groovy
index ad6c95b363..23d2783f23 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/PrintlnLoadsAConstantTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/PrintlnLoadsAConstantTest.groovy
@@ -18,8 +18,12 @@
*/
package org.codehaus.groovy.classgen.asm
-class PrintlnLoadsAConstantTest extends AbstractBytecodeTestCase {
+import org.junit.jupiter.api.Test
+
+final class PrintlnLoadsAConstantTest extends AbstractBytecodeTestCase {
+
+ @Test
void testPrintln() {
assert compile(''' println "true" ''').hasSequence(['LDC "true"'])
}
-}
\ No newline at end of file
+}
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/TypeAnnotationsTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/TypeAnnotationsTest.groovy
index 03b5570c2c..c5270ddec5 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/TypeAnnotationsTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/TypeAnnotationsTest.groovy
@@ -18,6 +18,8 @@
*/
package org.codehaus.groovy.classgen.asm
+import org.junit.jupiter.api.Test
+
final class TypeAnnotationsTest extends AbstractBytecodeTestCase {
private final String imports = '''\
@@ -26,6 +28,7 @@ final class TypeAnnotationsTest extends
AbstractBytecodeTestCase {
|import static java.lang.annotation.RetentionPolicy.*
|'''.stripMargin()
+ @Test
void testTypeAnnotationsForConstructor1() {
def bytecode = compile(classNamePattern: 'HasConstructor', method:
'<init>', imports + '''
@Retention(RUNTIME) @Target(CONSTRUCTOR) @interface CtorAnno { }
@@ -44,6 +47,7 @@ final class TypeAnnotationsTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testTypeAnnotationsForConstructor2() {
def bytecode = compile(classNamePattern: 'Foo.Bar', method: '<init>',
imports + '''
@Retention(RUNTIME) @Target(TYPE_USE) @interface TypeAnno0 {
String value() }
@@ -66,6 +70,7 @@ final class TypeAnnotationsTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11184
+ @Test
void testTypeAnnotationsForConstructor3() {
def bytecode = compile(classNamePattern: 'Foo.Bar', method: '<init>',
imports + '''
@Retention(RUNTIME) @Target(TYPE_USE) @interface TypeAnno0 {
String value() }
@@ -92,6 +97,7 @@ final class TypeAnnotationsTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testTypeAnnotationsForMethod1() {
def bytecode = compile(method: 'foo', imports + '''
@Retention(RUNTIME) @Target(TYPE_USE) @interface TypeAnno0 { }
@@ -125,6 +131,7 @@ final class TypeAnnotationsTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testTypeAnnotationsForMethod2() {
def bytecode = compile(method: 'foo', imports + '''
@Retention(RUNTIME) @Target(TYPE_USE) @interface TypeParameterAnno
{ }
@@ -159,6 +166,7 @@ final class TypeAnnotationsTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testTypeAnnotationsForMethod3() {
def bytecode = compile(classNamePattern: 'Foo', method: 'get', imports
+ '''
@Retention(RUNTIME) @Target(PARAMETER) @interface ParameterAnno { }
@@ -208,6 +216,7 @@ final class TypeAnnotationsTest extends
AbstractBytecodeTestCase {
}
// GROOVY-9154
+ @Test
void testTypeAnnotationsForMethod4() {
def bytecode = compile(classNamePattern: 'Foo', method:
'sizeZeroOrPositive', '''\
@Grab("net.jqwik:jqwik:1.9.3")
@@ -233,6 +242,7 @@ final class TypeAnnotationsTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11184
+ @Test
void testTypeAnnotationsForMethod5() {
def bytecode = compile(classNamePattern: 'Foo', method: 'bar', imports
+ '''
@Retention(RUNTIME) @Target(TYPE_USE) @interface TypeAnno0 {
String value() }
@@ -258,6 +268,7 @@ final class TypeAnnotationsTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11479
+ @Test
void testTypeAnnotationsForClosure() {
def bytecode = compile(classNamePattern: 'Foo\\$_closure1', method:
'doCall', imports + '''
@Retention(RUNTIME) @Target(TYPE_USE) @interface TypeAnno0 { }
@@ -276,6 +287,7 @@ final class TypeAnnotationsTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11479
+ @Test
void testTypeAnnotationsForLambda() {
def bytecode = compile(classNamePattern: 'Foo\\$_lambda1', method:
'doCall', imports + '''
@Retention(RUNTIME) @Target(TYPE_USE) @interface TypeAnno0 { }
@@ -293,6 +305,7 @@ final class TypeAnnotationsTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testTypeAnnotationsForField1() {
def bytecode = compile(classNamePattern: 'Foo', field: 'foo', imports
+ '''
@Retention(RUNTIME) @Target(FIELD) @interface FieldAnno { String
value() }
@@ -319,6 +332,7 @@ final class TypeAnnotationsTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testTypeAnnotationsForField2() {
def bytecode = compile(classNamePattern: 'Bar', field: 'numbers',
imports + '''
@Retention(RUNTIME) @Target(TYPE_USE) @interface TypeAnno4 { }
@@ -340,6 +354,7 @@ final class TypeAnnotationsTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11179
+ @Test
void testTypeAnnotationsForClass() {
def bytecode = compile(classNamePattern: 'Baz', imports + '''
@Retention(RUNTIME) @Target(TYPE) @interface TypeAnno { String
value() }
@@ -382,6 +397,7 @@ final class TypeAnnotationsTest extends
AbstractBytecodeTestCase {
/**
* @see
https://docs.oracle.com/javase/specs/jls/se11/html/jls-9.html#jls-9.7.4
*/
+ @Test
void testTypeAnnotationsForArray() {
def bytecode = compile(classNamePattern: 'Foo', method: 'bar', imports
+ '''
@Retention(RUNTIME) @Target(TYPE_USE) @interface TypeAnno0 { }
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/CombinedIndyAndStaticCompilationTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/CombinedIndyAndStaticCompilationTest.groovy
index 87a9233e38..def803299d 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/CombinedIndyAndStaticCompilationTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/CombinedIndyAndStaticCompilationTest.groovy
@@ -19,15 +19,19 @@
package org.codehaus.groovy.classgen.asm.sc
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
import static org.codehaus.groovy.control.CompilerConfiguration.DEFAULT as
config
+import static org.junit.jupiter.api.Assumptions.assumeTrue
/**
* Tests for combined static compilation and indy code
*/
-class CombinedIndyAndStaticCompilationTest extends AbstractBytecodeTestCase {
+final class CombinedIndyAndStaticCompilationTest extends
AbstractBytecodeTestCase {
+
+ @Test
void testArrayAccess() {
- if (!config.indyEnabled) return;
+ assumeTrue(config.indyEnabled)
["byte", "short", "int", "long", "float", "double", "boolean",
"char"].each { type->
//array get
compile ("""
@@ -48,6 +52,7 @@ class CombinedIndyAndStaticCompilationTest extends
AbstractBytecodeTestCase {
}
}
+ @Test
void testNegativeAccess() {
["byte", "short", "int", "long", "float", "double", "char"].each {
type ->
assertScript """
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/GetAnnotationStaticCompileTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/GetAnnotationStaticCompileTest.groovy
index 998520b602..8064385bd8 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/GetAnnotationStaticCompileTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/GetAnnotationStaticCompileTest.groovy
@@ -19,17 +19,16 @@
package org.codehaus.groovy.classgen.asm.sc
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
/**
* Unit tests for static type checking : miscellaneous tests.
*/
-class GetAnnotationStaticCompileTest extends AbstractBytecodeTestCase {
+final class GetAnnotationStaticCompileTest extends AbstractBytecodeTestCase {
+ @Test
void testGetAnnotationShouldNotProduceProxy() {
- def bytecode = compile([method:'m'],'''import
java.lang.annotation.Retention
- import java.lang.annotation.RetentionPolicy
- import java.lang.annotation.Target
- import java.lang.annotation.ElementType
+ def bytecode = compile([method:'m'],'''import java.lang.annotation.*
@Retention(RetentionPolicy.RUNTIME)
@Target([ElementType.TYPE])
public @interface MyAnnotation {
@@ -49,6 +48,4 @@ class GetAnnotationStaticCompileTest extends
AbstractBytecodeTestCase {
println bytecode
clazz.newInstance().main()
}
-
}
-
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompilationTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompilationTest.groovy
index 9ce34e2c50..f04e292cb7 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompilationTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompilationTest.groovy
@@ -20,9 +20,14 @@ package org.codehaus.groovy.classgen.asm.sc
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
import org.codehaus.groovy.runtime.MethodClosure
+import org.junit.jupiter.api.Disabled
+import org.junit.jupiter.api.Test
+
+import static groovy.test.GroovyAssert.shouldFail
final class StaticCompilationTest extends AbstractBytecodeTestCase {
+ @Test
void testEmptyMethod() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m() { }
@@ -33,6 +38,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testPrimitiveReturn1() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
int m() { 1 }
@@ -44,6 +50,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testPrimitiveReturn2() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
long m() { 1L }
@@ -55,6 +62,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testPrimitiveReturn3() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
short m() { 1 }
@@ -67,6 +75,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testPrimitiveReturn4() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
byte m() { 1 }
@@ -79,6 +88,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testParameterReturns() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
int m(int i) { i }
@@ -106,6 +116,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11288
+ @Test
void testEmptyDeclaration0() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m() {
@@ -122,6 +133,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testEmptyDeclaration1() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
int m() {
@@ -139,6 +151,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11288
+ @Test
void testSingleAssignment0() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m() {
@@ -155,6 +168,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testSingleAssignment1() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
int m() {
@@ -172,6 +186,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11288
+ @Test
void testSingleAssignment2() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
class C {
@@ -194,6 +209,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11288
+ @Test
void testSingleAssignment3() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
class C {
@@ -236,6 +252,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11288
+ @Test
void testSubscriptAssignment1() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m(int[] i) {
@@ -261,6 +278,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11288
+ @Test
void testSubscriptAssignment2() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m(int[] i) {
@@ -279,6 +297,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11286
+ @Test
void testVoidMethod1() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m() {
@@ -298,6 +317,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11286
+ @Test
void testVoidMethod2() {
assert compile(method: 'm', '''import static java.lang.System.gc
@groovy.transform.CompileStatic
@@ -316,6 +336,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11286
+ @Test
void testVoidMethod3() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m() {
@@ -349,6 +370,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11286, GROOVY-11453
+ @Test
void testVoidMethod4() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m(List<C> list) {
@@ -431,6 +453,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
}
// GROOVY-11630
+ @Test
void testVoidMethod5() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m() {
@@ -449,6 +472,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testIntLeftShift() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m() {
@@ -462,6 +486,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testLongLeftShift() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m() {
@@ -475,7 +500,8 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
- void _testPlusPlus() {
+ @Disabled @Test
+ void testPlusPlus() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m(int i) {
i++
@@ -485,7 +511,8 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
- void _testMinusMinus() {
+ @Disabled @Test
+ void testMinusMinus() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m(int i) {
i--
@@ -495,6 +522,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testPlusEquals() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
int m() {
@@ -522,6 +550,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testPlusEqualsFromArgs() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m(int i, int j) {
@@ -542,6 +571,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testFlow() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
String m(String str) {
@@ -569,6 +599,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testInstanceOf() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m(Object str) {
@@ -584,6 +615,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testShouldGenerateDirectConstructorCall() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
class Foo {
@@ -600,6 +632,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testShouldGenerateDirectArrayConstruct() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m() {
@@ -615,6 +648,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testShouldGenerateDirectBooleanArrayConstruct() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m() {
@@ -632,6 +666,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testShouldTriggerDirectCallToOuterClassGetter() {
assert compile(method: 'fromInner', classNamePattern: '.*Inner.*', '''
class Holder {
@@ -667,6 +702,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testShouldOptimizeBytecodeByAvoidingCreationOfMopMethods() {
def clazz = new GroovyShell().evaluate '''import groovy.transform.*
@CompileStatic
@@ -685,6 +721,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
assert mopMethods.isEmpty()
}
+ @Test
void testShouldNotOptimizeBytecodeForMopMethodsBecauseOfSkip() {
def clazz = new GroovyShell().evaluate '''import groovy.transform.*
@CompileStatic
@@ -705,6 +742,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
}
// GROOVY-7124
+ @Test
void testUseInvokeVirtualPreferredOverInvokeInterface() {
assert compile(method: 'foo', classNamePattern: 'B', '''
interface A {
@@ -720,6 +758,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
''').hasStrictSequence(['INVOKEVIRTUAL B.m'])
}
+ @Test
void testShouldNotTryToCastToSupposedDelegateType() {
assertScript '''
@groovy.transform.CompileStatic
@@ -736,6 +775,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testShouldOptimizeCharInit() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m() {
@@ -748,6 +788,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testShouldOptimizeCharComparison() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m() {
@@ -782,6 +823,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testForEachLoopOptimization() {
def loop_init = [
'ALOAD', // load array (might be more complex than just ALOAD
in general case)
@@ -910,6 +952,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
}
}
+ @Test
void testCompareWithCharOptimization() {
String code = '''
@groovy.transform.CompileStatic
@@ -934,6 +977,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
assertScript(code)
}
+ @Test
void testShouldRemoveUnnecessaryCast() {
assert compile(method: 'm', '''@groovy.transform.CompileStatic
void m() {
@@ -948,6 +992,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testInstanceMethodReference() {
// dynamic case should be a method closure
assert String::toUpperCase instanceof MethodClosure
@@ -974,6 +1019,7 @@ final class StaticCompilationTest extends
AbstractBytecodeTestCase {
}
// GROOVY-6925
+ @Test
void testOuterSCInnerSTC() {
assert compile(classNamePattern: 'C', method: 'test', '''
import groovy.transform.*
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileArrayLengthAndGet.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileArrayLengthAndGet.groovy
index 6bcf4bdaca..ffc252a798 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileArrayLengthAndGet.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileArrayLengthAndGet.groovy
@@ -19,10 +19,14 @@
package org.codehaus.groovy.classgen.asm.sc
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
import static org.codehaus.groovy.control.CompilerConfiguration.DEFAULT as
config
+import static org.junit.jupiter.api.Assumptions.assumeFalse
-class StaticCompileArrayLengthAndGet extends AbstractBytecodeTestCase {
+final class StaticCompileArrayLengthAndGet extends AbstractBytecodeTestCase {
+
+ @Test
void testShouldCompileArrayLengthStatically() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -37,8 +41,9 @@ class StaticCompileArrayLengthAndGet extends
AbstractBytecodeTestCase {
assert obj.m([4,5,6] as Object[]) == 3
}
+ @Test
void testArrayGet1() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
// this test is done with indy in another tests case
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -51,11 +56,11 @@ class StaticCompileArrayLengthAndGet extends
AbstractBytecodeTestCase {
)
def obj = clazz.newInstance()
assert obj.m([4,5,6] as int[]) == 4
-
}
+ @Test
void testArraySet1() {
- if (config.indyEnabled) return;
+ assumeFalse(config.indyEnabled)
// this test is done with indy in another tests case
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -70,6 +75,5 @@ class StaticCompileArrayLengthAndGet extends
AbstractBytecodeTestCase {
int[] arr = [1,2,3]
obj.m(arr)
assert arr[0] == 666
-
}
}
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileClosureCallTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileClosureCallTest.groovy
index c680d91b3c..627dbccc98 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileClosureCallTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileClosureCallTest.groovy
@@ -19,12 +19,14 @@
package org.codehaus.groovy.classgen.asm.sc
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
/**
* Tests for static compilation: checks that closures are called properly.
*/
final class StaticCompileClosureCallTest extends AbstractBytecodeTestCase {
+ @Test
void testShouldCallClosure() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -38,6 +40,7 @@ final class StaticCompileClosureCallTest extends
AbstractBytecodeTestCase {
clazz.newInstance().run()
}
+ @Test
void testShouldCallClosureWithOneArg() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -51,6 +54,7 @@ final class StaticCompileClosureCallTest extends
AbstractBytecodeTestCase {
clazz.newInstance().run()
}
+ @Test
void testShouldCallClosureWithTwoArgs() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -64,6 +68,7 @@ final class StaticCompileClosureCallTest extends
AbstractBytecodeTestCase {
clazz.newInstance().run()
}
+ @Test
void testShouldCallClosureWithThreeArgs() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -77,6 +82,7 @@ final class StaticCompileClosureCallTest extends
AbstractBytecodeTestCase {
clazz.newInstance().run()
}
+ @Test
void testStaticCompilationOfClosures() {
assertScript '''
@groovy.transform.CompileStatic
@@ -116,6 +122,7 @@ final class StaticCompileClosureCallTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testWriteSharedVariableInClosure() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -129,6 +136,7 @@ final class StaticCompileClosureCallTest extends
AbstractBytecodeTestCase {
clazz.newInstance().main()
}
+ @Test
void testCallPrivateMethodFromClosure() {
assertScript '''
@groovy.transform.CompileStatic
@@ -145,6 +153,7 @@ final class StaticCompileClosureCallTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testCallStaticPrivateMethodFromClosure() {
assertScript '''
@groovy.transform.CompileStatic
@@ -161,6 +170,7 @@ final class StaticCompileClosureCallTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testCallMethodWithinClosure() {
assertScript '''
@groovy.transform.CompileStatic
@@ -174,6 +184,7 @@ final class StaticCompileClosureCallTest extends
AbstractBytecodeTestCase {
}
// GROOVY-6199
+ @Test
void testCallClassMethodFromNestedClosure() {
assertScript '''
class MyClass {
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileComparisonTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileComparisonTest.groovy
index 7802bd5785..324977392f 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileComparisonTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileComparisonTest.groovy
@@ -19,8 +19,11 @@
package org.codehaus.groovy.classgen.asm.sc
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
-class StaticCompileComparisonTest extends AbstractBytecodeTestCase {
+final class StaticCompileComparisonTest extends AbstractBytecodeTestCase {
+
+ @Test
void testCompareInts() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -33,6 +36,7 @@ class StaticCompileComparisonTest extends
AbstractBytecodeTestCase {
)
}
+ @Test
void testCompareDoubles() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -45,6 +49,7 @@ class StaticCompileComparisonTest extends
AbstractBytecodeTestCase {
)
}
+ @Test
void testCompareDoubleWithInt() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -57,6 +62,7 @@ class StaticCompileComparisonTest extends
AbstractBytecodeTestCase {
)
}
+ @Test
void testCompareArrayLen() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -69,6 +75,7 @@ class StaticCompileComparisonTest extends
AbstractBytecodeTestCase {
)
}
+ @Test
void testCompareArrayLenUsingIf() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -85,6 +92,7 @@ class StaticCompileComparisonTest extends
AbstractBytecodeTestCase {
)
}
+ @Test
void testIdentityCompare() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -98,6 +106,4 @@ class StaticCompileComparisonTest extends
AbstractBytecodeTestCase {
)
clazz.newInstance().main()
}
-
-
}
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileDGMMethodTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileDGMMethodTest.groovy
index 48114b73c6..252cf0ce09 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileDGMMethodTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileDGMMethodTest.groovy
@@ -19,8 +19,11 @@
package org.codehaus.groovy.classgen.asm.sc
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
-class StaticCompileDGMMethodTest extends AbstractBytecodeTestCase {
+final class StaticCompileDGMMethodTest extends AbstractBytecodeTestCase {
+
+ @Test
void testShouldCallToIntegerOnString() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -35,6 +38,7 @@ class StaticCompileDGMMethodTest extends
AbstractBytecodeTestCase {
clazz.newInstance().run()
}
+ @Test
void testShouldCallToIntegerOnGString() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -50,6 +54,7 @@ class StaticCompileDGMMethodTest extends
AbstractBytecodeTestCase {
clazz.newInstance().run()
}
+ @Test
void testEach() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -63,6 +68,7 @@ class StaticCompileDGMMethodTest extends
AbstractBytecodeTestCase {
clazz.newInstance().run()
}
+ @Test
void testCollect() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -75,5 +81,4 @@ class StaticCompileDGMMethodTest extends
AbstractBytecodeTestCase {
''')
clazz.newInstance().run()
}
-
}
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileInnerClassTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileInnerClassTest.groovy
index 3e5b8448b6..144952f4dd 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileInnerClassTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileInnerClassTest.groovy
@@ -19,8 +19,11 @@
package org.codehaus.groovy.classgen.asm.sc
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
-class StaticCompileInnerClassTest extends AbstractBytecodeTestCase {
+final class StaticCompileInnerClassTest extends AbstractBytecodeTestCase {
+
+ @Test
void testStaticCompileCallToOwnerField() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -35,9 +38,9 @@ class StaticCompileInnerClassTest extends
AbstractBytecodeTestCase {
assert c.foo() == '/tmp'
''')
clazz.newInstance().main()
-
}
+ @Test
void testStaticCompileCallToOwnerMethod() {
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
@@ -53,11 +56,10 @@ class StaticCompileInnerClassTest extends
AbstractBytecodeTestCase {
assert c.foo() == '/tmp'
''')
clazz.newInstance().main()
-
}
+ @Test
void testStaticCompileCallToOwnerPrivateMethod() {
-
def bytecode = compile([method:'m'],'''
@groovy.transform.CompileStatic
class Config {
@@ -78,6 +80,7 @@ class StaticCompileInnerClassTest extends
AbstractBytecodeTestCase {
)*/
}
+ @Test
void testAccessPrivateMemberFromAnotherInnerClass() {
assertScript '''
@groovy.transform.CompileStatic
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileMathTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileMathTest.groovy
index 95ec62776e..333db1a9e8 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileMathTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileMathTest.groovy
@@ -19,6 +19,7 @@
package org.codehaus.groovy.classgen.asm.sc
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
import static groovy.test.GroovyAssert.shouldFail
@@ -27,6 +28,7 @@ import static groovy.test.GroovyAssert.shouldFail
*/
final class StaticCompileMathTest extends AbstractBytecodeTestCase {
+ @Test
void testIntSum() {
assertScript '''
@groovy.transform.CompileStatic
@@ -39,6 +41,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testLongSum() {
assertScript '''
@groovy.transform.CompileStatic
@@ -51,6 +54,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testShortSum() {
assertScript '''
@groovy.transform.CompileStatic
@@ -63,6 +67,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testFloatSum() {
assertScript '''
@groovy.transform.CompileStatic
@@ -75,6 +80,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testDoubleSum() {
assertScript '''
@groovy.transform.CompileStatic
@@ -87,6 +93,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testDoublePlusInt() {
assertScript '''
@groovy.transform.CompileStatic
@@ -99,6 +106,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testIntMinusDouble() {
assertScript '''
@groovy.transform.CompileStatic
@@ -111,6 +119,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testIntMinusBigDec() {
extractionOptions = [method: 'm', print:true]
assertScript '''
@@ -122,6 +131,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testIntPlusBigDec() {
extractionOptions = [method: 'm', print:true]
assertScript '''
@@ -133,6 +143,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testIntMultiplyBigDec() {
extractionOptions = [method: 'm', print:true]
assertScript '''
@@ -144,6 +155,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testIntDivBigDec() {
extractionOptions = [method: 'm', print:true]
assertScript '''
@@ -155,6 +167,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testStaticCompilePiComputationWithPrimitives() {
// extractionOptions = [method: 'doIt', print:true]
assertScript '''@groovy.transform.CompileStatic
@@ -175,6 +188,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testStaticCompilePiComputationWithPrimitivesAndRangeLoop() {
// extractionOptions = [method: 'doIt', print:true]
assertScript '''@groovy.transform.CompileStatic
@@ -195,6 +209,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testStaticCompileLeftShiftEquals() {
assertScript '''
@groovy.transform.CompileStatic
@@ -207,6 +222,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testStaticCompileRightShiftEquals() {
assertScript '''
@groovy.transform.CompileStatic
@@ -219,6 +235,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testStaticCompilePlusEquals() {
assertScript '''
@groovy.transform.CompileStatic
@@ -231,6 +248,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testStaticCompileMinusEquals() {
assertScript '''
@groovy.transform.CompileStatic
@@ -243,6 +261,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testStaticCompileDivideEquals() {
assertScript '''
@groovy.transform.CompileStatic
@@ -264,6 +283,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
assert err =~ /Cannot assign value of type java.math.BigDecimal to
variable of type int/
}
+ @Test
void testStaticCompileMultiplyEquals() {
assertScript '''
@groovy.transform.CompileStatic
@@ -276,6 +296,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testStaticCompilePowerEquals() {
assertScript '''
@groovy.transform.CompileStatic
@@ -288,6 +309,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testStaticCompileModEquals() {
assertScript '''
@groovy.transform.CompileStatic
@@ -300,6 +322,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
'''
}
+ @Test
void testPrimitiveIntCompareNotEqualShouldUseFastPath() {
def source = '''
@groovy.transform.CompileStatic
@@ -319,6 +342,7 @@ final class StaticCompileMathTest extends
AbstractBytecodeTestCase {
])
}
+ @Test
void testPrimitiveLongCompareNotEqualShouldUseFastPath() {
def source = '''
@groovy.transform.CompileStatic
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileNullCompareOptimizationTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileNullCompareOptimizationTest.groovy
index d43e44c925..e87c3d04c2 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileNullCompareOptimizationTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompileNullCompareOptimizationTest.groovy
@@ -19,12 +19,14 @@
package org.codehaus.groovy.classgen.asm.sc
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
/**
* Unit tests for static compilation: null test optimizations.
*/
final class StaticCompileNullCompareOptimizationTest extends
AbstractBytecodeTestCase {
+ @Test
void testShouldUseIfNull1() {
def bytecode = compile(method:'m', '''
@groovy.transform.CompileStatic
@@ -35,6 +37,7 @@ final class StaticCompileNullCompareOptimizationTest extends
AbstractBytecodeTes
assert bytecode.hasStrictSequence(['IFNULL'])
}
+ @Test
void testShouldUseIfNull2() {
def bytecode = compile(method:'m', '''
@groovy.transform.CompileStatic
@@ -45,6 +48,7 @@ final class StaticCompileNullCompareOptimizationTest extends
AbstractBytecodeTes
assert bytecode.hasStrictSequence(['IFNULL'])
}
+ @Test
void testShouldUseIfNonNull1() {
def bytecode = compile(method:'m', '''
@groovy.transform.CompileStatic
@@ -55,6 +59,7 @@ final class StaticCompileNullCompareOptimizationTest extends
AbstractBytecodeTes
assert bytecode.hasStrictSequence(['IFNONNULL'])
}
+ @Test
void testShouldUseIfNonNull2() {
def bytecode = compile(method:'m', '''
@groovy.transform.CompileStatic
@@ -65,6 +70,7 @@ final class StaticCompileNullCompareOptimizationTest extends
AbstractBytecodeTes
assert bytecode.hasStrictSequence(['IFNONNULL'])
}
+ @Test
void testPrimitiveWithNullShouldBeOptimized1() {
def bytecode = compile(method:'m', '''
@groovy.transform.CompileStatic
@@ -75,6 +81,7 @@ final class StaticCompileNullCompareOptimizationTest extends
AbstractBytecodeTes
assert bytecode.hasStrictSequence(['ICONST_0', 'POP'])
}
+ @Test
void testPrimitiveWithNullShouldBeOptimized2() {
def bytecode = compile(method:'m', '''
@groovy.transform.CompileStatic
@@ -85,6 +92,7 @@ final class StaticCompileNullCompareOptimizationTest extends
AbstractBytecodeTes
assert bytecode.hasStrictSequence(['ICONST_0', 'POP'])
}
+ @Test
void testOptimizeGroovyTruthForPrimitiveBoolean1() {
def bytecode = compile(method:'m', '''
@groovy.transform.CompileStatic
@@ -101,6 +109,7 @@ final class StaticCompileNullCompareOptimizationTest
extends AbstractBytecodeTes
])
}
+ @Test
void testOptimizeGroovyTruthForPrimitiveBoolean2() {
def bytecode = compile(method:'m', '''
@groovy.transform.CompileStatic
@@ -123,6 +132,7 @@ final class StaticCompileNullCompareOptimizationTest
extends AbstractBytecodeTes
])
}
+ @Test
void testOptimizeGroovyTruthForPrimitiveBoolean3() {
def bytecode = compile(method:'m', '''
@groovy.transform.CompileStatic
@@ -139,6 +149,7 @@ final class StaticCompileNullCompareOptimizationTest
extends AbstractBytecodeTes
])
}
+ @Test
void testOptimizeGroovyTruthForNonPrimitiveBoolean() {
def bytecode = compile(method:'m', '''
@groovy.transform.CompileStatic
@@ -161,6 +172,7 @@ final class StaticCompileNullCompareOptimizationTest
extends AbstractBytecodeTes
])
}
+ @Test
void testOptimizeGroovyTruthForPrimitiveNumberType() {
def bytecode = compile(method:'m', '''
@groovy.transform.CompileStatic
@@ -183,6 +195,7 @@ final class StaticCompileNullCompareOptimizationTest
extends AbstractBytecodeTes
])
}
+ @Test
void testNoGroovyTruthOptimizationForObject() {
def bytecode = compile(method:'m', '''
@groovy.transform.CompileStatic
@@ -203,6 +216,7 @@ final class StaticCompileNullCompareOptimizationTest
extends AbstractBytecodeTes
])
}
+ @Test
void testNoGroovyTruthOptimizationForString() {
def bytecode = compile(method:'m', '''
@groovy.transform.CompileStatic
@@ -223,6 +237,7 @@ final class StaticCompileNullCompareOptimizationTest
extends AbstractBytecodeTes
])
}
+ @Test
void testGroovyTruthOptimizationForFinalClass() {
def bytecode = compile(method:'m', '''
final class A {
@@ -246,6 +261,7 @@ final class StaticCompileNullCompareOptimizationTest
extends AbstractBytecodeTes
assert !bytecode.hasSequence(['INVOKEDYNAMIC cast(LA;)Z'])
}
+ @Test
void testGroovyTruthOptimizationForPrivateInnerClass() {
def bytecode = compile(method:'m', '''
class A {
@@ -271,6 +287,7 @@ final class StaticCompileNullCompareOptimizationTest
extends AbstractBytecodeTes
assert !bytecode.hasSequence(['INVOKEDYNAMIC cast(LA$B;)Z'])
}
+ @Test
void testNoGroovyTruthOptimizationForPublicInnerClass() {
def bytecode = compile(method:'m', '''
class A {
@@ -296,6 +313,7 @@ final class StaticCompileNullCompareOptimizationTest
extends AbstractBytecodeTes
}
// GROOVY-10711
+ @Test
void testNoGroovyTruthOptimizationIfProvidesAsBoolean() {
def bytecode = compile(method:'m', '''
@groovy.transform.CompileStatic
@@ -323,6 +341,7 @@ final class StaticCompileNullCompareOptimizationTest
extends AbstractBytecodeTes
])
}
+ @Test
void testCompare() {
assertScript '''
class Pogo {
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompilePostfixPrefixTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompilePostfixPrefixTest.groovy
index d19651603d..b1c20662e2 100644
---
a/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompilePostfixPrefixTest.groovy
+++
b/src/test/groovy/org/codehaus/groovy/classgen/asm/sc/StaticCompilePostfixPrefixTest.groovy
@@ -19,8 +19,11 @@
package org.codehaus.groovy.classgen.asm.sc
import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+import org.junit.jupiter.api.Test
-class StaticCompilePostfixPrefixTest extends AbstractBytecodeTestCase {
+final class StaticCompilePostfixPrefixTest extends AbstractBytecodeTestCase {
+
+ @Test
void testPostfixOnInt() {
def bytecode = compile([method:'m'], '''@groovy.transform.CompileStatic
void m() {
@@ -44,6 +47,7 @@ class StaticCompilePostfixPrefixTest extends
AbstractBytecodeTestCase {
clazz.newInstance().m()
}
+ @Test
void testPostfixOnDate() {
def bytecode = compile([method:'m'],'''@groovy.transform.CompileStatic
void m() {
@@ -71,6 +75,7 @@ class StaticCompilePostfixPrefixTest extends
AbstractBytecodeTestCase {
clazz.newInstance().m()
}
+ @Test
void testPrefixOnInt() {
def bytecode = compile([method:'m'],'''@groovy.transform.CompileStatic
void m() {
@@ -93,6 +98,7 @@ class StaticCompilePostfixPrefixTest extends
AbstractBytecodeTestCase {
clazz.newInstance().m()
}
+ @Test
void testPrefixOnDate() {
def bytecode = compile([method:'m'],'''@groovy.transform.CompileStatic
void m() {
@@ -115,5 +121,4 @@ class StaticCompilePostfixPrefixTest extends
AbstractBytecodeTestCase {
}
''')
}
-
}