mappropertytest.groovy

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

GROOVY
35
字号
/**  * @author <a href="mailto:james@coredevelopers.net">James Strachan</a> * @version $Revision: 1.3 $ */class MapPropertyTest extends GroovyTestCase {    void testGetAndSetProperties() {        def m = [ 'name' : 'James', 'location' : 'London', 'id':1 ]                assert m.name == 'James'        assert m.location == 'London'        assert m.id == 1                m.name = 'Bob'        m.location = 'Atlanta'        m.id = 2                assert m.name == 'Bob'        assert m.location == 'Atlanta'        assert m.id == 2    }    void testSetupAndEmptyMap() {        def m = [:]                m.name = 'Bob'        m.location = 'Atlanta'        m.id = 2                assert m.name == 'Bob'        assert m.location == 'Atlanta'        assert m.id == 2    }}

⌨️ 快捷键说明

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