home | career | drupal | java | mac | mysql | perl | scala | uml | unix

Groovy example source code file (ClosureParameterPassingBug.groovy)

This example Groovy source code file (ClosureParameterPassingBug.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

closureparameterpassingbug, closureparameterpassingbug, could, could, testsupport, testsupport

The Groovy ClosureParameterPassingBug.groovy source code

package groovy.bugs

import org.codehaus.groovy.classgen.TestSupport

/**
 * @author John Wilson
 * @version $Revision: 4996 $
 */
class ClosureParameterPassingBug extends TestSupport {
    
    void testBugInMethod() {
        def c = { x ->
            def y = 123
            def c1 = {
                println y
                println x
                println x[0]
            }

            c1()
        }

        c([1])
    }

    void testBug() {
        assertScript """
def c = { x ->
    def y = 123
    def c1 = { 
        assert x != null , "Could not find a value for x"
        assert y == 123 , "Could not find a value for y"
        println x[0]
    }

    c1()
} 

c([1]) 
"""
    }
   
}

Other Groovy examples (source code examples)

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

new blog posts

 

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