stringoperationtest.groovy

来自「大名鼎鼎的java动态脚本语言。已经通过了sun的认证」· GROOVY 代码 · 共 42 行

GROOVY
42
字号
class StringOperationTest extends GroovyTestCase {    def x    def y        void testPlus() {        x = "hello " + "there"        assert x == "hello there"                x = "hello " + 2        assert x == "hello 2"                x = "hello " + 1.2        assert x == "hello 1.2"                y = x + 1        assert y == "hello 1.21"            }	void testLongPlus() {	    x = "hello" + " " + "there" + " nice" + " day"	    	    assert x == "hello there nice day"	}	    void testMinus() {		x = "the quick brown fox" - "quick "				assert x == "the brown fox"				y = x - "brown "				assert y == "the fox"    }        void testOperationsOnConstantString() {        assert "hello".size() == 5        assert "the quick brown".substring(4).substring(0,5) == "quick"    }}

⌨️ 快捷键说明

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