Groovy动态语言 运行在JVM中的动态语言 可以方便的处理业务逻辑变化大的业务

源代码在线查看: variableprecedence.groovy

软件大小: 1644 K
上传用户: maple_78
关键词: Groovy JVM 动态语言 运行
下载地址: 免注册下载 普通下载 VIP

相关代码

				/**
				 * @author John Wilson
				 * @version $Revision: 3827 $
				 */
				class VariblePrecedence extends GroovyTestCase {
				    
				    void testVariablePrecedence() {
				 
				        assertScript( """
				            class VariableFoo {
				                def x = 100
				                def y = 93
				                def c = {x -> assert x == 1; assert y == 93; }
				
				                static void main(args) {
				                    def vfoo = new VariableFoo()
				                    vfoo.c.call(1)
				
				                    def z = 874;
				                    1.times { assert vfoo.x == 100; assert z == 874; z = 39; }
				                    assert z == 39;
				
				                    vfoo.local();
				                }
				
				                void local() {
				                    c.call(1);
				
				                    def z = 874;
				                    1.times { assert x == 100; assert z == 874; z = 39; }
				                    assert z == 39;
				                }
				            }
				
				        """ );
				
				    }
				
				
				/*
				 * CURRENTLY BROKEN.  Variable scoping needs an overhaul to * fix it.
				 */
				    void testVariablePrecedenceInScript_FAILS() { if (notYetImplemented()) return
				        assertScript( """
				            c = { x -> assert x == 1; assert y == 93; }
				            x = 100;
				            y = 93;
				
				            c.call(1);
				        """);
				    }
				
				}
							

相关资源