大名鼎鼎的java动态脚本语言。已经通过了sun的认证

源代码在线查看: collectiontest.groovy

软件大小: 1630 K
上传用户: hjf
关键词: java sun 动态 脚本
下载地址: 免注册下载 普通下载 VIP

相关代码

				package groovy								class CollectionTest extends GroovyTestCase {								    void testUniqueOnListNoDupls() {				    	assert [].unique() == []				    	assert [1].unique() == [1]				    	assert [1,2].unique() == [1,2]				    	def a = [1,2]				    	assert a.is(a.unique())				    }								    void testUniqueOnListOneDupl() {				    	assert [1,1].unique() == [1]				    	def a = [1,1]				    	assert a.is(a.unique())				    	assert [1,2,1].unique() == [1,2]				    	assert [1,2,1,1].unique() == [1,2]				    	assert [1,1,2].unique() == [1,2]				    	assert [1,1,2,1].unique() == [1,2]				    	assert [1,1,2,1,1].unique() == [1,2]				    }								    void testUniqueOnListTwoDupls() {				    	assert [1,1,2,2].unique() == [1,2]				    	def a = [1,1,2,2]				    	assert a.is(a.unique())				    	assert [1,2,1,2].unique() == [1,2]				    	assert [1,2,1,1,2].unique() == [1,2]				    	assert [1,1,2,2].unique() == [1,2]				    	assert [1,1,2,1,2].unique() == [1,2]				    	assert [1,1,2,2,1,1,2,2].unique() == [1,2]				    }								    void testUniqueOnOtherCollections() {				    	def a = new HashSet([1,1])				    	assert a.is(a.unique())				    	assert 1 == a.size()				    	a = new TreeSet([1,1])				    	assert a.is(a.unique())				    	assert 1 == a.size()				    	a = new Vector([1,1])				    	assert a.is(a.unique())				    	assert 1 == a.size()				    	a = new LinkedList([1,1])				    	assert a.is(a.unique())				    	assert 1 == a.size()				    }								    // todo: GROOVY-1006				    void testUniqueOnDifferentTypes() {				    	def a = [1, 2, (short)1, 2L, 2.0]				    	def b = a.unique()				    	assert (b == a && a == [1, 2])				    	a = [Math.PI, "foo", 1.0, 2L, (short)2, 2.0F]				    	b = a.unique()				    	assert (b == a && a == [Math.PI, "foo", 1.0, 2L])				    }				}							

相关资源