📄 instanceoftest.groovy
字号:
import java.util.Mapclass InstanceofTest extends GroovyTestCase { void testTrue() { def x = false def o = 12 if ( o instanceof Integer ) { x = true } assert x == true } void testFalse() { def x = false def o = 12 if ( o instanceof Double ) { x = true } assert x == false } void testImportedClass() { def m = ["xyz":2] assert m instanceof Map assert !(m instanceof Double) assertTrue(m instanceof Map) assertFalse(m instanceof Double) } void testFullyQualifiedClass() { def l = [1, 2, 3] assert l instanceof java.util.List assert !(l instanceof Map) assertTrue(l instanceof java.util.List) assertFalse(l instanceof Map) }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -