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 8a40250d99 junit jupiter
8a40250d99 is described below
commit 8a40250d9902b71edfced5475cd3dfe1d09b5059
Author: Eric Milles <[email protected]>
AuthorDate: Mon Mar 2 13:18:08 2026 -0600
junit jupiter
---
src/test/groovy/bugs/ArrayMethodCallBug.groovy | 4 +-
.../bugs/ClosureWithStaticVariablesBug.groovy | 5 +-
.../groovy/bugs/DoubleSizeParametersBug.groovy | 11 +++--
.../groovy/bugs/IterateOverCustomTypeBug.groovy | 4 +-
src/test/groovy/bugs/NestedClosure2Bug.groovy | 15 +++---
.../bugs/SubscriptOnPrimitiveTypeArrayBug.groovy | 8 +++-
.../groovy/bugs/SubscriptOnStringArrayBug.groovy | 15 +++---
src/test/groovy/bugs/VariableScopingBug.groovy | 47 +++++++++----------
.../groovy/SerializableCompatibilityTest.groovy | 7 ++-
.../groovy/classgen/ConstructorIssueTest.groovy | 53 ----------------------
.../groovy/runtime/StaticPrintlnTest.groovy | 6 ++-
.../groovy/groovy/bugs/TestSupport.java | 6 +--
12 files changed, 75 insertions(+), 106 deletions(-)
diff --git a/src/test/groovy/bugs/ArrayMethodCallBug.groovy
b/src/test/groovy/bugs/ArrayMethodCallBug.groovy
index 114079a513..dc3f73bee3 100644
--- a/src/test/groovy/bugs/ArrayMethodCallBug.groovy
+++ b/src/test/groovy/bugs/ArrayMethodCallBug.groovy
@@ -19,9 +19,11 @@
package bugs
import groovy.bugs.TestSupport
+import org.junit.jupiter.api.Test
-class ArrayMethodCallBug extends TestSupport {
+final class ArrayMethodCallBug extends TestSupport {
+ @Test
void testMethodCallingWithArrayBug() {
def array = getMockArguments()
diff --git a/src/test/groovy/bugs/ClosureWithStaticVariablesBug.groovy
b/src/test/groovy/bugs/ClosureWithStaticVariablesBug.groovy
index 250f517f5b..f6901c0d45 100644
--- a/src/test/groovy/bugs/ClosureWithStaticVariablesBug.groovy
+++ b/src/test/groovy/bugs/ClosureWithStaticVariablesBug.groovy
@@ -18,12 +18,13 @@
*/
package bugs
-import groovy.bugs.TestSupport
+import org.junit.jupiter.api.Test
-class ClosureWithStaticVariablesBug extends TestSupport {
+final class ClosureWithStaticVariablesBug {
static def y = [:]
+ @Test
void testBug() {
def c = { x ->
return {
diff --git a/src/test/groovy/bugs/DoubleSizeParametersBug.groovy
b/src/test/groovy/bugs/DoubleSizeParametersBug.groovy
index 77ef8ff22c..3b71c089bc 100644
--- a/src/test/groovy/bugs/DoubleSizeParametersBug.groovy
+++ b/src/test/groovy/bugs/DoubleSizeParametersBug.groovy
@@ -18,18 +18,21 @@
*/
package bugs
-import groovy.bugs.TestSupport
+import org.junit.jupiter.api.Test
-class DoubleSizeParametersBug extends TestSupport {
+import static groovy.test.GroovyAssert.assertScript
+final class DoubleSizeParametersBug {
+
+ @Test
void testBug() {
- assertScript """
+ assertScript '''
def foo(double x, y) {
println "x: "+x
println "y: "+y
}
foo(10.0d, 0)
- """
+ '''
}
}
diff --git a/src/test/groovy/bugs/IterateOverCustomTypeBug.groovy
b/src/test/groovy/bugs/IterateOverCustomTypeBug.groovy
index 2e694b3eab..3d28c4e3ba 100644
--- a/src/test/groovy/bugs/IterateOverCustomTypeBug.groovy
+++ b/src/test/groovy/bugs/IterateOverCustomTypeBug.groovy
@@ -19,9 +19,11 @@
package bugs
import groovy.bugs.TestSupport
+import org.junit.jupiter.api.Test
-class IterateOverCustomTypeBug extends TestSupport {
+final class IterateOverCustomTypeBug extends TestSupport {
+ @Test
void testBug() {
def object = this
diff --git a/src/test/groovy/bugs/NestedClosure2Bug.groovy
b/src/test/groovy/bugs/NestedClosure2Bug.groovy
index 3c934a2770..b47cdb1e95 100644
--- a/src/test/groovy/bugs/NestedClosure2Bug.groovy
+++ b/src/test/groovy/bugs/NestedClosure2Bug.groovy
@@ -18,14 +18,15 @@
*/
package bugs
-import groovy.bugs.TestSupport
+import org.junit.jupiter.api.Test
-/**
- */
-class NestedClosure2Bug extends TestSupport {
+import static groovy.test.GroovyAssert.assertScript
+
+final class NestedClosure2Bug {
Object f
+ @Test
void testFieldBug() {
def closure = {
return {
@@ -38,6 +39,7 @@ class NestedClosure2Bug extends TestSupport {
assert f == 123
}
+ @Test
void testBugOutsideOfScript() {
def a = 123
def b = 456
@@ -61,8 +63,9 @@ class NestedClosure2Bug extends TestSupport {
assert value == 123
}
+ @Test
void testBug() {
- assertScript """
+ assertScript '''
def a = 123
def closure = {
return {
@@ -76,6 +79,6 @@ class NestedClosure2Bug extends TestSupport {
value = c3()
assert value == 123
-"""
+ '''
}
}
diff --git a/src/test/groovy/bugs/SubscriptOnPrimitiveTypeArrayBug.groovy
b/src/test/groovy/bugs/SubscriptOnPrimitiveTypeArrayBug.groovy
index 85168647ed..7964cd665a 100644
--- a/src/test/groovy/bugs/SubscriptOnPrimitiveTypeArrayBug.groovy
+++ b/src/test/groovy/bugs/SubscriptOnPrimitiveTypeArrayBug.groovy
@@ -19,11 +19,14 @@
package bugs
import groovy.bugs.TestSupport
+import org.junit.jupiter.api.Test
+
+final class SubscriptOnPrimitiveTypeArrayBug extends TestSupport {
-class SubscriptOnPrimitiveTypeArrayBug extends TestSupport {
int[] ia; // type is not necessary
int i1;
+ @Test
void testBug() {
def array = getIntArray() // this function returns [I, true primitive
array
@@ -42,6 +45,7 @@ class SubscriptOnPrimitiveTypeArrayBug extends TestSupport {
assert range == [2, 8]
}
+ @Test
void testGroovyIntArray() {
int[] ia = [1, 2]
int[] ia1 = ia; // type is not necessary
@@ -50,11 +54,11 @@ class SubscriptOnPrimitiveTypeArrayBug extends TestSupport {
assert i2 == 1
}
+ @Test
void testIntArrayObjectRangeSelection() {
int[] ia = [1000, 1100, 1200, 1300, 1400]
def range = new ObjectRange(new Integer(1), new Integer(3))
def selected = ia[range]
assert selected == [1100, 1200, 1300]
}
-
}
diff --git a/src/test/groovy/bugs/SubscriptOnStringArrayBug.groovy
b/src/test/groovy/bugs/SubscriptOnStringArrayBug.groovy
index f962c743e0..148ebd67a5 100644
--- a/src/test/groovy/bugs/SubscriptOnStringArrayBug.groovy
+++ b/src/test/groovy/bugs/SubscriptOnStringArrayBug.groovy
@@ -19,22 +19,25 @@
package bugs
import groovy.bugs.TestSupport
+import org.junit.jupiter.api.Test
-class SubscriptOnStringArrayBug extends TestSupport {
+final class SubscriptOnStringArrayBug extends TestSupport {
+ @Test
void testArraySubscript() {
def array = getMockArguments()
- assert array[1] == "b"
+ assert array[1] == 'b'
- array[0] = "d"
+ array[0] = 'd'
- assert array[0] == "d"
+ assert array[0] == 'd'
}
+ @Test
void testRobsTestCase() {
- def array = "one two three".split(" ")
+ def array = 'one two three'.split(' ')
- assert array[1] == "two"
+ assert array[1] == 'two'
}
}
diff --git a/src/test/groovy/bugs/VariableScopingBug.groovy
b/src/test/groovy/bugs/VariableScopingBug.groovy
index e0a407e640..2d2a22657f 100644
--- a/src/test/groovy/bugs/VariableScopingBug.groovy
+++ b/src/test/groovy/bugs/VariableScopingBug.groovy
@@ -18,35 +18,36 @@
*/
package bugs
-import groovy.bugs.TestSupport
+import org.junit.jupiter.api.Test
-class VariableScopingBug extends TestSupport {
+import static groovy.test.GroovyAssert.assertScript
+import static groovy.test.GroovyAssert.shouldFail
+final class VariableScopingBug {
+
+ @Test
void testUndeclaredVariable() {
- shouldFail(MissingPropertyException) {
- def shell = new GroovyShell()
- shell.evaluate("""
- class SomeTest {
- void run() {
- for (z in 0..2) {
- def x = [1, 2, 3]
- }
+ shouldFail MissingPropertyException, '''
+ class SomeTest {
+ void run() {
+ for (z in 0..2) {
+ def x = [1, 2, 3]
+ }
- for (t in 0..3) {
- for (y in x) { // previous x no longer be in scope
- println x
- }
+ for (t in 0..3) {
+ for (y in x) { // previous x no longer be in scope
+ println x
}
}
}
- new SomeTest().run()
- """)
- }
+ }
+ new SomeTest().run()
+ '''
}
+ @Test
void testVariableReuseAllowedInDifferentScopes() {
- def shell = new GroovyShell()
- shell.evaluate("""
+ assertScript '''
for (z in 0..2) {
def x = [1, 2, 3]
}
@@ -55,13 +56,13 @@ class VariableScopingBug extends TestSupport {
def x = 123
println x
}
- """)
+ '''
}
// GROOVY-5961
+ @Test
void testVariableInAicInsideStaticMethod() {
- def shell = new GroovyShell()
- shell.evaluate("""
+ assertScript '''
static foo() {
new LinkedList([1, 2]) {
int count
@@ -73,6 +74,6 @@ class VariableScopingBug extends TestSupport {
assert l.count == 0
assert l[0] == 1
assert l.count == 1
- """)
+ '''
}
}
diff --git a/src/test/groovy/groovy/SerializableCompatibilityTest.groovy
b/src/test/groovy/groovy/SerializableCompatibilityTest.groovy
index 4acbc44a73..499fb18e6f 100644
--- a/src/test/groovy/groovy/SerializableCompatibilityTest.groovy
+++ b/src/test/groovy/groovy/SerializableCompatibilityTest.groovy
@@ -18,9 +18,11 @@
*/
package groovy
-import groovy.bugs.TestSupport
+import org.junit.jupiter.api.Test
-class SerializableCompatibilityTest extends TestSupport {
+final class SerializableCompatibilityTest {
+
+ @Test
void testSerialize() {
def obj = new GroovyRuntimeException('boom')
assert obj instanceof GroovyRuntimeException
@@ -34,6 +36,7 @@ class SerializableCompatibilityTest extends TestSupport {
println out.toByteArray().encodeBase64().toString()
}
+ @Test
void testDeserialize() {
// generated by testSerialize
def serializedObjectStr_2_4_X =
'rO0ABXNyACJncm9vdnkubGFuZy5Hcm9vdnlSdW50aW1lRXhjZXB0aW9u/VHW5CcH3PYCAAJMAAZtb2R1bGV0ACRMb3JnL2NvZGVoYXVzL2dyb292eS9hc3QvTW9kdWxlTm9kZTtMAARub2RldAAhTG9yZy9jb2RlaGF1cy9ncm9vdnkvYXN0L0FTVE5vZGU7eHIAGmphdmEubGFuZy5SdW50aW1lRXhjZXB0aW9unl8GRwo0g+UCAAB4cgATamF2YS5sYW5nLkV4Y2VwdGlvbtD9Hz4aOxzEAgAAeHIAE2phdmEubGFuZy5UaHJvd2FibGXVxjUnOXe4ywMABEwABWNhdXNldAAVTGphdmEvbGFuZy9UaHJvd2FibGU7TAANZGV0YWlsTWVzc2FnZXQAEkxqYXZhL2xhbmcvU3RyaW5nO1sACnN0YWNrVHJhY2V0AB5
[...]
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/ConstructorIssueTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/ConstructorIssueTest.groovy
deleted file mode 100644
index 754f88a5f6..0000000000
--- a/src/test/groovy/org/codehaus/groovy/classgen/ConstructorIssueTest.groovy
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.codehaus.groovy.classgen
-
-import groovy.bugs.TestSupport
-
-class ConstructorIssueTest extends TestSupport {
-
- ConstructorIssueTest() {
- //println("Created test case!")
- }
-
- ConstructorIssueTest(String[] args) {
- //println("Created test case!")
- }
-
- static void main(args) {
- //println("in main() - called with ${array}")
-
- def foo = new ConstructorIssueTest()
- foo.done()
-
- //System.out.println("Done");
- }
-
- void done() {
- println("Yeah, I've been made")
- }
-
- void testConstructorIssue() {
- def array = getMockArguments()
-
- main(array)
-
- new ConstructorIssueTest(array).done()
- }
-}
diff --git
a/src/test/groovy/org/codehaus/groovy/runtime/StaticPrintlnTest.groovy
b/src/test/groovy/org/codehaus/groovy/runtime/StaticPrintlnTest.groovy
index c2ca966a60..c2dfe7126c 100644
--- a/src/test/groovy/org/codehaus/groovy/runtime/StaticPrintlnTest.groovy
+++ b/src/test/groovy/org/codehaus/groovy/runtime/StaticPrintlnTest.groovy
@@ -19,9 +19,11 @@
package org.codehaus.groovy.runtime
import groovy.bugs.TestSupport
+import org.junit.jupiter.api.Test
-class StaticPrintlnTest extends TestSupport {
+final class StaticPrintlnTest extends TestSupport {
+ @Test
void testStaticPrint() {
main(getMockArguments())
}
@@ -29,4 +31,4 @@ class StaticPrintlnTest extends TestSupport {
static void main(args) {
println("called with: " + args)
}
-}
\ No newline at end of file
+}
diff --git a/src/testFixtures/groovy/groovy/bugs/TestSupport.java
b/src/testFixtures/groovy/groovy/bugs/TestSupport.java
index a1730ccb92..9369507b15 100644
--- a/src/testFixtures/groovy/groovy/bugs/TestSupport.java
+++ b/src/testFixtures/groovy/groovy/bugs/TestSupport.java
@@ -18,15 +18,13 @@
*/
package groovy.bugs;
-import groovy.test.GroovyTestCase;
-
import java.util.Iterator;
import java.util.List;
/**
- * Base class for test cases
+ * Base class for test cases.
*/
-public abstract class TestSupport extends GroovyTestCase {
+public abstract class TestSupport {
public String[] getMockArguments() {
return new String[]{"a", "b", "c"};