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 e1ff27e51a junit jupiter
e1ff27e51a is described below
commit e1ff27e51a1424e7488949cf54f7cacaefa0dcb0
Author: Eric Milles <[email protected]>
AuthorDate: Fri Mar 20 13:12:12 2026 -0500
junit jupiter
---
.../{Groovy3403Bug.groovy => Groovy3403.groovy} | 26 +++++-----
.../{Groovy3405Bug.groovy => Groovy3405.groovy} | 16 +++---
.../{Groovy3410Bug.groovy => Groovy3410.groovy} | 48 +++++++++++------
src/test/groovy/bugs/Groovy3422.groovy | 1 +
.../{Groovy3424Bug.groovy => Groovy3424.groovy} | 24 ++++-----
.../{Groovy3426Bug.groovy => Groovy3426.groovy} | 27 +++++-----
.../{Groovy3446Bug.groovy => Groovy3446.groovy} | 7 +--
.../{Groovy3462Bug.groovy => Groovy3462.groovy} | 15 +++---
.../{Groovy3464Bug.groovy => Groovy3464.groovy} | 45 ++++++++--------
.../{Groovy3465Bug.groovy => Groovy3465.groovy} | 17 ++++--
src/test/groovy/bugs/Groovy3465Helper.groovy | 28 ----------
.../{Groovy3498Bug.groovy => Groovy3498.groovy} | 12 +++--
.../{Groovy3509Bug.groovy => Groovy3509.groovy} | 21 ++++----
.../bugs/{Groovy3645.groovy => Groovy3511.groovy} | 33 ++++++++----
src/test/groovy/bugs/Groovy3511Bug.groovy | 60 ----------------------
.../{Groovy3519Bug.groovy => Groovy3519.groovy} | 17 +++---
.../{Groovy3560Bug.groovy => Groovy3560.groovy} | 2 +-
.../{Groovy3574Bug.groovy => Groovy3574.groovy} | 30 +++++------
.../{Groovy3590Bug.groovy => Groovy3590.groovy} | 4 +-
.../{Groovy3596Bug.groovy => Groovy3596.groovy} | 6 +--
src/test/groovy/bugs/Groovy3645.groovy | 1 +
.../{Groovy3679Bug.groovy => Groovy3679.groovy} | 28 +++++-----
22 files changed, 204 insertions(+), 264 deletions(-)
diff --git a/src/test/groovy/bugs/Groovy3403Bug.groovy
b/src/test/groovy/bugs/Groovy3403.groovy
similarity index 79%
rename from src/test/groovy/bugs/Groovy3403Bug.groovy
rename to src/test/groovy/bugs/Groovy3403.groovy
index 91822345f3..c48e2d7726 100644
--- a/src/test/groovy/bugs/Groovy3403Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3403.groovy
@@ -21,42 +21,42 @@ package bugs
import groovy.mock.interceptor.StubFor
import org.junit.jupiter.api.Test
-class Groovy3403Bug {
+final class Groovy3403 {
@Test
void testStubIssueForStaticMethodsDueToCallSiteCachingWhenUsing2Stubs() {
def stub1 = new StubFor(Main3403)
stub1.demand.test() {
- return "stubbed call made - 1"
+ return 'stubbed call made - 1'
}
def ot = new Helper3403()
stub1.use {
- assert ot.doTest() == "stubbed call made - 1"
+ assert ot.doTest() == 'stubbed call made - 1'
}
def stub2 = new StubFor(Main3403)
stub2.demand.test() {
- return "stubbed call made - 2"
+ return 'stubbed call made - 2'
}
// the following stubbed call is on stub2 and its demand count should
be separate.
// Currently due to caching of MockProxyMetaClass, it gets counted
towards stub1 demands
// and throws "End of demands" exception
stub2.use {
- assert ot.doTest() == "stubbed call made - 2"
+ assert ot.doTest() == 'stubbed call made - 2'
}
}
-}
-class Main3403 {
- static test(){
- }
-}
+ static class Main3403 {
+ static test() {
+ }
+ }
-class Helper3403 {
- def doTest() {
- Main3403.test()
+ static class Helper3403 {
+ def doTest() {
+ Main3403.test()
+ }
}
}
diff --git a/src/test/groovy/bugs/Groovy3405Bug.groovy
b/src/test/groovy/bugs/Groovy3405.groovy
similarity index 76%
rename from src/test/groovy/bugs/Groovy3405Bug.groovy
rename to src/test/groovy/bugs/Groovy3405.groovy
index ee8a1d78bb..622de41232 100644
--- a/src/test/groovy/bugs/Groovy3405Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3405.groovy
@@ -21,7 +21,7 @@ package bugs
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Test
-class Groovy3405Bug {
+final class Groovy3405 {
@AfterEach
void tearDown() {
@@ -31,14 +31,14 @@ class Groovy3405Bug {
@Test
void testAddingStaticMethodsOnMCWithDefaultParameters() {
// test with 2 params having default values
- String.metaClass.'static'.testStaticTwoParams = { first = "foo",
second = "bar" -> return "$first - $second" }
- assert "baz - qux" == "".testStaticTwoParams("baz", "qux")
- assert "baz - bar" == "".testStaticTwoParams("baz")
- assert "foo - bar" == "".testStaticTwoParams()
+ String.metaClass.'static'.testStaticTwoParams = { first = 'foo',
second = 'bar' -> return "$first - $second" }
+ assert 'baz - qux' == ''.testStaticTwoParams('baz', 'qux')
+ assert 'baz - bar' == ''.testStaticTwoParams('baz')
+ assert 'foo - bar' == ''.testStaticTwoParams()
// test with 1 param having default value
- String.metaClass.'static'.testStaticOneParam = { first = "foo" ->
return first }
- assert "baz" == "".testStaticOneParam("baz")
- assert "foo" == "".testStaticOneParam()
+ String.metaClass.'static'.testStaticOneParam = { first = 'foo' ->
return first }
+ assert 'baz' == ''.testStaticOneParam('baz')
+ assert 'foo' == ''.testStaticOneParam()
}
}
diff --git a/src/test/groovy/bugs/Groovy3410Bug.groovy
b/src/test/groovy/bugs/Groovy3410.groovy
similarity index 74%
rename from src/test/groovy/bugs/Groovy3410Bug.groovy
rename to src/test/groovy/bugs/Groovy3410.groovy
index 1f78813c28..f4a3a17a6e 100644
--- a/src/test/groovy/bugs/Groovy3410Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3410.groovy
@@ -22,12 +22,11 @@ import org.junit.jupiter.api.Test
import static groovy.test.GroovyAssert.assertScript
-
-class Groovy3410Bug {
+final class Groovy3410 {
@Test
- void testClassVerificationErrorsWithBooleanExpUsingPrimitiveFields() {
- assertScript """
+ void testClassVerificationErrorsWithBooleanExpUsingPrimitiveFields1() {
+ assertScript '''
class Groovy3405N1 {
long id // or float or double
@@ -35,43 +34,59 @@ class Groovy3410Bug {
return (id ? true : false)
}
}
+
println new Groovy3405N1()
- """
+ '''
+ }
- assertScript """
+ @Test
+ void testClassVerificationErrorsWithBooleanExpUsingPrimitiveFields2() {
+ assertScript '''
class Groovy3405N2 {
long id
def bar() {
- return (id ? "a" : "b")
+ return (id ? 'a' : 'b')
}
}
+
println new Groovy3405N2()
- """
+ '''
+ }
- assertScript """
+ @Test
+ void testClassVerificationErrorsWithBooleanExpUsingPrimitiveFields3() {
+ assertScript '''
class Groovy3405N3 {
long id = 0
def bar() {
- assert id, "Done"
+ assert id, 'Done'
}
}
+
println new Groovy3405N3()
- """
+ '''
+ }
- assertScript """
+ @Test
+ void testClassVerificationErrorsWithBooleanExpUsingPrimitiveFields4() {
+ assertScript '''
class Groovy3405N4 {
long id = 0
def bar() {
while(id){
- print "here"
+ print 'here'
break
}
}
}
+
println new Groovy3405N4()
- """
+ '''
+ }
- assertScript """
+ @Test
+ void testClassVerificationErrorsWithBooleanExpUsingPrimitiveFields5() {
+ assertScript '''
class Groovy3405N5 {
long id = 0
def bar() {
@@ -82,7 +97,8 @@ class Groovy3410Bug {
}
}
}
+
println new Groovy3405N5()
- """
+ '''
}
}
diff --git a/src/test/groovy/bugs/Groovy3422.groovy
b/src/test/groovy/bugs/Groovy3422.groovy
index c47f2e1567..01fa16c3bb 100644
--- a/src/test/groovy/bugs/Groovy3422.groovy
+++ b/src/test/groovy/bugs/Groovy3422.groovy
@@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test
import static groovy.test.GroovyAssert.assertScript
final class Groovy3422 {
+
@Test
void testStaticClosureProperty() {
assertScript '''
diff --git a/src/test/groovy/bugs/Groovy3424Bug.groovy
b/src/test/groovy/bugs/Groovy3424.groovy
similarity index 85%
rename from src/test/groovy/bugs/Groovy3424Bug.groovy
rename to src/test/groovy/bugs/Groovy3424.groovy
index 2ff972d143..7a7ee63c0a 100644
--- a/src/test/groovy/bugs/Groovy3424Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3424.groovy
@@ -22,10 +22,10 @@ import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
-class Groovy3424Bug {
+final class Groovy3424 {
- MetaClassRegistry registry
- MetaClass originalMetaClass
+ private MetaClassRegistry registry
+ private MetaClass originalMetaClass
@BeforeEach
void setUp() {
@@ -84,15 +84,15 @@ class Groovy3424Bug {
assert newFoo() instanceof Groovy3424Foo
}
-}
-
-class Groovy3424Foo {}
-
-class Groovy3424ClassProxyMetaClass extends ProxyMetaClass {
- Groovy3424ClassProxyMetaClass(MetaClassRegistry metaClassRegistry, Class
aClass, MetaClass adaptee) {
- super(metaClassRegistry, aClass, adaptee)
+ static class Groovy3424Foo {
}
- public Object invokeConstructor(final Object[] arguments) {
- 'constructor'
+
+ static class Groovy3424ClassProxyMetaClass extends ProxyMetaClass {
+ Groovy3424ClassProxyMetaClass(MetaClassRegistry metaClassRegistry,
Class aClass, MetaClass adaptee) {
+ super(metaClassRegistry, aClass, adaptee)
+ }
+ Object invokeConstructor(final Object[] arguments) {
+ 'constructor'
+ }
}
}
diff --git a/src/test/groovy/bugs/Groovy3426Bug.groovy
b/src/test/groovy/bugs/Groovy3426.groovy
similarity index 75%
rename from src/test/groovy/bugs/Groovy3426Bug.groovy
rename to src/test/groovy/bugs/Groovy3426.groovy
index 99d8594f88..fffb896ca8 100644
--- a/src/test/groovy/bugs/Groovy3426Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3426.groovy
@@ -22,10 +22,10 @@ import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
-class Groovy3426Bug {
+final class Groovy3426 {
- MetaClassRegistry registry
- MetaClass originalMetaClass
+ private MetaClassRegistry registry
+ private MetaClass originalMetaClass
@BeforeEach
void setUp() {
@@ -54,17 +54,16 @@ class Groovy3426Bug {
assert 'foo' == getFoo()
}
-}
-
-class Groovy3426Foo {
- static get() { 'foo' }
-}
-
-class Groovy3426ClassProxyMetaClass extends ProxyMetaClass {
- Groovy3426ClassProxyMetaClass(MetaClassRegistry metaClassRegistry, Class
aClass, MetaClass adaptee) {
- super(metaClassRegistry, aClass, adaptee)
+ static class Groovy3426Foo {
+ static get() { 'foo' }
}
- public Object invokeStaticMethod(final Object aClass, final String method,
final Object[] arguments) {
- 'static'
+
+ static class Groovy3426ClassProxyMetaClass extends ProxyMetaClass {
+ Groovy3426ClassProxyMetaClass(MetaClassRegistry metaClassRegistry,
Class aClass, MetaClass adaptee) {
+ super(metaClassRegistry, aClass, adaptee)
+ }
+ public Object invokeStaticMethod(final Object aClass, final String
method, final Object[] arguments) {
+ 'static'
+ }
}
}
diff --git a/src/test/groovy/bugs/Groovy3446Bug.groovy
b/src/test/groovy/bugs/Groovy3446.groovy
similarity index 89%
rename from src/test/groovy/bugs/Groovy3446Bug.groovy
rename to src/test/groovy/bugs/Groovy3446.groovy
index f4d50310ad..a71f858ae8 100644
--- a/src/test/groovy/bugs/Groovy3446Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3446.groovy
@@ -20,13 +20,14 @@ package bugs
import org.junit.jupiter.api.Test
-class Groovy3446Bug {
+final class Groovy3446 {
+
@Test
void testLocalMethodFavoredOverStaticallyImportedMethod() {
- assert currentTimeMillis() == "local method called"
+ assert currentTimeMillis() == 'local method called'
}
def currentTimeMillis() {
- "local method called"
+ 'local method called'
}
}
diff --git a/src/test/groovy/bugs/Groovy3462Bug.groovy
b/src/test/groovy/bugs/Groovy3462.groovy
similarity index 79%
rename from src/test/groovy/bugs/Groovy3462Bug.groovy
rename to src/test/groovy/bugs/Groovy3462.groovy
index b239a167d3..80aabc710c 100644
--- a/src/test/groovy/bugs/Groovy3462Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3462.groovy
@@ -22,21 +22,20 @@ import org.junit.jupiter.api.Test
import static groovy.test.GroovyAssert.assertScript
-
-class Groovy3462Bug {
+final class Groovy3462 {
@Test
void testClosureWithParameterHavingDefaultExpression() {
- assertScript """
- month = { String date = new Date().format("yyyyMM") ->
+ assertScript '''
+ month = { String date = new Date().format('yyyyMM') ->
date
}
- def obj = month("200101")
- assert month("200101") == "200101"
+ def obj = month('200101')
+ assert month('200101') == '200101'
- String expectedDate = new Date().format("yyyyMM")
+ String expectedDate = new Date().format('yyyyMM')
assert month() == expectedDate
- """
+ '''
}
}
diff --git a/src/test/groovy/bugs/Groovy3464Bug.groovy
b/src/test/groovy/bugs/Groovy3464.groovy
similarity index 76%
rename from src/test/groovy/bugs/Groovy3464Bug.groovy
rename to src/test/groovy/bugs/Groovy3464.groovy
index 768434a366..38a6d5a9d3 100644
--- a/src/test/groovy/bugs/Groovy3464Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3464.groovy
@@ -27,18 +27,20 @@ import org.junit.jupiter.api.Test
import static groovy.test.GroovyAssert.shouldFail
/**
- * GROOVY-3463:
* Spring/CGLIB proxies throw exception "object is not an instance of
declaring class"
*/
-class Groovy3464Bug {
+final class Groovy3464 {
- GroovyShell shell
- CompilerConfiguration config
- File targetDir, stubDir
+ private GroovyShell shell
+ private CompilerConfiguration config
+ private File targetDir, stubDir
+
+ private static File createTempDir() {
+ File.createTempDir('Groovy3464',
Long.toString(System.currentTimeMillis()))
+ }
@BeforeEach
void setUp() {
-
config = new CompilerConfiguration()
config.with {
targetDirectory = createTempDir()
@@ -50,10 +52,10 @@ class Groovy3464Bug {
groovyFile << '''
class GroovyThing {
- String m1() { "thing.m1" }
- String m2() { m1() + " called from thing.m2"}
+ String m1() { 'thing.m1' }
+ String m2() { m1() + ' called from thing.m2'}
}
- '''
+ '''
javaFile << '''
public class JavaThing extends GroovyThing {
@@ -61,7 +63,7 @@ class Groovy3464Bug {
return "javaThing.m3 calling m2 " + m2();
}
}
- '''
+ '''
def loader = new GroovyClassLoader(this.class.classLoader)
def cu = new JavaAwareCompilationUnit(config, loader)
@@ -70,20 +72,18 @@ class Groovy3464Bug {
cu.compile()
} catch (any) {
any.printStackTrace()
- assert false, "Compilation of the Groovy and Java files should
have succeeded"
+ assert false, 'Compilation of the Groovy and Java files should
have succeeded'
}
- this.shell = new GroovyShell(loader)
-
+ shell = new GroovyShell(loader)
}
@AfterEach
void tearDown() {
+ stubDir?.deleteDir()
+ targetDir?.deleteDir()
config.targetDirectory?.deleteDir()
config.jointCompilationOptions?.stubDir?.deleteDir()
- targetDir?.deleteDir()
- stubDir?.deleteDir()
-
}
@Test
@@ -91,11 +91,11 @@ class Groovy3464Bug {
shouldFail(MissingMethodException) {
shell.evaluate '''
def t = new GroovyThing()
- assert t.m3() == "javaThing.m3 calling m2 thing.m1 called from
thing.m2"
+ assert t.m3() == 'javaThing.m3 calling m2 thing.m1 called from
thing.m2'
t = new JavaThing()
t.m3()
- assert false, "Method m3() should not be found"
+ assert false : 'Method m3() should not be found'
'''
}
}
@@ -104,16 +104,11 @@ class Groovy3464Bug {
void testScenarioTwo() {
shell.evaluate '''
def t = new GroovyThing()
- assert t.m2() == "thing.m1 called from thing.m2"
+ assert t.m2() == 'thing.m1 called from thing.m2'
t = new JavaThing()
- assert t.m3() == "javaThing.m3 calling m2 thing.m1 called from
thing.m2"
+ assert t.m3() == 'javaThing.m3 calling m2 thing.m1 called from
thing.m2'
'''
}
-
- static File createTempDir() {
- File tempDirectory = File.createTempDir("Groovy3464Bug",
Long.toString(System.currentTimeMillis()))
- return tempDirectory
- }
}
diff --git a/src/test/groovy/bugs/Groovy3465Bug.groovy
b/src/test/groovy/bugs/Groovy3465.groovy
similarity index 79%
rename from src/test/groovy/bugs/Groovy3465Bug.groovy
rename to src/test/groovy/bugs/Groovy3465.groovy
index 98907bf28e..9d11436600 100644
--- a/src/test/groovy/bugs/Groovy3465Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3465.groovy
@@ -18,18 +18,27 @@
*/
package bugs
+import groovy.transform.PackageScope
import org.junit.jupiter.api.Test
import static bugs.Groovy3465Helper.func
-class Groovy3465Bug {
+final class Groovy3465 {
+
@Test
void testCallingAStaticImportedMethodWithNamedParamaters() {
-
func text: 'Some text', value: 1
-
func(text: 'Some text', value: 1)
-
func([text: 'Some text', value: 1])
}
}
+
+@PackageScope class Groovy3465Helper {
+
+ static func(arg) {
+ assert arg instanceof Map
+ assert arg.size() == 2
+ assert arg.containsKey('text') && arg.containsKey('value')
+ return arg
+ }
+}
diff --git a/src/test/groovy/bugs/Groovy3465Helper.groovy
b/src/test/groovy/bugs/Groovy3465Helper.groovy
deleted file mode 100644
index 064eb5d391..0000000000
--- a/src/test/groovy/bugs/Groovy3465Helper.groovy
+++ /dev/null
@@ -1,28 +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 Groovy3465Helper {
- static func(arg) {
- assert arg instanceof Map
- assert arg.size() == 2
- assert arg.containsKey('text') && arg.containsKey('value')
- return arg
- }
-}
diff --git a/src/test/groovy/bugs/Groovy3498Bug.groovy
b/src/test/groovy/bugs/Groovy3498.groovy
similarity index 80%
rename from src/test/groovy/bugs/Groovy3498Bug.groovy
rename to src/test/groovy/bugs/Groovy3498.groovy
index db41540b60..5fc68495a8 100644
--- a/src/test/groovy/bugs/Groovy3498Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3498.groovy
@@ -20,13 +20,15 @@ package bugs
import org.junit.jupiter.api.Test
+import static groovy.test.GroovyAssert.assertScript
+
+final class Groovy3498 {
-class Groovy3498Bug {
@Test
void testClosureExpressionFiltering() {
- new GroovyShell().evaluate """
- { -> assert false, 'This statement should not have been executed' }
- println 'Ok'
- """
+ assertScript '''
+ { -> assert false : 'This statement should not have been executed'
}
+ println 'Ok'
+ '''
}
}
diff --git a/src/test/groovy/bugs/Groovy3509Bug.groovy
b/src/test/groovy/bugs/Groovy3509.groovy
similarity index 91%
rename from src/test/groovy/bugs/Groovy3509Bug.groovy
rename to src/test/groovy/bugs/Groovy3509.groovy
index 4606361fcc..12249fc68a 100644
--- a/src/test/groovy/bugs/Groovy3509Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3509.groovy
@@ -20,8 +20,7 @@ package bugs
import org.junit.jupiter.api.Test
-
-class Groovy3509Bug {
+final class Groovy3509 {
@Test
void testGPathInconcistency() {
@@ -72,16 +71,16 @@ class Groovy3509Bug {
// even with this intermediary null node, we should still get 3
assert root?.level1?.level2?.level3.sum() == 3
}
-}
-class Root {
- List level1 = []
-}
+ static class Root {
+ List level1 = []
+ }
-class Level2 {
- Integer level3
-}
+ static class Level2 {
+ Integer level3
+ }
-class Level1 {
- Level2 level2
+ static class Level1 {
+ Level2 level2
+ }
}
diff --git a/src/test/groovy/bugs/Groovy3645.groovy
b/src/test/groovy/bugs/Groovy3511.groovy
similarity index 56%
copy from src/test/groovy/bugs/Groovy3645.groovy
copy to src/test/groovy/bugs/Groovy3511.groovy
index e64919f022..717f3d721c 100644
--- a/src/test/groovy/bugs/Groovy3645.groovy
+++ b/src/test/groovy/bugs/Groovy3511.groovy
@@ -18,20 +18,33 @@
*/
package bugs
+import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation
import org.junit.jupiter.api.Test
import static groovy.test.GroovyAssert.shouldFail
-final class Groovy3645 {
+final class Groovy3511 {
+
@Test
- void testMethodCallOnSuperInAStaticMethod() {
- def err = shouldFail MissingMethodException, '''
- class Foo3645 {
- static main(args) {
- super.bar()
- }
- }
- '''
- assert err.message.contains('No signature of static method: bar for
class: java.lang.Object')
+ void testExceptionMessageStringToNumberConversion() {
+ def ex = shouldFail {
+ Double test = 'Hello'
+ }
+ assert ex.message.contains(Double.class.name)
+
+ ex = shouldFail {
+ Float test = 'Hello'
+ }
+ assert ex.message.contains(Float.class.name)
+
+ ex = shouldFail {
+ DefaultTypeTransformation.castToNumber('Hello', Long.class)
+ }
+ assert ex.message.contains(Long.class.name)
+
+ ex = shouldFail {
+ DefaultTypeTransformation.castToNumber('Hello')
+ }
+ assert ex.message.contains(Number.class.name)
}
}
diff --git a/src/test/groovy/bugs/Groovy3511Bug.groovy
b/src/test/groovy/bugs/Groovy3511Bug.groovy
deleted file mode 100644
index 9bcb61d9da..0000000000
--- a/src/test/groovy/bugs/Groovy3511Bug.groovy
+++ /dev/null
@@ -1,60 +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.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation
-import org.junit.jupiter.api.Test
-
-import static org.junit.jupiter.api.Assertions.assertTrue
-import static org.junit.jupiter.api.Assertions.fail
-
-class Groovy3511Bug {
- final SHOULD_HAVE_FAILED = "The conversion above should have failed"
- @Test
- void testExceptionMessageStringToNumberConversion() {
- try {
- Double test = "Hello"
- fail(SHOULD_HAVE_FAILED)
- } catch (ex) {
- verifyExceptionMsg(ex, Double.class.name)
- }
- try {
- Float test = "Hello"
- fail(SHOULD_HAVE_FAILED)
- } catch (ex) {
- verifyExceptionMsg(ex, Float.class.name)
- }
- try {
- DefaultTypeTransformation.castToNumber("Hello", Long.class)
- fail(SHOULD_HAVE_FAILED)
- } catch (ex) {
- verifyExceptionMsg(ex, Long.class.name)
- }
- try {
- DefaultTypeTransformation.castToNumber("Hello")
- fail(SHOULD_HAVE_FAILED)
- } catch (ex) {
- verifyExceptionMsg(ex, Number.class.name)
- }
- }
-
- def verifyExceptionMsg(ex, className) {
- assertTrue ex.message.contains(className)
- }
-}
diff --git a/src/test/groovy/bugs/Groovy3519Bug.groovy
b/src/test/groovy/bugs/Groovy3519.groovy
similarity index 89%
rename from src/test/groovy/bugs/Groovy3519Bug.groovy
rename to src/test/groovy/bugs/Groovy3519.groovy
index 6817c19209..d955004c03 100644
--- a/src/test/groovy/bugs/Groovy3519Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3519.groovy
@@ -22,8 +22,7 @@ import org.junit.jupiter.api.Test
import static groovy.test.GroovyAssert.assertScript
-
-class Groovy3519Bug {
+final class Groovy3519 {
@Test
void testShouldSkipPrivateMethodsFromCovariantReturnTypeChecks() {
@@ -34,32 +33,32 @@ class Groovy3519Bug {
}
def a = new A()
assert a.bar() == "1"
+
class B extends A {
Integer foo() {2}
}
def b = new B()
- assert b.bar()=="1"
+ assert b.bar() == "1"
'''
}
@Test
void testShouldSkipPrivateMethodsFromCovariantReturnTypeChecksCS() {
- assertScript '''import groovy.transform.CompileStatic
-
- @CompileStatic
+ assertScript '''
+ @groovy.transform.CompileStatic
class A {
private String foo() { "1" }
def bar() { foo() }
}
def a = new A()
assert a.bar() == "1"
- @CompileStatic
+
+ @groovy.transform.CompileStatic
class B extends A {
Integer foo() {2}
}
def b = new B()
- assert b.bar()=="1"
+ assert b.bar() == "1"
'''
}
-
}
diff --git a/src/test/groovy/bugs/Groovy3560Bug.groovy
b/src/test/groovy/bugs/Groovy3560.groovy
similarity index 97%
rename from src/test/groovy/bugs/Groovy3560Bug.groovy
rename to src/test/groovy/bugs/Groovy3560.groovy
index c50b16d2eb..c2961b4f69 100644
--- a/src/test/groovy/bugs/Groovy3560Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3560.groovy
@@ -20,8 +20,8 @@ package bugs
import org.junit.jupiter.api.Test
+final class Groovy3560 {
-class Groovy3560Bug {
@Test
void testVarArgsWithAnInterfaceAsVarArgArrayType() {
assert Groovy3560Helper.m1(new Groovy3560A(), new Groovy3560B()) == 2
diff --git a/src/test/groovy/bugs/Groovy3574Bug.groovy
b/src/test/groovy/bugs/Groovy3574.groovy
similarity index 70%
rename from src/test/groovy/bugs/Groovy3574Bug.groovy
rename to src/test/groovy/bugs/Groovy3574.groovy
index 6705b08d6e..bc9797c14c 100644
--- a/src/test/groovy/bugs/Groovy3574Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3574.groovy
@@ -20,30 +20,27 @@ package bugs
import org.junit.jupiter.api.Test
-import static org.junit.jupiter.api.Assertions.fail
+import static groovy.test.GroovyAssert.shouldFail
+final class Groovy3574 {
-class Groovy3574Bug {
@Test
void testToStringCallDelegationToConvertedClosureProxy() {
Closure failing1 = {
- throw new RuntimeException("Call to this closure fails.")
+ throw new RuntimeException('Call to this closure fails.')
}
Closure failing2 = { a, b ->
- assert a == "a"
- assert b == "b"
- throw new RuntimeException("Call to this closure fails.")
+ assert a == 'a'
+ assert b == 'b'
+ throw new RuntimeException('Call to this closure fails.')
}
MyType3574A instance1 = failing1 as MyType3574A
// test call without args
- try{
+ shouldFail {
instance1.m()
- fail("The call m() should have failed - 1")
- } catch (ex) {
- // ok, if it failed
}
// this call was getting delegated to the closure earlier
@@ -51,18 +48,15 @@ class Groovy3574Bug {
// test call with args
MyType3574B instance2 = failing2 as MyType3574B
- try{
- instance2.m("a", "b")
- fail("The call m() should have failed - 2")
- } catch (ex) {
- // ok, if it failed
+ shouldFail {
+ instance2.m('a', 'b')
}
// this call was getting delegated to the closure earlier
assert instance2.toString() != null
}
-}
-interface MyType3574A { def m()}
+ interface MyType3574A { def m() }
-interface MyType3574B { def m(a, b)}
+ interface MyType3574B { def m(a, b) }
+}
diff --git a/src/test/groovy/bugs/Groovy3590Bug.groovy
b/src/test/groovy/bugs/Groovy3590.groovy
similarity index 94%
rename from src/test/groovy/bugs/Groovy3590Bug.groovy
rename to src/test/groovy/bugs/Groovy3590.groovy
index 78a96dab5e..bb9278280d 100644
--- a/src/test/groovy/bugs/Groovy3590Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3590.groovy
@@ -20,11 +20,11 @@ package bugs
import org.junit.jupiter.api.Test
+final class Groovy3590 {
-class Groovy3590Bug {
@Test
void testMapDefaultValueGetWithPrevKeyHavingNullValue() {
- def map = ['key':null]
+ def map = [key: null]
assert map.get('key', this) == null
}
}
diff --git a/src/test/groovy/bugs/Groovy3596Bug.groovy
b/src/test/groovy/bugs/Groovy3596.groovy
similarity index 92%
rename from src/test/groovy/bugs/Groovy3596Bug.groovy
rename to src/test/groovy/bugs/Groovy3596.groovy
index 94d5871449..505cec0852 100644
--- a/src/test/groovy/bugs/Groovy3596Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3596.groovy
@@ -21,13 +21,13 @@ package bugs
import gls.CompilableTestSupport
import org.junit.jupiter.api.Test
-final class Groovy3596Bug extends CompilableTestSupport {
+final class Groovy3596 extends CompilableTestSupport {
@Test
void testMapReferenceWithGenericsTypeParameters() {
- shouldCompile """
+ shouldCompile '''
interface TypeDescriptor3596 {}
interface MapDescriptor3596 extends Map<String,
TypeDescriptor3596> {}
- """
+ '''
}
}
diff --git a/src/test/groovy/bugs/Groovy3645.groovy
b/src/test/groovy/bugs/Groovy3645.groovy
index e64919f022..4a8b3f34db 100644
--- a/src/test/groovy/bugs/Groovy3645.groovy
+++ b/src/test/groovy/bugs/Groovy3645.groovy
@@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test
import static groovy.test.GroovyAssert.shouldFail
final class Groovy3645 {
+
@Test
void testMethodCallOnSuperInAStaticMethod() {
def err = shouldFail MissingMethodException, '''
diff --git a/src/test/groovy/bugs/Groovy3679Bug.groovy
b/src/test/groovy/bugs/Groovy3679.groovy
similarity index 76%
rename from src/test/groovy/bugs/Groovy3679Bug.groovy
rename to src/test/groovy/bugs/Groovy3679.groovy
index 3bc59ff034..2285c3d3b7 100644
--- a/src/test/groovy/bugs/Groovy3679Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3679.groovy
@@ -20,34 +20,34 @@ package bugs
import org.junit.jupiter.api.Test
+final class Groovy3679 {
-class Groovy3679Bug {
@Test
void testMapEntryWinOverPvtAndPkgPrivateClassFields() {
// map entry should win over a package-private field
def map1 = new HashMap()
- map1["table"] = "Some table"
- assert map1["table"] != null
+ map1['table'] = 'Some table'
+ assert map1['table'] != null
// map entry should win over a private field
def map2 = [:]
- map2["header"] = "Some header"
- assert map2["header"] != null
+ map2['header'] = 'Some header'
+ assert map2['header'] != null
// following is to verify that setting of private fields with .@"$x"
syntax is not
// broken by the fix introduced
def x = new X3679()
- x.setSomething("foo",2)
+ x.setSomething('foo', 2)
assert x.getAFoo() == 2
}
-}
-class X3679 extends HashMap {
- private foo
- def setSomething(String x,y) {
- this.@"$x" = y
- }
- def getAFoo() {
- return foo
+ static class X3679 extends HashMap {
+ private foo
+ def setSomething(String x,y) {
+ this.@"$x" = y
+ }
+ def getAFoo() {
+ return foo
+ }
}
}