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 723371cb83 junit jupiter
723371cb83 is described below
commit 723371cb83c9533c20110910f681536f037a8d1d
Author: Eric Milles <[email protected]>
AuthorDate: Fri Mar 20 09:35:51 2026 -0500
junit jupiter
---
src/test/groovy/bugs/ByteIndexBug.groovy | 14 +--
src/test/groovy/bugs/ClosureVariableBug.groovy | 15 +--
...oovy3156And2621Bug.groovy => Groovy2621.groovy} | 33 +++---
.../{Groovy308_Bug.groovy => Groovy308.groovy} | 15 +--
.../{Groovy3135Bug.groovy => Groovy3135.groovy} | 43 ++++---
.../{Groovy3139Bug.groovy => Groovy3139.groovy} | 30 ++---
src/test/groovy/bugs/Groovy3163.groovy | 78 +++++++++++++
src/test/groovy/bugs/Groovy3163Bug.groovy | 83 -------------
.../{Groovy3175_Bug.groovy => Groovy3175.groovy} | 31 +++--
...oadInvokeMethodBug.groovy => Groovy3205.groovy} | 36 ++----
src/test/groovy/bugs/Groovy3205Bug.groovy | 35 ------
...StaticInClosureBug.groovy => Groovy3208.groovy} | 30 +++--
src/test/groovy/bugs/Groovy3208Bug.groovy | 50 --------
...MarkupAndMethodBug.groovy => Groovy3235.groovy} | 42 +++----
src/test/groovy/bugs/Groovy3235Bug.groovy | 47 --------
src/test/groovy/bugs/Groovy3238.groovy | 43 +++++++
src/test/groovy/bugs/Groovy3238Bug.groovy | 39 -------
.../{Groovy325_Bug.groovy => Groovy325.groovy} | 18 +--
.../{Groovy3304Bug.groovy => Groovy3304.groovy} | 17 ++-
.../{Groovy3305Bug.groovy => Groovy3305.groovy} | 20 ++--
src/test/groovy/bugs/Groovy3311.groovy | 2 -
.../{Groovy3335Bug.groovy => Groovy3335.groovy} | 2 +-
.../{Groovy3339Bug.groovy => Groovy3339.groovy} | 2 +-
.../{Groovy3383Bug.groovy => Groovy3383.groovy} | 14 +--
.../{Groovy3389Bug.groovy => Groovy3389.groovy} | 10 +-
src/test/groovy/bugs/GuillaumesMapBug.groovy | 8 +-
src/test/groovy/bugs/MarkupAndMethodBug.groovy | 10 +-
src/test/groovy/bugs/MethodDispatchBug.groovy | 20 ++--
.../groovy/bugs/OverloadInvokeMethodBug.groovy | 26 ++---
src/test/groovy/bugs/RodsBug.groovy | 24 ++--
src/test/groovy/bugs/StaticMethodCallBug.groovy | 8 +-
src/test/groovy/bugs/SuperMethod2Bug.groovy | 128 ++++++++++-----------
src/test/groovy/bugs/ToStringBug.groovy | 8 +-
src/test/groovy/bugs/TryCatchBug.groovy | 7 +-
src/test/groovy/bugs/UseStaticInClosureBug.groovy | 15 +--
src/test/groovy/groovy/ClosureInClosureTest.groovy | 19 +--
.../groovy/groovy/ClosureMethodCallTest.groovy | 9 +-
.../groovy/groovy/PrimitiveTypeFieldTest.groovy | 5 +-
.../org/codehaus/groovy/classgen/RunBugsTest.java | 102 ----------------
39 files changed, 423 insertions(+), 715 deletions(-)
diff --git a/src/test/groovy/bugs/ByteIndexBug.groovy
b/src/test/groovy/bugs/ByteIndexBug.groovy
index 27c886fbcb..dcee2c10e7 100644
--- a/src/test/groovy/bugs/ByteIndexBug.groovy
+++ b/src/test/groovy/bugs/ByteIndexBug.groovy
@@ -22,15 +22,15 @@ import org.junit.jupiter.api.Test
final class ByteIndexBug {
- // TODO: this tests a string with 128 nulls - is that what is intended?
+ // TODO: This tests a string with 128 nulls - is that what is intended?
@Test
void testBug() {
- def sb = new StringBuffer("\"\"\"\n")
- for (j in 0..127){ // 126 is okay.
- sb.append('$').append("{x}")
+ def sb = new StringBuilder('"""\n')
+ for (j in 0..127) { // 126 is okay
+ sb.append('${x}')
}
- sb.append("\n\"\"\"\n")
- def b = new Binding(x:null)
- new GroovyShell(b).evaluate(sb.toString(),"foo")
+ sb.append('\n"""\n')
+ def b = new Binding(x: null)
+ new GroovyShell(b).evaluate(sb.toString(), 'foo')
}
}
diff --git a/src/test/groovy/bugs/ClosureVariableBug.groovy
b/src/test/groovy/bugs/ClosureVariableBug.groovy
index bc52b56384..95e090d64f 100644
--- a/src/test/groovy/bugs/ClosureVariableBug.groovy
+++ b/src/test/groovy/bugs/ClosureVariableBug.groovy
@@ -53,30 +53,27 @@ final class ClosureVariableBug {
}
protected Integer callClosure(collection) {
- Integer x
- /** @todo
Integer x = 0
- */
collection.each { x = it }
return x
}
@Test
void testLocalVariableWithPrimitiveType() {
- assertScript """
+ assertScript '''
int x
1.times { x=2 }
assert x==2
- """
- assertScript """
+ '''
+ assertScript '''
long x
1.times { x=2 }
assert x==2
- """
- assertScript """
+ '''
+ assertScript '''
double x
1.times { x=2 }
assert x==2
- """
+ '''
}
}
diff --git a/src/test/groovy/bugs/Groovy3156And2621Bug.groovy
b/src/test/groovy/bugs/Groovy2621.groovy
similarity index 87%
rename from src/test/groovy/bugs/Groovy3156And2621Bug.groovy
rename to src/test/groovy/bugs/Groovy2621.groovy
index 98303d39ce..e81be2164d 100644
--- a/src/test/groovy/bugs/Groovy3156And2621Bug.groovy
+++ b/src/test/groovy/bugs/Groovy2621.groovy
@@ -20,20 +20,30 @@ package bugs
import org.junit.jupiter.api.Test
+final class Groovy2621 {
-class Groovy3156And2621Bug {
@Test
- void testMethodNameResolutionInANestedClosure() {
- assert m() == 'method'
- assert c1() == 'method'
+ void testSimilarNamesForMethodAndLocalWithLocalAsMethodArgument() {
+ def convention = 'value'
+ 1.times {
+ this.convention(convention)
+ }
}
+ void convention(String arg) {
+ }
+
+
//--------------------------------------------------------------------------
+
+ // GROOVY-3156
@Test
- void testSimilarNamesForMethodAndLocalWithLocalAsMethodArgument() {
- failingExecute()
+ void testMethodNameResolutionInNestedClosure() {
+ assert m() == 'method'
+ assert c1() == 'method'
}
def m = { return 'method' }
+
def c1 = {
def m = { return 'c1' }
def c2 = {
@@ -43,18 +53,9 @@ class Groovy3156And2621Bug {
* It should resolve to outermost class' m().
*/
assert m() == 'c1'
+
return this.m()
}
return c2()
}
-
- void convention(String arg) {
- }
-
- void failingExecute() {
- def convention= 'value'
- 1.times {
- this.convention(convention)
- }
- }
}
diff --git a/src/test/groovy/bugs/Groovy308_Bug.groovy
b/src/test/groovy/bugs/Groovy308.groovy
similarity index 82%
rename from src/test/groovy/bugs/Groovy308_Bug.groovy
rename to src/test/groovy/bugs/Groovy308.groovy
index 9c94119f22..dd414eb9b5 100644
--- a/src/test/groovy/bugs/Groovy308_Bug.groovy
+++ b/src/test/groovy/bugs/Groovy308.groovy
@@ -20,25 +20,22 @@ package bugs
import org.junit.jupiter.api.Test
-/**
- */
-class Groovy308_Bug {
+final class Groovy308 {
@Test
void testBug() {
def out = new StringWriter()
- out << "hello " << "world!"
+ out << 'hello ' << 'world!'
def value = out.toString()
- assert value == "hello world!"
+ assert value == 'hello world!'
out = new ByteArrayOutputStream()
- out << "hello " << "world!"
+ out << 'hello ' << 'world!'
value = new String(out.toByteArray())
- assert value == "hello world!"
+ assert value == 'hello world!'
- System.out << "hello" << " world!"
+ System.out << 'hello' << ' world!'
}
}
-
diff --git a/src/test/groovy/bugs/Groovy3135Bug.groovy
b/src/test/groovy/bugs/Groovy3135.groovy
similarity index 58%
rename from src/test/groovy/bugs/Groovy3135Bug.groovy
rename to src/test/groovy/bugs/Groovy3135.groovy
index f8df22d519..67df2297d4 100644
--- a/src/test/groovy/bugs/Groovy3135Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3135.groovy
@@ -20,59 +20,58 @@ package bugs
import org.junit.jupiter.api.Test
+final class Groovy3135 {
-class Groovy3135Bug {
- static Byte b = Byte.parseByte("1")
- static Short s = Short.parseShort("2")
- static Integer i = Integer.parseInt("3")
- static Long l = Long.parseLong("4")
- static Float f = Float.parseFloat("5")
- static Double d = Double.parseDouble("6")
- static BigInteger bi = new BigInteger("7")
- static BigDecimal bd = new BigDecimal("8")
+ private static Byte b = Byte.parseByte('1')
+ private static Short s = Short.parseShort('2')
+ private static Integer i = Integer.parseInt('3')
+ private static Long l = Long.parseLong('4')
+ private static Float f = Float.parseFloat('5')
+ private static Double d = Double.parseDouble('6')
+ private static BigInteger bi = new BigInteger('7')
+ private static BigDecimal bd = new BigDecimal('8')
- def values
+ private Object values
@Test
void testConversionForPrimitiveTypeVarArgs() {
-
- setVarArgsShort("", b, s)
+ setVarArgsShort('', b, s)
checkConversionAndVarArgCount(Short.TYPE, 2)
- setVarArgsInteger("", b, s, i)
+ setVarArgsInteger('', b, s, i)
checkConversionAndVarArgCount(Integer.TYPE, 3)
- setVarArgsLong("", b, s, i, l)
+ setVarArgsLong('', b, s, i, l)
checkConversionAndVarArgCount(Long.TYPE, 4)
- setVarArgsFloat("", b, s, i, l, f)
+ setVarArgsFloat('', b, s, i, l, f)
checkConversionAndVarArgCount(Float.TYPE, 5)
- setVarArgsDouble("", b, s, i, l, f, d, bi, bd)
+ setVarArgsDouble('', b, s, i, l, f, d, bi, bd)
checkConversionAndVarArgCount(Double.TYPE, 8)
}
- def setVarArgsShort(String str, short... varArgValues) {
+ void setVarArgsShort(String str, short... varArgValues) {
values = varArgValues
}
- def setVarArgsInteger(String str, int... varArgValues) {
+ void setVarArgsInteger(String str, int... varArgValues) {
values = varArgValues
}
- def setVarArgsLong(String str, long... varArgValues) {
+ void setVarArgsLong(String str, long... varArgValues) {
values = varArgValues
}
- def setVarArgsFloat(String str, float... varArgValues) {
+ void setVarArgsFloat(String str, float... varArgValues) {
values = varArgValues
}
- def setVarArgsDouble(String str, double... varArgValues) {
+ void setVarArgsDouble(String str, double... varArgValues) {
values = varArgValues
}
- def checkConversionAndVarArgCount(expectedType, varArgsCount) {
+ void checkConversionAndVarArgCount(expectedType, varArgsCount) {
assert values.class.componentType == expectedType
assert values.size() == varArgsCount
}
diff --git a/src/test/groovy/bugs/Groovy3139Bug.groovy
b/src/test/groovy/bugs/Groovy3139.groovy
similarity index 76%
rename from src/test/groovy/bugs/Groovy3139Bug.groovy
rename to src/test/groovy/bugs/Groovy3139.groovy
index 16d61fd26d..2030f29c0c 100644
--- a/src/test/groovy/bugs/Groovy3139Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3139.groovy
@@ -21,14 +21,14 @@ package bugs
import groovy.mock.interceptor.StubFor
import org.junit.jupiter.api.Test
-class Groovy3139Bug {
+final class Groovy3139 {
@Test
void testStubbingIssueDueToCachingWhenUsing2Stubs() {
def urlStub1 = new StubFor(URL)
- urlStub1.demand.openConnection {""}
+ urlStub1.demand.openConnection {''}
urlStub1.use {
- def get = new Get2(url: "http://localhost")
+ def get = new Get2(url: 'http://localhost')
def result = get.text
}
@@ -36,24 +36,26 @@ class Groovy3139Bug {
// the following stubbed call is on urlStub2 and its demand cound
should be separate.
// Currently due to caching of MockProxyMetaClass, it gets counted
towards urlStub1 demands
// and throws "End of demands" exception
- urlStub2.demand.openConnection {""}
+ urlStub2.demand.openConnection {''}
urlStub2.use {
- def get = new Get2(url: "http://localhost")
+ def get = new Get2(url: 'http://localhost')
def result = get.text
}
}
-}
-class Get2{
- String url
+ static class Get2 {
+
+ String url
- String getText() {
+ String getText() {
def aUrl = new URL(toString())
- def conn = aUrl.openConnection()
- return "DUMMY"
- }
+ def conn = aUrl.openConnection()
+ return 'DUMMY'
+ }
- String toString(){
- return url
+ @Override
+ String toString() {
+ return url
+ }
}
}
diff --git a/src/test/groovy/bugs/Groovy3163.groovy
b/src/test/groovy/bugs/Groovy3163.groovy
new file mode 100644
index 0000000000..102edf0e9e
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy3163.groovy
@@ -0,0 +1,78 @@
+/*
+ * 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 bugs
+
+import org.junit.jupiter.api.Test
+
+final class Groovy3163 {
+
+ @Test
+ void testSuperOverStatic() {
+ def siws = new Groovy3163SomeImplementorWithStatic()
+
+ assert siws.build(1)[0] == 1
+
+ def c = { -> 'foo ' }
+
+ //def s = c as Script
+ //assert s.is(siws.build(s)[0])
+
+ assert c.is(siws.build(c)[0])
+ }
+
+ static class Groovy3163SomeBaseClass {
+
+ Object build(Integer i) {
+ return i
+ }
+
+ Object build(BigInteger i) {
+ return i
+ }
+
+ Object build(Class c) {
+ return c
+ }
+
+ Object build(Script s) {
+ return s
+ }
+ }
+
+ static class Groovy3163SomeImplementorWithStatic extends
Groovy3163SomeBaseClass {
+
+ // Comment this out, otherwise the super.build(x) calls won't match
the members in our parent.
+ static Object build(Closure c) {
+ [c]
+ }
+
+ // This one will also block a super.build, but it's the Script one.
+ static Object build(BigDecimal d) {
+ [d]
+ }
+
+ Object build(Integer i) {
+ [super.build(i)]
+ }
+
+ Object build(Script s) {
+ [super.build(s)]
+ }
+ }
+}
diff --git a/src/test/groovy/bugs/Groovy3163Bug.groovy
b/src/test/groovy/bugs/Groovy3163Bug.groovy
deleted file mode 100644
index b230bf1c28..0000000000
--- a/src/test/groovy/bugs/Groovy3163Bug.groovy
+++ /dev/null
@@ -1,83 +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 bugs
-
-import org.junit.jupiter.api.Test
-
-
-class Groovy3163Test {
-
-@Test
-void testSuperOverStatic() {
- def siws = new Groovy3163SomeImplementorWithStatic()
-
- assert (1 == siws.build(1)[0])
-
- def c = { -> 'foo ' }
-
-// def s = c as Script
-// assert s.is(siws.build(s)[0])
-
- assert c.is(siws.build(c)[0])
-}
-
-}
-
-
-class Groovy3163SomeBaseClass {
-
- Object build(Integer i) {
- return i
- }
-
- Object build(BigInteger i) {
- return i
- }
-
- Object build(Class c) {
- return c
- }
-
- Object build(Script s) {
- return s
- }
-}
-
-class Groovy3163SomeImplementorWithStatic extends Groovy3163SomeBaseClass {
-
- // Comment this out, otherwise the super.build(x) calls won't match the
members in our parent.
-
- static Object build(Closure c) {
- return [c]
- }
-
- // This one will also block a super.build, but it's the Script one.
- static Object build(BigDecimal d) {
- return [d]
- }
-
- Object build(Integer i) {
- return [super.build(i)]
- }
-
- Object build(Script s) {
- return [super.build(s)]
- }
-
-}
diff --git a/src/test/groovy/bugs/Groovy3175_Bug.groovy
b/src/test/groovy/bugs/Groovy3175.groovy
similarity index 61%
rename from src/test/groovy/bugs/Groovy3175_Bug.groovy
rename to src/test/groovy/bugs/Groovy3175.groovy
index 2c8e78b0ea..3174cfd5b5 100644
--- a/src/test/groovy/bugs/Groovy3175_Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3175.groovy
@@ -22,25 +22,24 @@ import org.junit.jupiter.api.Test
import static groovy.test.GroovyAssert.assertScript
-class Groovy3175_Bug {
+final class Groovy3175 {
@Test
void testSyntheticModifier() {
- assertScript """
- import groovy.transform.Generated
+ assertScript '''
+ class MyService {
+ private fio
+ def thing
+ def something() { }
+ def anotherSomething() { assert true }
+ }
- class MyService {
- private fio
- def thing
- def something() { }
- def anotherSomething() { assert true }
- }
- def fields = MyService.getDeclaredFields().grep { !it.synthetic }
- assert fields.size() == 2
- def methods = MyService.getDeclaredMethods().grep { !it.synthetic }
- assert methods.size() == 6
- methods = methods.grep { !it.getAnnotation(Generated) }
- assert methods.size() == 2
- """
+ def fields = MyService.getDeclaredFields().grep { !it.synthetic }
+ assert fields.size() == 2
+ def methods = MyService.getDeclaredMethods().grep { !it.synthetic }
+ assert methods.size() == 6
+ methods = methods.grep {
!it.getAnnotation(groovy.transform.Generated) }
+ assert methods.size() == 2
+ '''
}
}
diff --git a/src/test/groovy/bugs/OverloadInvokeMethodBug.groovy
b/src/test/groovy/bugs/Groovy3205.groovy
similarity index 66%
copy from src/test/groovy/bugs/OverloadInvokeMethodBug.groovy
copy to src/test/groovy/bugs/Groovy3205.groovy
index e74cde8192..5f7221c36b 100644
--- a/src/test/groovy/bugs/OverloadInvokeMethodBug.groovy
+++ b/src/test/groovy/bugs/Groovy3205.groovy
@@ -20,33 +20,21 @@ package bugs
import org.junit.jupiter.api.Test
-
-/**
- */
-
-class OverloadInvokeMethodBug {
+final class Groovy3205 {
@Test
- void testBug() {
- def a = new OverloadA()
- a.duh()
-
- def b = new OverloadB()
- b.duh()
+ void testOverrideToStringInMapOfClosures() {
+ def proxyImpl = [
+ control: { 'new control' },
+ toString: { 'new toString' }
+ ] as IGroovy3205
+
+ assert proxyImpl.control() == 'new control'
+ assert proxyImpl.toString() == 'new toString'
}
-}
-
-class OverloadA {
- def invokeMethod(String name, Object args) {
- try {
- metaClass.invokeMethod(this, name, args)
- } catch (MissingMethodException e) {
- println "Missing method: ${name}"
- }
+ static class IGroovy3205 {
+ String control() { 'original control' }
+ String toString() { 'original toString' }
}
}
-
-class OverloadB extends OverloadA {
-
-}
diff --git a/src/test/groovy/bugs/Groovy3205Bug.groovy
b/src/test/groovy/bugs/Groovy3205Bug.groovy
deleted file mode 100644
index a6aa11e807..0000000000
--- a/src/test/groovy/bugs/Groovy3205Bug.groovy
+++ /dev/null
@@ -1,35 +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 bugs
-
-class Groovy3205Bug {
- def void testOverrideToStringInMapOfClosures() {
- def proxyImpl = [
- control: { "new control" },
- toString: { "new toString" }
- ] as IGroovy3205Bug
- assert proxyImpl.control() == "new control"
- assert proxyImpl.toString() == "new toString"
- }
-}
-
-class IGroovy3205Bug {
- String control() { "original control" }
- String toString() { "original toString" }
-}
diff --git a/src/test/groovy/bugs/UseStaticInClosureBug.groovy
b/src/test/groovy/bugs/Groovy3208.groovy
similarity index 63%
copy from src/test/groovy/bugs/UseStaticInClosureBug.groovy
copy to src/test/groovy/bugs/Groovy3208.groovy
index f44e318e06..1ccdd70003 100644
--- a/src/test/groovy/bugs/UseStaticInClosureBug.groovy
+++ b/src/test/groovy/bugs/Groovy3208.groovy
@@ -20,30 +20,28 @@ package bugs
import org.junit.jupiter.api.Test
-
-/**
- */
-class UseStaticInClosureBug {
-
- static def stuff = [:]
+final class Groovy3208 {
@Test
void testBug() {
- [1,2,3].each { stuff[it] = "dog" }
-
- assert stuff.size() == 3
- assert stuff[2] == "dog"
+ new Sub().each { assert it.doIt() == 'ABC' }
+ assert new Sub().doItAgain() == 'ABC'
}
@Test
- void testBug2() {
- doStatic()
+ void testSubclassStaticContextProperty() {
+ assert Sub.doItStatically() == 'ABC'
+ assert Sub.doItStaticallyAgain() == 'ABC'
}
- static def doStatic() {
- [1,2,3].each { stuff[it] = "dog" }
+ static class Super {
+ def doIt = { PROP }
+ static doItStatically = { PROP }
+ static final String PROP = 'ABC'
+ }
- assert stuff.size() == 3
- assert stuff[2] == "dog"
+ static class Sub extends Super {
+ String doItAgain() { PROP }
+ static String doItStaticallyAgain() { PROP }
}
}
diff --git a/src/test/groovy/bugs/Groovy3208Bug.groovy
b/src/test/groovy/bugs/Groovy3208Bug.groovy
deleted file mode 100644
index deff49f176..0000000000
--- a/src/test/groovy/bugs/Groovy3208Bug.groovy
+++ /dev/null
@@ -1,50 +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 bugs
-
-import org.junit.jupiter.api.Test
-
-import static org.junit.jupiter.api.Assertions.assertEquals
-
-
-class Groovy3208Bug {
-
- @Test
- void testBug() {
- new Sub().each { assertEquals("ABC", it.doIt()) }
-
- assertEquals("ABC", new Sub().doItAgain())
- }
-
-// void testSubclassStaticContextProperty() {
-// assert "ABC" == Sub.doItStatically()
-// assert "ABC" == Sub.doItStaticallyAgain()
-// }
-}
-
-class Super {
- static final String PROP = "ABC"
- def doIt = { PROP }
-// static doItStatically = { PROP }
-}
-
-class Sub extends Super {
- String doItAgain() { PROP }
-// static String doItStaticallyAgain() { PROP }
-}
diff --git a/src/test/groovy/bugs/MarkupAndMethodBug.groovy
b/src/test/groovy/bugs/Groovy3235.groovy
similarity index 61%
copy from src/test/groovy/bugs/MarkupAndMethodBug.groovy
copy to src/test/groovy/bugs/Groovy3235.groovy
index b212ac0331..805562f5d3 100644
--- a/src/test/groovy/bugs/MarkupAndMethodBug.groovy
+++ b/src/test/groovy/bugs/Groovy3235.groovy
@@ -20,33 +20,29 @@ package bugs
import org.junit.jupiter.api.Test
-
-/**
- * Mixes variables, closures and method calls in markup
- *
- */
-class MarkupAndMethodBug {
+final class Groovy3235 {
@Test
- void testBug() {
- def tree = createTree()
- def name = tree.person[0]['@name']
- assert name == 'James'
- }
-
- protected def createTree() {
- def builder = NodeBuilder.newInstance()
-
- def root = builder.people() {
- person(name:getTestName())
+ void testBug3235 () {
+ def d = '''\
+ |This is one line.
+ |
+ |That was an empty line.
+ |Another empty line follows.
+ |
+ |All these lines should be written.
+ |'''.stripMargin()
+
+ def f = File.createTempFile('groovy.bugs.Groovy3235Bug', '.txt')
+ f.deleteOnExit()
+ f.withWriter { w ->
+ d.eachLine { w.println it }
}
- assert root != null
+ def t = f.text
- return root
- }
+ assert d == t.normalize()
- protected def getTestName() {
- "James"
- }
+ assert d.denormalize() == t
+ }
}
diff --git a/src/test/groovy/bugs/Groovy3235Bug.groovy
b/src/test/groovy/bugs/Groovy3235Bug.groovy
deleted file mode 100644
index 9031fdad81..0000000000
--- a/src/test/groovy/bugs/Groovy3235Bug.groovy
+++ /dev/null
@@ -1,47 +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 bugs
-
-import org.junit.jupiter.api.Test
-
-
-class Groovy3235Bug {
-
-@Test
-void testBug3235 () {
- def d = """This is one line.
-
- That was an empty line.
- Another empty line follows.
-
- All these lines should be written.
-"""
- def f = File.createTempFile("groovy.bugs.Groovy3235Bug", ".txt")
- f.deleteOnExit()
- f.withWriter { w ->
- d.eachLine { w.println it }
- }
-
- def t = f.text
-
- assert d == t.normalize()
-
- assert d.denormalize() == t
- }
-}
diff --git a/src/test/groovy/bugs/Groovy3238.groovy
b/src/test/groovy/bugs/Groovy3238.groovy
new file mode 100644
index 0000000000..c62161b4c0
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy3238.groovy
@@ -0,0 +1,43 @@
+/*
+ * 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 bugs
+
+import org.junit.jupiter.api.Test
+
+final class Groovy3238 {
+
+ @Test
+ void testRelativeExactnessToMatchForBigIntegerParam() {
+ def obj = new Groovy3238()
+ def bi = new BigInteger('1')
+
+ Groovy3238.metaClass.m = {Double val -> 'Double'}; obj.metaClass = null
+ assert obj.m(bi) == 'Double'
+ Groovy3238.metaClass.m = {double val -> 'double'}; obj.metaClass = null
+ assert obj.m(bi) == 'double' //double should be chosen over Double
+ Groovy3238.metaClass.m = {BigDecimal val -> 'BigDecimal'};
obj.metaClass = null
+ assert obj.m(bi) == 'BigDecimal' //BigDecimal should be chosen over
Double, double
+ Groovy3238.metaClass.m = {Object val -> 'Object'}; obj.metaClass = null
+ assert obj.m(bi) == 'Object' //Object should be chosen over Double,
double, BigDecimal
+ Groovy3238.metaClass.m = {Number val -> 'Number'}; obj.metaClass = null
+ assert obj.m(bi) == 'Number' //Number should be chosen over Double,
double, BigDecimal, Object
+ Groovy3238.metaClass.m = {BigInteger val -> 'BigInteger'};
obj.metaClass = null
+ assert obj.m(bi) == 'BigInteger' //BigInteger should be chosen over
Double, double, BigDecimal, Object, Number
+ }
+}
diff --git a/src/test/groovy/bugs/Groovy3238Bug.groovy
b/src/test/groovy/bugs/Groovy3238Bug.groovy
deleted file mode 100644
index 45eada942e..0000000000
--- a/src/test/groovy/bugs/Groovy3238Bug.groovy
+++ /dev/null
@@ -1,39 +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 bugs
-
-class Groovy3238Bug {
- def void testRelativeExactnessToMatchForBigIntegerParam() {
- def obj = new Groovy3238Bug()
- def bi = new BigInteger("1")
-
- Groovy3238Bug.metaClass.m = {Double val -> "Double"}; obj.metaClass =
null
- assert obj.m(bi) == "Double"
- Groovy3238Bug.metaClass.m = {double val -> "double"}; obj.metaClass =
null
- assert obj.m(bi) == "double" //double should be chosen over Double
- Groovy3238Bug.metaClass.m = {BigDecimal val -> "BigDecimal"};
obj.metaClass = null
- assert obj.m(bi) == "BigDecimal" //BigDecimal should be chosen over
Double, double
- Groovy3238Bug.metaClass.m = {Object val -> "Object"}; obj.metaClass =
null
- assert obj.m(bi) == "Object" //Object should be chosen over Double,
double, BigDecimal
- Groovy3238Bug.metaClass.m = {Number val -> "Number"}; obj.metaClass =
null
- assert obj.m(bi) == "Number" //Number should be chosen over Double,
double, BigDecimal, Object
- Groovy3238Bug.metaClass.m = {BigInteger val -> "BigInteger"};
obj.metaClass = null
- assert obj.m(bi) == "BigInteger" //BigInteger should be chosen over
Double, double, BigDecimal, Object, Number
- }
-}
diff --git a/src/test/groovy/bugs/Groovy325_Bug.groovy
b/src/test/groovy/bugs/Groovy325.groovy
similarity index 81%
rename from src/test/groovy/bugs/Groovy325_Bug.groovy
rename to src/test/groovy/bugs/Groovy325.groovy
index 241c000356..35dea76bd8 100644
--- a/src/test/groovy/bugs/Groovy325_Bug.groovy
+++ b/src/test/groovy/bugs/Groovy325.groovy
@@ -20,15 +20,15 @@ package bugs
import org.junit.jupiter.api.Test
+final class Groovy325 {
-class Groovy325_Bug {
- static boolean staticMethod() {
- return true
- }
+ static boolean staticMethod() {
+ return true
+ }
- @Test
- void testCallStaticMethodFromClosure() {
- def c = { staticMethod() }
- assert c()
- }
+ @Test
+ void testCallStaticMethodFromClosure() {
+ def c = { staticMethod() }
+ assert c()
+ }
}
diff --git a/src/test/groovy/bugs/Groovy3304Bug.groovy
b/src/test/groovy/bugs/Groovy3304.groovy
similarity index 73%
rename from src/test/groovy/bugs/Groovy3304Bug.groovy
rename to src/test/groovy/bugs/Groovy3304.groovy
index b91ca1e284..21f89dce83 100644
--- a/src/test/groovy/bugs/Groovy3304Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3304.groovy
@@ -21,18 +21,15 @@ package bugs
import org.codehaus.groovy.control.MultipleCompilationErrorsException
import org.junit.jupiter.api.Test
-import static org.junit.jupiter.api.Assertions.fail
+import static groovy.test.GroovyAssert.shouldFail
+
+final class Groovy3304 {
-class Groovy3304Bug {
@Test
void testBreakAfterSwitchCausesSyntaxError() {
- try {
- new GroovyShell().parse("switch(x) {}\nbreak")
- fail()
- } catch (MultipleCompilationErrorsException e) {
- def syntaxError = e.errorCollector.getSyntaxError(0)
- assert syntaxError
- assert syntaxError.line == 2
- }
+ def e = shouldFail(MultipleCompilationErrorsException,
'switch(x){}\nbreak')
+
+ def syntaxError = e.errorCollector.getSyntaxError(0)
+ assert syntaxError?.line == 2
}
}
diff --git a/src/test/groovy/bugs/Groovy3305Bug.groovy
b/src/test/groovy/bugs/Groovy3305.groovy
similarity index 76%
rename from src/test/groovy/bugs/Groovy3305Bug.groovy
rename to src/test/groovy/bugs/Groovy3305.groovy
index f9654f2b96..0977435617 100644
--- a/src/test/groovy/bugs/Groovy3305Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3305.groovy
@@ -18,14 +18,18 @@
*/
package bugs
-class Groovy3305Bug {
- def void testSingleListExpandingToMultipleArgs() {
- assert foo1([1, "A"]) == "1,A"
- assert foo2([BigDecimal.ZERO, "B"]) == "0,B"
- assert foo3([(byte)3, "C"]) == "3,C"
- assert foo4([(float)4, "D"]) == "4.0,D"
- assert foo5([(long)5, "E"]) == "5,E"
- assert foo6([(short)6, "F"]) == "6,F"
+import org.junit.jupiter.api.Test
+
+final class Groovy3305 {
+
+ @Test
+ void testSingleListExpandingToMultipleArgs() {
+ assert foo1([1, 'A']) == '1,A'
+ assert foo2([BigDecimal.ZERO, 'B']) == '0,B'
+ assert foo3([(byte)3, 'C']) == '3,C'
+ assert foo4([(float)4, 'D']) == '4.0,D'
+ assert foo5([(long)5, 'E']) == '5,E'
+ assert foo6([(short)6, 'F']) == '6,F'
}
def foo1(int arg0, String arg1) {
diff --git a/src/test/groovy/bugs/Groovy3311.groovy
b/src/test/groovy/bugs/Groovy3311.groovy
index 8d0b303264..f73be7ab4e 100644
--- a/src/test/groovy/bugs/Groovy3311.groovy
+++ b/src/test/groovy/bugs/Groovy3311.groovy
@@ -18,12 +18,10 @@
*/
package bugs
-import groovy.transform.CompileStatic
import org.junit.jupiter.api.Test
import static groovy.test.GroovyAssert.assertScript
-@CompileStatic
final class Groovy3311 {
@Test
diff --git a/src/test/groovy/bugs/Groovy3335Bug.groovy
b/src/test/groovy/bugs/Groovy3335.groovy
similarity index 97%
rename from src/test/groovy/bugs/Groovy3335Bug.groovy
rename to src/test/groovy/bugs/Groovy3335.groovy
index c545df933b..ea6b1dbbe1 100644
--- a/src/test/groovy/bugs/Groovy3335Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3335.groovy
@@ -20,8 +20,8 @@ package bugs
import org.junit.jupiter.api.Test
+final class Groovy3335 {
-class Groovy3335Bug {
@Test
void testClassToString() {
// the following call was resulting in a MethodSelectionException
diff --git a/src/test/groovy/bugs/Groovy3339Bug.groovy
b/src/test/groovy/bugs/Groovy3339.groovy
similarity index 98%
rename from src/test/groovy/bugs/Groovy3339Bug.groovy
rename to src/test/groovy/bugs/Groovy3339.groovy
index b229d75667..c94193b17e 100644
--- a/src/test/groovy/bugs/Groovy3339Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3339.groovy
@@ -20,8 +20,8 @@ package bugs
import org.junit.jupiter.api.Test
+final class Groovy3339 {
-class Groovy3339Bug {
@Test
void testConstantCachingInClosureClasses() {
// In all the cases below, the OptimizerVisitor replaces number 10 by
diff --git a/src/test/groovy/bugs/Groovy3383Bug.groovy
b/src/test/groovy/bugs/Groovy3383.groovy
similarity index 81%
rename from src/test/groovy/bugs/Groovy3383Bug.groovy
rename to src/test/groovy/bugs/Groovy3383.groovy
index 92f0d68c61..c08abb3403 100644
--- a/src/test/groovy/bugs/Groovy3383Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3383.groovy
@@ -22,17 +22,17 @@ import org.junit.jupiter.api.Test
import static groovy.test.GroovyAssert.assertScript
+final class Groovy3383 {
-class Groovy3383Bug {
@Test
void testClassUsageInInterfaceDef() {
- assertScript """
- interface Groovy3383 {
- Class type = Groovy3383.class
+ assertScript '''
+ interface IGroovy3383 {
+ Class type = IGroovy3383.class
}
- def t = Groovy3383.type
- assert t.name == "Groovy3383"
- """
+ def t = IGroovy3383.type
+ assert t.name == 'IGroovy3383'
+ '''
}
}
diff --git a/src/test/groovy/bugs/Groovy3389Bug.groovy
b/src/test/groovy/bugs/Groovy3389.groovy
similarity index 90%
rename from src/test/groovy/bugs/Groovy3389Bug.groovy
rename to src/test/groovy/bugs/Groovy3389.groovy
index af3b67c97f..c92afc6a0d 100644
--- a/src/test/groovy/bugs/Groovy3389Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3389.groovy
@@ -22,12 +22,12 @@ import org.junit.jupiter.api.Test
import static groovy.test.GroovyAssert.assertScript
+final class Groovy3389 {
-class Groovy3389Bug {
@Test
void testFieldHidingByLocalVariable() {
- assertScript """
- class Groovy3389 {
+ assertScript '''
+ class Foo {
String bar
void doIt() {
def bar = new File('.')
@@ -35,8 +35,8 @@ class Groovy3389Bug {
}
}
- def obj = new Groovy3389()
+ def obj = new Foo()
obj.doIt()
- """
+ '''
}
}
diff --git a/src/test/groovy/bugs/GuillaumesMapBug.groovy
b/src/test/groovy/bugs/GuillaumesMapBug.groovy
index 2bd2c14922..ed3bf21679 100644
--- a/src/test/groovy/bugs/GuillaumesMapBug.groovy
+++ b/src/test/groovy/bugs/GuillaumesMapBug.groovy
@@ -20,8 +20,7 @@ package bugs
import org.junit.jupiter.api.Test
-
-class GuillaumesMapBug {
+final class GuillaumesMapBug {
@Test
void testBug2() {
@@ -35,14 +34,13 @@ class GuillaumesMapBug {
assert map[2] == 3
}
- void doLoop(list, map) {
+ private void doLoop(list, map) {
def i = 0
for (it in list) {
map[i++] = it
}
}
-
@Test
void testBug() {
def list = [1, 2, 3]
@@ -54,7 +52,7 @@ class GuillaumesMapBug {
assert map[2] == 3
}
- void doClosureLoop(list, map) {
+ private void doClosureLoop(list, map) {
def i = 0
list.each { map[i++] = it }
}
diff --git a/src/test/groovy/bugs/MarkupAndMethodBug.groovy
b/src/test/groovy/bugs/MarkupAndMethodBug.groovy
index b212ac0331..87dfbebbc5 100644
--- a/src/test/groovy/bugs/MarkupAndMethodBug.groovy
+++ b/src/test/groovy/bugs/MarkupAndMethodBug.groovy
@@ -20,12 +20,10 @@ package bugs
import org.junit.jupiter.api.Test
-
/**
* Mixes variables, closures and method calls in markup
- *
*/
-class MarkupAndMethodBug {
+final class MarkupAndMethodBug {
@Test
void testBug() {
@@ -34,7 +32,7 @@ class MarkupAndMethodBug {
assert name == 'James'
}
- protected def createTree() {
+ protected createTree() {
def builder = NodeBuilder.newInstance()
def root = builder.people() {
@@ -46,7 +44,7 @@ class MarkupAndMethodBug {
return root
}
- protected def getTestName() {
- "James"
+ protected getTestName() {
+ 'James'
}
}
diff --git a/src/test/groovy/bugs/MethodDispatchBug.groovy
b/src/test/groovy/bugs/MethodDispatchBug.groovy
index 6da53041b0..8c754418b1 100644
--- a/src/test/groovy/bugs/MethodDispatchBug.groovy
+++ b/src/test/groovy/bugs/MethodDispatchBug.groovy
@@ -20,32 +20,32 @@ package bugs
import org.junit.jupiter.api.Test
+final class MethodDispatchBug {
-class MethodDispatchBug {
def doit(Object parameter1, Object parameter2) {
- "OO"
+ 'OO'
}
def doit(Boolean parameter1, Object parameter2) {
- "BO"
+ 'BO'
}
def doit(Object parameter1, Boolean parameter2) {
- "OB"
+ 'OB'
}
def doit(Boolean parameter1, Boolean parameter2) {
- "BB"
+ 'BB'
}
@Test
void testBug() {
- def o = this;
+ def o = this
- assert "BB" == o.doit(true, true);
- assert "BO" == o.doit(true, 9);
- assert "OB" == o.doit(9, true);
- assert "OO" == o.doit(9, 9);
+ assert 'BB' == o.doit(true, true)
+ assert 'BO' == o.doit(true, 9)
+ assert 'OB' == o.doit(9, true)
+ assert 'OO' == o.doit(9, 9)
}
def methodWithDefaults(a,b,c=1000) {
diff --git a/src/test/groovy/bugs/OverloadInvokeMethodBug.groovy
b/src/test/groovy/bugs/OverloadInvokeMethodBug.groovy
index e74cde8192..ae79511107 100644
--- a/src/test/groovy/bugs/OverloadInvokeMethodBug.groovy
+++ b/src/test/groovy/bugs/OverloadInvokeMethodBug.groovy
@@ -20,11 +20,7 @@ package bugs
import org.junit.jupiter.api.Test
-
-/**
- */
-
-class OverloadInvokeMethodBug {
+final class OverloadInvokeMethodBug {
@Test
void testBug() {
@@ -35,18 +31,16 @@ class OverloadInvokeMethodBug {
b.duh()
}
-}
-
-class OverloadA {
- def invokeMethod(String name, Object args) {
- try {
- metaClass.invokeMethod(this, name, args)
- } catch (MissingMethodException e) {
- println "Missing method: ${name}"
+ static class OverloadA {
+ def invokeMethod(String name, Object args) {
+ try {
+ metaClass.invokeMethod(this, name, args)
+ } catch (MissingMethodException e) {
+ println "Missing method: ${name}"
+ }
}
}
-}
-
-class OverloadB extends OverloadA {
+ static class OverloadB extends OverloadA {
+ }
}
diff --git a/src/test/groovy/bugs/RodsBug.groovy
b/src/test/groovy/bugs/RodsBug.groovy
index 5b3d18c8f1..fc1e0c2c9e 100644
--- a/src/test/groovy/bugs/RodsBug.groovy
+++ b/src/test/groovy/bugs/RodsBug.groovy
@@ -20,44 +20,34 @@ package bugs
import org.junit.jupiter.api.Test
-
-class RodsBug {
+final class RodsBug {
@Test
void testBug() {
doTest(true)
- /*
- def x = 1
- if (x > 0) {
- String name = "Rod"
- println(name)
- }
- */
}
@Test
void testBug2() {
def x = 1
if (x > 0) {
- //String name = "Rod"
- def name = "Rod"
+ def name = 'Rod'
}
}
- void doTest(flag) {
+ private void doTest(flag) {
if (flag) {
- String name = "Rod"
- //def name = "Rod"
+ String name = 'Rod'
doAssert(name)
}
}
- void doTest() {
- String name = "Rod"
+ private void doTest() {
+ String name = 'Rod'
doAssert(name)
}
- void doAssert(text) {
+ private void doAssert(text) {
assert text != null
}
}
diff --git a/src/test/groovy/bugs/StaticMethodCallBug.groovy
b/src/test/groovy/bugs/StaticMethodCallBug.groovy
index 121ab70d94..5e2a9e4835 100644
--- a/src/test/groovy/bugs/StaticMethodCallBug.groovy
+++ b/src/test/groovy/bugs/StaticMethodCallBug.groovy
@@ -21,19 +21,17 @@ package bugs
import groovy.bugs.TestSupport
import org.junit.jupiter.api.Test
-/**
- */
-class StaticMethodCallBug {
+final class StaticMethodCallBug {
@Test
void testBug() {
def value = TestSupport.mockStaticMethod()
- assert value == "cheese"
+ assert value == 'cheese'
}
@Test
void testStaticProperty() {
def value = TestSupport.mockStaticProperty
- assert value == "cheese"
+ assert value == 'cheese'
}
}
diff --git a/src/test/groovy/bugs/SuperMethod2Bug.groovy
b/src/test/groovy/bugs/SuperMethod2Bug.groovy
index 9183dddb88..bf25d57a2f 100644
--- a/src/test/groovy/bugs/SuperMethod2Bug.groovy
+++ b/src/test/groovy/bugs/SuperMethod2Bug.groovy
@@ -20,134 +20,132 @@ package bugs
import org.junit.jupiter.api.Test
-
-/**
- */
-class SuperMethod2Bug {
+final class SuperMethod2Bug {
@Test
void testBug() {
def base = new SuperBase()
def value = base.doSomething()
- assert value == "TestBase"
+ assert value == 'TestBase'
base = new SuperDerived()
value = base.doSomething()
- assert value == "TestDerivedTestBase"
+ assert value == 'TestDerivedTestBase'
}
@Test
void testBug2() {
def base = new SuperBase()
def value = base.foo(2)
- assert value == "TestBase2"
+ assert value == 'TestBase2'
base = new SuperDerived()
value = base.foo(3)
- assert value == "TestDerived3TestBase3"
+ assert value == 'TestDerived3TestBase3'
}
@Test
void testBug3() {
def base = new SuperBase()
def value = base.foo(2,3)
- assert value == "foo(x,y)Base2,3"
+ assert value == 'foo(x,y)Base2,3'
base = new SuperDerived()
value = base.foo(3,4)
- assert value == "foo(x,y)Derived3,4foo(x,y)Base3,4"
+ assert value == 'foo(x,y)Derived3,4foo(x,y)Base3,4'
}
@Test
void testBug4() {
- def base = new SuperBase("Cheese")
+ def base = new SuperBase('Cheese')
def value = base.name
- assert value == "Cheese"
+ assert value == 'Cheese'
- base = new SuperDerived("Cheese")
+ base = new SuperDerived('Cheese')
value = base.name
- assert value == "CheeseDerived"
+ assert value == 'CheeseDerived'
}
@Test
- void testCallsToSuperMethodsReturningPrimitives(){
- def base = new SuperBase("super cheese")
+ void testCallsToSuperMethodsReturningPrimitives() {
+ def base = new SuperBase('super cheese')
assert base.longMethod() == 1
assert base.intMethod() == 1
assert base.boolMethod() == true
- base = new SuperDerived("derived super cheese")
+ base = new SuperDerived('derived super cheese')
assert base.longMethod() == 1
assert base.intMethod() == 1
assert base.boolMethod() == true
}
-}
-class SuperBase {
- String name
+
//--------------------------------------------------------------------------
- SuperBase() {
- }
+ static class SuperBase {
+ String name
- SuperBase(String name) {
- this.name = name
- }
+ SuperBase() {
+ }
- def doSomething() {
- "TestBase"
- }
+ SuperBase(String name) {
+ this.name = name
+ }
- def foo(param) {
- "TestBase" + param
- }
+ def doSomething() {
+ 'TestBase'
+ }
+
+ def foo(param) {
+ 'TestBase' + param
+ }
- def foo(x, y) {
- "foo(x,y)Base" + x + "," + y
+ def foo(x, y) {
+ 'foo(x,y)Base' + x + ',' + y
+ }
+
+ boolean boolMethod(){true}
+ long longMethod(){1l}
+ int intMethod(){1i}
}
- boolean boolMethod(){true}
- long longMethod(){1l}
- int intMethod(){1i}
-}
+ static class SuperDerived extends SuperBase {
-class SuperDerived extends SuperBase {
+ def calls = 0
- def calls = 0
+ SuperDerived() {
+ }
- SuperDerived() {
- }
+ SuperDerived(String name) {
+ super(name + 'Derived')
+ }
- SuperDerived(String name) {
- super(name + "Derived")
- }
+ def doSomething() {
+ /** @todo ++calls causes bug */
+ //calls++
+ /*
+ calls = calls + 1
+ assert calls < 3
+ */
- def doSomething() {
- /** @todo ++calls causes bug */
- //calls++
- /*
- calls = calls + 1
- assert calls < 3
- */
+ 'TestDerived' + super.doSomething()
+ }
- "TestDerived" + super.doSomething()
- }
+ def foo(param) {
+ 'TestDerived' + param + super.foo(param)
+ }
- def foo(param) {
- "TestDerived" + param + super.foo(param)
- }
+ def foo(x, y) {
+ 'foo(x,y)Derived' + x + ',' + y + super.foo(x, y)
+ }
- def foo(x, y) {
- "foo(x,y)Derived" + x + "," + y + super.foo(x, y)
+ // we want to ensure that a call with super, which is directly added
into
+ // bytecode without calling MetaClass does correct boxing
+ boolean booMethod(){super.boolMethod()}
+ int intMethod(){super.intMethod()}
+ long longMethod(){super.longMethod()}
}
-
- // we want to ensure that a call with super, which is directly added into
- // bytecode without calling MetaClass does correct boxing
- boolean booMethod(){super.boolMethod()}
- int intMethod(){super.intMethod()}
- long longMethod(){super.longMethod()}
}
-
diff --git a/src/test/groovy/bugs/ToStringBug.groovy
b/src/test/groovy/bugs/ToStringBug.groovy
index a973ad2c35..31cb01863e 100644
--- a/src/test/groovy/bugs/ToStringBug.groovy
+++ b/src/test/groovy/bugs/ToStringBug.groovy
@@ -20,10 +20,7 @@ package bugs
import org.junit.jupiter.api.Test
-
-/**
- */
-class ToStringBug {
+final class ToStringBug {
@Test
void testBug() {
@@ -31,7 +28,8 @@ class ToStringBug {
assert value != null
}
+ @Override
String toString() {
- return super.toString() + "[hey]"
+ return super.toString() + '[hey]'
}
}
diff --git a/src/test/groovy/bugs/TryCatchBug.groovy
b/src/test/groovy/bugs/TryCatchBug.groovy
index fbe3fbe47c..5e8df625ba 100644
--- a/src/test/groovy/bugs/TryCatchBug.groovy
+++ b/src/test/groovy/bugs/TryCatchBug.groovy
@@ -20,16 +20,15 @@ package bugs
import org.junit.jupiter.api.Test
-
-class TryCatchBug {
+final class TryCatchBug {
@Test
void testBug() {
try {
- println("Hello")
+ println('Hello')
}
finally {
- println("Finally")
+ println('Finally')
}
}
}
diff --git a/src/test/groovy/bugs/UseStaticInClosureBug.groovy
b/src/test/groovy/bugs/UseStaticInClosureBug.groovy
index f44e318e06..610674df91 100644
--- a/src/test/groovy/bugs/UseStaticInClosureBug.groovy
+++ b/src/test/groovy/bugs/UseStaticInClosureBug.groovy
@@ -20,19 +20,16 @@ package bugs
import org.junit.jupiter.api.Test
-
-/**
- */
-class UseStaticInClosureBug {
+final class UseStaticInClosureBug {
static def stuff = [:]
@Test
void testBug() {
- [1,2,3].each { stuff[it] = "dog" }
+ [1,2,3].each { stuff[it] = 'dog' }
assert stuff.size() == 3
- assert stuff[2] == "dog"
+ assert stuff[2] == 'dog'
}
@Test
@@ -40,10 +37,10 @@ class UseStaticInClosureBug {
doStatic()
}
- static def doStatic() {
- [1,2,3].each { stuff[it] = "dog" }
+ private static doStatic() {
+ [1,2,3].each { stuff[it] = 'dog' }
assert stuff.size() == 3
- assert stuff[2] == "dog"
+ assert stuff[2] == 'dog'
}
}
diff --git a/src/test/groovy/groovy/ClosureInClosureTest.groovy
b/src/test/groovy/groovy/ClosureInClosureTest.groovy
index b5712bce62..368d173bf0 100644
--- a/src/test/groovy/groovy/ClosureInClosureTest.groovy
+++ b/src/test/groovy/groovy/ClosureInClosureTest.groovy
@@ -20,7 +20,6 @@ package groovy
import org.junit.jupiter.api.Test
-
/**
* Bug illustrating the nested closures variable scope visibility issue.
* l.each is ClosureInClosureBug$1 and it.each is ClosureInClosureBug$2
@@ -29,25 +28,19 @@ import org.junit.jupiter.api.Test
* but cannot see what's in the second level.
*
* In order to make the test work, do not forget to uncomment the line
"println(text)"
- *
- * @authour Guillaume Laforge
*/
-class ClosureInClosureTest {
+final class ClosureInClosureTest {
+
@Test
void testInvisibleVariable() {
- def text = "test "
+ def text = 'test '
def l = [1..11, 2..12, 3..13, 4..14]
- l.each{
- it.each{
+ l.each {
+ it.each {
assert text == 'test '
}
}
}
-
- static void main(args) {
- def bug = new ClosureInClosureTest()
- bug.testInvisibleVariable()
- }
-}
\ No newline at end of file
+}
diff --git a/src/test/groovy/groovy/ClosureMethodCallTest.groovy
b/src/test/groovy/groovy/ClosureMethodCallTest.groovy
index de212f11de..dc157f5e56 100644
--- a/src/test/groovy/groovy/ClosureMethodCallTest.groovy
+++ b/src/test/groovy/groovy/ClosureMethodCallTest.groovy
@@ -40,7 +40,8 @@ final class ClosureMethodCallTest {
assert foo == 'hello sam and james'
}
- @Test // GROOVY-2266
+ // GROOVY-2266
+ @Test
void testClosureCallMethodWithObjectArray() {
def args = [1] as Object[]
def closure = { x -> x[0] }
@@ -77,7 +78,8 @@ final class ClosureMethodCallTest {
assert attribute(x: 2, y: 3) == 6
}
- @Test // GROOVY-6819
+ // GROOVY-6819
+ @Test
void testFixForIncompatibleClassChangeError() {
assertScript '''
class Foo {
@@ -95,7 +97,8 @@ final class ClosureMethodCallTest {
'''
}
- @Test // GROOVY-9397
+ // GROOVY-9397
+ @Test
void testRespondsToIsThreadSafe() {
def executor = Executors.newCachedThreadPool()
try {
diff --git a/src/test/groovy/groovy/PrimitiveTypeFieldTest.groovy
b/src/test/groovy/groovy/PrimitiveTypeFieldTest.groovy
index 38cd60396f..94e4947528 100644
--- a/src/test/groovy/groovy/PrimitiveTypeFieldTest.groovy
+++ b/src/test/groovy/groovy/PrimitiveTypeFieldTest.groovy
@@ -20,8 +20,8 @@ package groovy
import org.junit.jupiter.api.Test
+final class PrimitiveTypeFieldTest {
-class PrimitiveTypeFieldTest {
private long longField
private static short shortField
@@ -44,12 +44,12 @@ class PrimitiveTypeFieldTest {
assert longField == 1
}
+ // GROOVY-133
@Test
void testIntParamBug() {
assert bugMethod(123) == 246
assert bugMethod2(123) == 246
- // GROOVY-133
def closure = {int x-> x * 2 }
assert closure.call(123) == 246
@@ -62,6 +62,7 @@ class PrimitiveTypeFieldTest {
def bugMethod2(int x) {
x * 2
}
+
@Test
void testStaticPrimitiveField() {
shortField = (Short) 123
diff --git a/src/test/groovy/org/codehaus/groovy/classgen/RunBugsTest.java
b/src/test/groovy/org/codehaus/groovy/classgen/RunBugsTest.java
index 6130d4129e..9bf7692a5f 100644
--- a/src/test/groovy/org/codehaus/groovy/classgen/RunBugsTest.java
+++ b/src/test/groovy/org/codehaus/groovy/classgen/RunBugsTest.java
@@ -28,111 +28,9 @@ import org.junit.jupiter.api.Test;
*/
final class RunBugsTest extends TestSupport {
- @Test
- void testStaticMethodCall() throws Exception {
- GroovyObject object =
compile("src/test/groovy/bugs/StaticMethodCallBug.groovy");
- object.invokeMethod("testBug", null);
- }
-
- @Test
- void testTryCatchBug() throws Exception {
- GroovyObject object =
compile("src/test/groovy/bugs/TryCatchBug.groovy");
- object.invokeMethod("testBug", null);
- }
-
- @Test
- void testRodsBug() throws Exception {
- GroovyObject object = compile("src/test/groovy/bugs/RodsBug.groovy");
- object.invokeMethod("testBug", null);
- }
-
- @Test
- void testCastBug() throws Exception {
- GroovyObject object =
compile("src/test/groovy/groovy/ClosureMethodCallTest.groovy");
- object.invokeMethod("testCallingClosureWithMultipleArguments", null);
- }
-
- @Test
- void testGuillaumesMapBug() throws Exception {
- GroovyObject object =
compile("src/test/groovy/bugs/GuillaumesMapBug.groovy");
- object.invokeMethod("testBug", null);
- }
-
@Test
void testUseClosureInScript() throws Exception {
GroovyObject object =
compile("src/test/groovy/groovy/script/scriptWithClosure.groovy");
object.invokeMethod("run", null);
}
-
- @Test
- void testUseStaticInClosure() throws Exception {
- GroovyObject object =
compile("src/test/groovy/bugs/UseStaticInClosureBug.groovy");
- object.invokeMethod("testBug2", null);
- }
-
- @Test
- void testPrimitiveTypeFieldTest() throws Exception {
- GroovyObject object =
compile("src/test/groovy/groovy/PrimitiveTypeFieldTest.groovy");
- object.invokeMethod("testPrimitiveField", null);
- }
-
- @Test
- void testMethodDispatchBug() throws Exception {
- GroovyObject object =
compile("src/test/groovy/bugs/MethodDispatchBug.groovy");
- object.invokeMethod("testBug", null);
- }
-
- @Test
- void testClosureInClosureTest() throws Exception {
- GroovyObject object =
compile("src/test/groovy/groovy/ClosureInClosureTest.groovy");
- object.invokeMethod("testInvisibleVariable", null);
- }
-
- @Test
- void testOverloadInvokeMethodBug() throws Exception {
- GroovyObject object =
compile("src/test/groovy/bugs/OverloadInvokeMethodBug.groovy");
- object.invokeMethod("testBug", null);
- }
-
- @Test
- void testClosureVariableBug() throws Exception {
- GroovyObject object =
compile("src/test/groovy/bugs/ClosureVariableBug.groovy");
- object.invokeMethod("testBug", null);
- }
-
- @Test
- void testMarkupAndMethodBug() throws Exception {
- GroovyObject object =
compile("src/test/groovy/bugs/MarkupAndMethodBug.groovy");
- object.invokeMethod("testBug", null);
- }
-
- @Test
- void testClosureParameterPassingBug() throws Exception {
- GroovyObject object =
compile("src/test/groovy/bugs/ClosureParameterPassingBug.groovy");
- object.invokeMethod("testBug", null);
- }
-
- @Test
- void testNestedClosureBug() throws Exception {
- GroovyObject object =
compile("src/test/groovy/bugs/NestedClosure2Bug.groovy");
- object.invokeMethod("testFieldBug", null);
- }
-
- @Test
- void testSuperMethod2Bug() throws Exception {
- GroovyObject object =
compile("src/test/groovy/bugs/SuperMethod2Bug.groovy");
- object.invokeMethod("testBug", null);
- }
-
- @Test
- void testToStringBug() throws Exception {
- GroovyObject object =
compile("src/test/groovy/bugs/ToStringBug.groovy");
- object.invokeMethod("testBug", null);
- }
-
- @Test
- void testByteIndexBug() throws Exception {
- GroovyObject object =
compile("src/test/groovy/bugs/ByteIndexBug.groovy");
- object.invokeMethod("testBug", null);
- }
}