blob: 62afb63e6ac1c6f7fb5430c1b56b1916910d58c2 [file] [log] [blame]
import org.codehaus.groovy.classgen.TestSupport
/**
* @version $Revision$
*/
class VariableScopingBug extends TestSupport {
void testBug() {
// undeclared variable x
shouldFail {
for (z in 0..2) {
x = makeCollection()
}
for (t in 0..3) {
for (y in x) {
println x
}
}
}
}
void testVariableReuse() {
for (z in 0..2) {
x = makeCollection()
}
for (t in 0..3) {
x = 123
println x
}
}
protected makeCollection() {
return [1, 2, 3]
}
}