You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/07/16 03:04:52 UTC
[groovy] branch GROOVY_3_0_X updated: additional test case
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
new 8efeeed additional test case
8efeeed is described below
commit 8efeeed3633ec338b8b46c91d4e4302e459b11bb
Author: Paul King <pa...@asert.com.au>
AuthorDate: Thu Jul 16 13:04:43 2020 +1000
additional test case
---
src/test/groovy/bugs/MethodClosureTest.groovy | 40 +++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/src/test/groovy/bugs/MethodClosureTest.groovy b/src/test/groovy/bugs/MethodClosureTest.groovy
index bdba5fd..03599e4 100644
--- a/src/test/groovy/bugs/MethodClosureTest.groovy
+++ b/src/test/groovy/bugs/MethodClosureTest.groovy
@@ -58,7 +58,6 @@ class MethodClosureTest extends GroovyTestCase {
assert list == [1]
}
-
void testShellVariable() {
def shell = new GroovyShell()
assert shell.evaluate("x = String.&toUpperCase; x('abc')") == "ABC"
@@ -66,5 +65,42 @@ class MethodClosureTest extends GroovyTestCase {
assert shell.evaluate("x = Integer.&parseInt; x('123')") == 123
assert shell.evaluate("x = 3.&parseInt; x('123')") == 123
}
-}
+ void testMethodClosureWithCategory() {
+ assertScript '''
+ class Bar {
+ protected methodClosure
+ def storeMethodClosure() {
+ methodClosure = this.&method
+ }
+ }
+
+ class Foo extends Bar {
+ def storeMethodClosure() {
+ methodClosure = super.&method
+ }
+ }
+
+ class BarCategory {
+ static method(Bar self) { 'result' }
+ }
+
+ def bar = new Bar()
+ def foo = new Foo()
+ bar.storeMethodClosure()
+ foo.storeMethodClosure()
+ try {
+ bar.methodClosure()
+ assert false
+ } catch(MissingMethodException ignore) {}
+ try {
+ foo.methodClosure()
+ assert false
+ } catch(MissingMethodException ignore) {}
+ use(BarCategory) {
+ assert bar.methodClosure() == 'result'
+ assert foo.methodClosure() == 'result'
+ }
+ '''
+ }
+}