alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (Groovy3156And2621Bug.groovy)

This example Groovy source code file (Groovy3156And2621Bug.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

groovy3156and2621bug, groovy3156and2621bug, groovytestcase, groovytestcase

The Groovy Groovy3156And2621Bug.groovy source code

package groovy.bugs

class Groovy3156And2621Bug extends GroovyTestCase {
    void testMethodNameResolutionInANestedClosure() {
        assert m() == 'method'
        assert c1() == 'method'
    }

    void testSimilarNamesForMethodAndLocalWithLocalAsMethodArgument() {
        failingExecute()
    }

    def m = { return 'method' }
    def c1 = {
        def m = { return 'c1' }
        def c2 = {
            /*
            *  If both 'm()' and 'this.m()' are used as follows,
            *  'this.m()' should not resolve to c1 closure's 'm' local variable.
            *  It should resolve to outermost class' m().
            */
            assert m() == 'c1'
            return this.m()
        }
        return c2()
    }

    void convention(String arg) {
        println 'called'
    }
    
    void failingExecute() {
        def convention= 'value'
        1.times {
            this.convention(convention)
        }
    }
}

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy Groovy3156And2621Bug.groovy source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.