|
Groovy example source code file (MapPropertyTest.groovy)
The Groovy MapPropertyTest.groovy source codepackage groovy /** * @author <a href="mailto:james@coredevelopers.net">James Strachan * @version $Revision: 5137 $ */ 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 } void testMapSubclassing() { def c = new MyClass() c.id = "hello" c.class = 1 c.myMethod() assert c.id == "hello" assert c.class == 1 assert c.getClass() != 1 } } class MyClass extends HashMap { def myMethod() { assert id == "hello" assert this.class == 1 } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy MapPropertyTest.groovy source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.