blob: 5328bf081687cc8fa9d7f75230f9a8ede533583e [file] [log] [blame]
package gls.scope
import gls.scope.CompilableTestSupport
public class StaticScopeTest extends CompilableTestSupport {
public void testNormalStaticScope() {
shouldNotCompile("""
static foo() {
foo = 1
}
""")
shouldCompile("""
static foo() {
def foo=1
}
""")
assertScript("""
class A {
static i
static foo() {
i=1
}
}
A.foo()
assert A.i == 1
""")
}
public void testClosureInStaticScope() {
shouldCompile("""
5.times { foo=2 }
""")
shouldCompile("""
5.times { foo=it }
""")
}
}