大名鼎鼎的java动态脚本语言。已经通过了sun的认证

源代码在线查看: closurevariablebug.groovy

软件大小: 1630 K
上传用户: hjf
关键词: java sun 动态 脚本
下载地址: 免注册下载 普通下载 VIP

相关代码

				/**				 * @version $Revision: 1.8 $				 */				class ClosureVariableBug extends GroovyTestCase {				    				    void testClosurePassingBug() {				        def count = 0				        def closure = { assert count == it }				        closure(0)				        				        count = 1				        closure(1)				    }				    				    void testPassingClosureAsNamedParameter() {				        def x = 123				        				        def foo = new Expando(a:{x}, b:456)				    				        assert foo.a != null				        				        println "Foo has a = ${foo.a}"				        				        def value = foo.a()				        assert value == 123				    }				    				    void testBug() {				        def value = callClosure([1, 2])				        assert value == 2				    }				    				    protected Integer callClosure(collection) {				        Integer x				        /** @todo				        Integer x = 0				        */				        collection.each { x = it }				        return x				    }				}			

相关资源