printtest.groovy

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

GROOVY
34
字号
class PrintTest extends GroovyTestCase {

    void testToString_FAILS() { if (notYetImplemented()) return
        assertToString("hello", 'hello')
        
        assertToString([], "[]")
        assertToString([1, 2, "hello"], '[1, 2, hello]')
        
        assertToString([1:20, 2:40, 3:'cheese'], '[1=20, 2=40, 3=cheese]')
        assertToString([:], "[:]")

        assertToString([['bob':'drools', 'james':'geronimo']], '[[james:geronimo, bob:drools]]')
        assertToString([5, ["bob", "james"], ["bob":"drools", "james":"geronimo"], "cheese"], '[5, [bob, james], [james:geronimo, bob:drools], cheese]')
    }

    void testInspect() {
        assertInspect("hello", '"hello"')
        
        assertInspect([], "[]")
        assertInspect([1, 2, "hello"], '[1, 2, "hello"]')
        
        assertInspect([1:20, 2:40, 3:'cheese'], '[1:20, 2:40, 3:"cheese"]')
        assertInspect([:], "[:]")

        assertInspect([['bob':'drools', 'james':'geronimo']], '[["james":"geronimo", "bob":"drools"]]')
        assertInspect([5, ["bob", "james"], ["bob":"drools", "james":"geronimo"], "cheese"], '[5, ["bob", "james"], ["james":"geronimo", "bob":"drools"], "cheese"]')
    }
    
    void testCPlusPlusStylePrinting() {
        def endl = "\n"
        
        System.out << "Hello world!" << endl
    }
}

⌨️ 快捷键说明

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