📄 optionalreturntest.groovy
字号:
class OptionalReturnTest extends GroovyTestCase { def y void testSingleExpression() { def value = foo() assert value == 'fooReturn' } void testLastExpressionIsSimple() { def value = bar() assert value == 'barReturn' } void testLastExpressionIsBooleanExpression() { def value = foo2() assert value value = foo3() assert value == false } void testLastExpressionIsAssignment() { def value = assign() assert value == 'assignReturn' value = assignField() assert value == 'assignFieldReturn' } void testLastExpressionIsMethodCall() { def value = methodCall() assert value == 'fooReturn' } void testEmptyExpression() { def value = nullReturn() assert value == null } // now this is not a compile time error in jsr-03 void testVoidMethod() { def value = voidMethod() assert value == null } void testNonAssignmentLastExpressions() { def value = lastIsAssert() assert value == null } def foo() { 'fooReturn' } def bar() { def x = 'barReturn' x } def foo2() { def x = 'cheese' x == 'cheese' } def foo3() { def x = 'cheese' x == 'edam' } def assign() { def x = 'assignReturn' } def assignField() { y = 'assignFieldReturn' } def nullReturn() { } def lastIsAssert() { assert 1 == 1 } def methodCall() { foo() } void voidMethod() { foo() }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -