importtest.groovy

来自「Groovy动态语言 运行在JVM中的动态语言 可以方便的处理业务逻辑变化大的业」· GROOVY 代码 · 共 28 行

GROOVY
28
字号
import java.io.*
import java.util.Map
import java.util.List

class ImportTest extends GroovyTestCase {

    void testImportAll() {
        def file = new File("foo.txt")
        assert file instanceof File
        assert file.getClass().name == "java.io.File"
    }
    
    void testImportByName() {
        def x = [:]
        assert x instanceof Map
        /**
         * For maps, map.getClass() should be used instead of map.class,
         * when map has no member, named as "class"
         */
        assert x.getClass() != null
        assert x.getClass().name.startsWith("java.util.")
        
        def y = [1, 2, 3]
        assert y instanceof List
        assert y.getClass().name.startsWith("java.util.")
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?