blob: c16b54e42916c698437078354b141d8bb9303893 [file] [log] [blame]
/**
* Tests Closures in Groovy
*
* @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
* @version $Revision$
*/
class ClosureReturnTest extends GroovyTestCase {
void testReturnValues() {
block = {x| return x > 5}
value = block.call(10)
assert value
value = block.call(3)
assert value == false
}
void testReturnValueUsingFunction() {
block = {x| return someFunction(x) }
value = block.call(10)
assert value
value = block.call(3)
assert value == false
}
someFunction(x) {
return x > 5
}
}