SystemOrganization addCategory: #'Container-Tests-Core-Abstract'! SystemOrganization addCategory: #'Container-Tests-Core-Comparators'! SystemOrganization addCategory: #'Container-Tests-Core-Iterators'! SystemOrganization addCategory: #'Container-Tests-Core-Lists'! SystemOrganization addCategory: #'Container-Tests-Core-Sets'! SystemOrganization addCategory: #'Container-Tests-Core-Maps'! SystemOrganization addCategory: #'Container-Tests-Core-Misc'! !CTTreeMap methodsFor: '*container-tests-core' stamp: 'lr 1/25/2012 08:11'! assertInvariants: anAsserter super assertInvariants: anAsserter. tree assertInvariants: anAsserter! ! !CTFingerArray methodsFor: '*container-tests-core' stamp: 'lr 2/5/2012 14:53'! assertInvariants: anAsserter inner: aBoolean! ! !CTSubList methodsFor: '*container-tests-core' stamp: 'lr 2/11/2012 14:45'! assertInvariants: anAsserter super assertInvariants: anAsserter. list assertInvariants: anAsserter. self isEmpty ifFalse: [ list at: firstIndex ifAbsent: [ anAsserter fail ]. list at: lastIndex ifAbsent: [ anAsserter fail ] ]! ! !CTLinkedHashSet methodsFor: '*container-tests-core' stamp: 'lr 1/14/2012 10:36'! assertInvariants: anAsserter super assertInvariants: anAsserter. root assertInvariants: anAsserter. self assert: table size = root forwardIterator size. self assert: (self includesAll: self iterator)! ! !CTFingerNode methodsFor: '*container-tests-core' stamp: 'lr 2/5/2012 18:15'! assertInvariants: anAsserter inner: aBoolean super assertInvariants: anAsserter inner: aBoolean. anAsserter assert: aBoolean. anAsserter assert: (self size between: 2 and: 3). self iterator do: [ :each | (each isKindOf: self class) ifTrue: [ each assertInvariants: anAsserter inner: aBoolean ] ]! ! !CTMap methodsFor: '*container-tests-core' stamp: 'lr 1/14/2012 11:18'! assertInvariants: anAsserter "Asserts the internal state of this collection" anAsserter assert: self iterator size = self size description: 'Iterator and collection size are not equal'! ! !CTLinkedList methodsFor: '*container-tests-core' stamp: 'lr 1/13/2012 11:08'! assertInvariants: anAsserter super assertInvariants: anAsserter. root assertInvariants: anAsserter! ! !CTTreeSet methodsFor: '*container-tests-core' stamp: 'lr 1/25/2012 08:11'! assertInvariants: anAsserter super assertInvariants: anAsserter. tree assertInvariants: anAsserter! ! !CTFingerDigit methodsFor: '*container-tests-core' stamp: 'lr 2/5/2012 18:14'! assertInvariants: anAsserter inner: aBoolean super assertInvariants: anAsserter inner: aBoolean. anAsserter assert: (self size between: 1 and: 4). self iterator do: [ :each | aBoolean ifTrue: [ each assertInvariants: anAsserter inner: aBoolean ] ifFalse: [ anAsserter deny: (each isKindOf: CTFingerArray) ] ]! ! !CTHashTable methodsFor: '*container-tests-core' stamp: 'lr 1/24/2012 20:02'! assertInvariants: anAsserter self assert: self size = self iterator size. self assert: self size <= threshold! ! !CTLinkedListRoot methodsFor: '*container-tests-core' stamp: 'lr 1/13/2012 11:07'! assertInvariants: anAsserter self assertInvariants: anAsserter forNode: self. self forwardIterator do: [ :node | self assertInvariants: anAsserter forNode: node ]. self backwardIterator do: [ :node | self assertInvariants: anAsserter forNode: node ]! ! !CTLinkedListRoot methodsFor: '*container-tests-core' stamp: 'lr 1/13/2012 11:07'! assertInvariants: anAsserter forNode: aNode anAsserter assert: aNode before after == aNode. anAsserter assert: aNode after before == aNode! ! !CTSplayTree methodsFor: '*container-tests-core' stamp: 'lr 1/28/2012 13:45'! assertInvariants: anAsserter anAsserter assert: self forwardIterator size = size. root isNil ifFalse: [ root assertInvariants: anAsserter comparator: comparator ]! ! !CTVectorList methodsFor: '*container-tests-core' stamp: 'lr 1/21/2012 19:15'! assertInvariants: anAsserter super assertInvariants: anAsserter. size + 1 to: array size do: [ :index | anAsserter assert: (array at: index) isNil ]! ! !CTUnmodifiableList methodsFor: '*container-tests-core' stamp: 'lr 2/11/2012 14:45'! assertInvariants: anAsserter super assertInvariants: anAsserter. list assertInvariants: anAsserter! ! !CTArrayList methodsFor: '*container-tests-core' stamp: 'lr 1/13/2012 11:08'! assertInvariants: anAsserter super assertInvariants: anAsserter. 1 to: firstIndex - 1 do: [ :index | anAsserter assert: (array at: index) isNil ]. lastIndex + 1 to: array size do: [ :index | anAsserter assert: (array at: index) isNil ]! ! !CTHashMap methodsFor: '*container-tests-core' stamp: 'lr 1/14/2012 10:28'! assertInvariants: anAsserter super assertInvariants: anAsserter. table assertInvariants: anAsserter! ! !CTDeepFingerTree methodsFor: '*container-tests-core' stamp: 'lr 2/5/2012 15:21'! assertInvariants: anAsserter inner: aBoolean super assertInvariants: anAsserter inner: aBoolean. anAsserter assert: (prefix isKindOf: CTFingerDigit). prefix assertInvariants: anAsserter inner: aBoolean. anAsserter assert: (tree isKindOf: CTFingerTree). tree assertInvariants: anAsserter inner: true. anAsserter assert: (suffix isKindOf: CTFingerDigit). suffix assertInvariants: anAsserter inner: aBoolean! ! !CTList methodsFor: '*container-tests-core' stamp: 'lr 1/13/2012 11:35'! assertInvariants: anAsserter super assertInvariants: anAsserter. anAsserter assert: self forwardIterator size = self size description: 'Forward-iterator and collection size are not equal'. anAsserter assert: self backwardIterator size = self size description: 'Backward-iterator and collection size are not equal'! ! !CTCollection methodsFor: '*container-tests-core' stamp: 'lr 1/25/2012 08:04'! assertInvariants: anAsserter "Asserts the internal state of this collection" anAsserter assert: self iterator size = self size description: 'Iterator and collection size are not equal'! ! TestCase subclass: #CTContainerTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Abstract'! CTContainerTest subclass: #CTCollectionTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Abstract'! !CTCollectionTest class methodsFor: 'testing' stamp: 'lr 8/7/2011 19:59'! isAbstract ^ self name = #CTCollectionTest! ! !CTCollectionTest methodsFor: 'accessing' stamp: 'lr 11/5/2011 18:42'! collectionClass ^ CTCollection! ! !CTCollectionTest methodsFor: 'accessing' stamp: 'lr 1/10/2012 07:40'! collectionWithAll: aCollection ^ self collectionClass withAll: aCollection! ! !CTCollectionTest methodsFor: 'accessing' stamp: 'lr 2/6/2012 22:37'! collectionWithRandomElements: anInteger ^ self collectionWithAll: (self randomSequence: anInteger)! ! !CTCollectionTest methodsFor: 'accessing' stamp: 'lr 2/11/2012 11:35'! emptyCollection ^ self collectionWithAll: #()! ! !CTCollectionTest methodsFor: 'tests-copying' stamp: 'lr 2/11/2012 14:41'! testCopyEmpty | old new | old := self emptyCollection. new := old copy. self deny: old == new. self assertIterable: old equals: new. self assertInvariants: old. self assertInvariants: new. (old isKindOf: CTSubList) ifTrue: [ ^ self ]. old add: $a. new add: $b. self assert: old size = 1. self assert: new size = 1. self assert: old iterator next = $a. self assert: new iterator next = $b. self assert: (old iterator anySatisfy: [ :e | e = $a ]). self assert: (new iterator anySatisfy: [ :e | e = $b ]). self assert: (old iterator noneSatisfy: [ :e | e = $b ]). self assert: (new iterator noneSatisfy: [ :e | e = $a ])! ! !CTCollectionTest methodsFor: 'tests-copying' stamp: 'lr 2/11/2012 14:41'! testCopyMany | old new | old := self collectionWithRandomElements: 100. new := old copy. self deny: old == new. self assertIterable: old equals: new. self assertInvariants: old. self assertInvariants: new. (old isKindOf: CTSubList) ifTrue: [ ^ self ]. old add: 101. new add: 102. self assert: old size = 101. self assert: new size = 101. self assert: (old iterator anySatisfy: [ :e | e = 101 ]). self assert: (new iterator anySatisfy: [ :e | e = 102 ]). self assert: (old iterator noneSatisfy: [ :e | e = 102 ]). self assert: (new iterator noneSatisfy: [ :e | e = 101 ])! ! !CTCollectionTest methodsFor: 'tests-exceptions' stamp: 'lr 1/27/2012 22:06'! testElementNotFound [ self emptyCollection remove: $a ] on: CTElementNotFoundError do: [ :exception | self assert: exception element = $a. ^ self ]. self fail! ! !CTCollectionTest methodsFor: 'tests-testing' stamp: 'lr 1/10/2012 07:42'! testIsEmpty self assert: (self collectionWithAll: #()) isEmpty. self deny: (self collectionWithAll: #($a)) isEmpty. self deny: (self collectionWithAll: #($a $b)) isEmpty! ! !CTCollectionTest methodsFor: 'tests-iterators' stamp: 'lr 1/27/2012 22:03'! testIteratorCopy | old new | old := self collectionWithRandomElements: 100. new := old iterator as: self collectionClass. self deny: old == new. self assertIterable: old equals: new. self assertInvariants: old. self assertInvariants: new! ! !CTCollectionTest methodsFor: 'tests-iterators' stamp: 'lr 1/13/2012 11:42'! testIteratorEmpty | collection | collection := self collectionWithAll: #(). self assertIterable: #() equals: collection iterator! ! !CTCollectionTest methodsFor: 'tests-iterators' stamp: 'lr 1/13/2012 11:44'! testIteratorMultiple | collection | collection := self collectionWithAll: #($a $b $c). self assert: collection iterator size = 3. self assert: (collection iterator includes: $a). self assert: (collection iterator includes: $b). self assert: (collection iterator includes: $c)! ! !CTCollectionTest methodsFor: 'tests-iterators' stamp: 'lr 1/13/2012 11:42'! testIteratorSingle | collection | collection := self collectionWithAll: #($a). self assertIterable: #($a) equals: collection iterator! ! !CTCollectionTest methodsFor: 'tests-instantiation' stamp: 'lr 1/26/2012 10:32'! testNew1 | collection | collection := self collectionClass new. self assertInvariants: collection. self assert: collection isEmpty! ! !CTCollectionTest methodsFor: 'tests-instantiation' stamp: 'lr 1/26/2012 10:32'! testNew2 | collection | collection := self collectionClass new: 100. self assertInvariants: collection. self assert: collection isEmpty! ! !CTCollectionTest methodsFor: 'tests' stamp: 'lr 1/28/2012 16:37'! testPrinting | collection | collection := self emptyCollection. self assert: collection printString isString. collection := self collectionWithAll: #($a $b $c). self assert: collection printString isString! ! !CTCollectionTest methodsFor: 'tests-removing' stamp: 'lr 1/14/2012 00:21'! testRemove | collection | collection := self collectionWithAll: #($a $b $c $d $e). self should: [ collection remove: $y ] raise: CTElementNotFoundError. self assert: (collection remove: $a) = $a. self assert: (collection remove: $c) = $c. self assert: (collection remove: $e) = $e. self assert: collection size = 2. self assert: (collection iterator includes: $b). self assert: (collection iterator includes: $d). self assertInvariants: collection! ! !CTCollectionTest methodsFor: 'tests-removing' stamp: 'lr 1/11/2012 22:47'! testRemoveAll | collection | collection := self collectionWithRandomElements: 100. collection removeAll. self assert: collection isEmpty. self assertInvariants: collection! ! !CTCollectionTest methodsFor: 'tests-removing' stamp: 'lr 1/14/2012 00:21'! testRemoveIfAbsent | collection | collection := self collectionWithAll: #($a $b $c $d $e). self assert: (collection remove: $y ifAbsent: [ $x ]) = $x. self assert: (collection remove: $a ifAbsent: [ $x ]) = $a. self assert: (collection remove: $c ifAbsent: [ $x ]) = $c. self assert: (collection remove: $e ifAbsent: [ $x ]) = $e. self assert: collection size = 2. self assert: (collection iterator includes: $b). self assert: (collection iterator includes: $d). self assertInvariants: collection! ! !CTCollectionTest methodsFor: 'tests-accessing' stamp: 'lr 1/10/2012 07:41'! testSize self assert: (self collectionWithAll: #()) size = 0. self assert: (self collectionWithAll: #($a)) size = 1. self assert: (self collectionWithAll: #($a $b)) size = 2! ! !CTCollectionTest methodsFor: 'tests-instantiation' stamp: 'lr 1/26/2012 10:32'! testWith1 | collection | collection := self collectionClass with: $a. self assertInvariants: collection. self assert: (collection iterator includes: $a). self assert: (collection size) = 1! ! !CTCollectionTest methodsFor: 'tests-instantiation' stamp: 'lr 1/26/2012 10:32'! testWith2 | collection | collection := self collectionClass with: $a with: $b. self assertInvariants: collection. self assert: (collection iterator includes: $a). self assert: (collection iterator includes: $b). self assert: (collection size) = 2! ! !CTCollectionTest methodsFor: 'tests-instantiation' stamp: 'lr 1/26/2012 10:32'! testWith3 | collection | collection := self collectionClass with: $a with: $b with: $c. self assertInvariants: collection. self assert: (collection iterator includes: $a). self assert: (collection iterator includes: $b). self assert: (collection iterator includes: $c). self assert: (collection size) = 3! ! !CTCollectionTest methodsFor: 'tests-instantiation' stamp: 'lr 1/26/2012 10:32'! testWith4 | collection | collection := self collectionClass with: $a with: $b with: $c with: $d. self assertInvariants: collection. self assert: (collection iterator includes: $a). self assert: (collection iterator includes: $b). self assert: (collection iterator includes: $c). self assert: (collection iterator includes: $d). self assert: (collection size) = 4! ! !CTCollectionTest methodsFor: 'tests-instantiation' stamp: 'lr 1/25/2012 22:53'! testWithAll | old new | old := self collectionWithRandomElements: 100. new := self collectionClass withAll: old. self deny: old == new. self assertIterable: old equals: new. self assertInvariants: old. self assertInvariants: new. old add: 101. new add: 102. self assert: old size = 101. self assert: new size = 101. self assert: (old iterator anySatisfy: [ :e | e = 101 ]). self assert: (new iterator anySatisfy: [ :e | e = 102 ]). self assert: (old iterator noneSatisfy: [ :e | e = 102 ]). self assert: (new iterator noneSatisfy: [ :e | e = 101 ])! ! !CTCollectionTest methodsFor: 'tests' stamp: 'lr 1/28/2012 16:39'! testWorkflow | collection | collection := self collectionClass new. self assertInvariants: collection. self assert: collection isEmpty. collection addAll: (self randomSequence: self workflowSize). self assertInvariants: collection. self assert: collection size = self workflowSize. 1 to: self workflowSize do: [ :each | self assert: (collection includes: each) ]. (collection isKindOf: CTSet) ifTrue: [ collection addAll: (self randomSequence: self workflowSize). self assertInvariants: collection. self assert: collection size = self workflowSize. 1 to: self workflowSize do: [ :each | self assert: (collection includes: each) ] ]. (self randomSequence: self workflowSize) do: [ :each | collection remove: each ]. self assertInvariants: collection. self assert: collection isEmpty! ! !CTCollectionTest methodsFor: 'tests' stamp: 'lr 1/28/2012 16:42'! workflowSize ^ 1000! ! CTCollectionTest subclass: #CTListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Abstract'! CTListTest subclass: #CTArrayListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! !CTArrayListTest methodsFor: 'accessing' stamp: 'lr 1/20/2012 22:16'! collectionClass ^ CTArrayList! ! !CTArrayListTest methodsFor: 'tests-iterators' stamp: 'lr 2/11/2012 14:39'! testBackwardIndexedIterator | collection | collection := self collectionWithAll: #($a $b $c). collection backwardIterator do: [ :key :value | self assert: (collection at: key) = value ]! ! !CTArrayListTest methodsFor: 'tests-iterators' stamp: 'lr 2/11/2012 14:39'! testForwardIndexedIterator | collection | collection := self collectionWithAll: #($a $b $c). collection forwardIterator do: [ :key :value | self assert: (collection at: key) = value ]! ! CTListTest subclass: #CTImmutableListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! !CTImmutableListTest class methodsFor: 'testing' stamp: 'lr 2/6/2012 20:45'! shouldInheritSelectors ^ false! ! !CTImmutableListTest methodsFor: 'accessing' stamp: 'lr 2/6/2012 20:47'! collectionClass ^ CTImmutableList! ! !CTImmutableListTest methodsFor: 'tests-adding' stamp: 'lr 2/6/2012 20:50'! testAdd self should: [ super testAdd ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-adding' stamp: 'lr 2/6/2012 20:50'! testAddAt self should: [ super testAddAt ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-adding' stamp: 'lr 2/6/2012 20:50'! testAddFirst self should: [ super testAddFirst ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-adding' stamp: 'lr 2/6/2012 20:50'! testAddLast self should: [ super testAddLast ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 20:46'! testAt super testAt! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 20:46'! testAtIfAbsent super testAtIfAbsent! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 20:49'! testAtPut self should: [ super testAtPut ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-iterators' stamp: 'lr 2/6/2012 22:33'! testBackwardIterator super testBackwardIterator! ! !CTImmutableListTest methodsFor: 'tests-iterators' stamp: 'lr 2/6/2012 22:33'! testBackwardIteratorEmpty super testBackwardIteratorEmpty! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 20:46'! testFirst super testFirst! ! !CTImmutableListTest methodsFor: 'tests-iterators' stamp: 'lr 2/6/2012 22:33'! testForwardIterator super testForwardIterator! ! !CTImmutableListTest methodsFor: 'tests-iterators' stamp: 'lr 2/6/2012 22:33'! testForwardIteratorEmpty super testForwardIteratorEmpty! ! !CTImmutableListTest methodsFor: 'tests-copying' stamp: 'lr 2/6/2012 23:18'! testImmutable | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable immutable == immutable! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 20:46'! testLast super testLast! ! !CTImmutableListTest methodsFor: 'tests-instantiation' stamp: 'lr 2/6/2012 22:41'! testNew1 super testNew1! ! !CTImmutableListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:36'! testRemove self should: [ super testRemove ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:36'! testRemoveAll self should: [ super testRemoveAll ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:36'! testRemoveAt self should: [ super testRemoveAt ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:36'! testRemoveAtIfAbsent self should: [ super testRemoveAtIfAbsent ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:36'! testRemoveFirst self should: [ super testRemoveFirst ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:36'! testRemoveIfAbsent self should: [ super testRemoveIfAbsent ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:36'! testRemoveLast self should: [ super testRemoveLast ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 22:38'! testSize super testSize! ! !CTImmutableListTest methodsFor: 'tests-copying' stamp: 'lr 2/6/2012 23:18'! testUnmodifiable | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable unmodifiable == immutable! ! !CTImmutableListTest methodsFor: 'tests-instantiation' stamp: 'lr 2/6/2012 22:41'! testWith1 super testWith1! ! !CTImmutableListTest methodsFor: 'tests-instantiation' stamp: 'lr 2/6/2012 22:41'! testWith2 super testWith2! ! !CTImmutableListTest methodsFor: 'tests-instantiation' stamp: 'lr 2/6/2012 22:41'! testWith3 super testWith3! ! !CTImmutableListTest methodsFor: 'tests-instantiation' stamp: 'lr 2/6/2012 22:41'! testWith4 super testWith4! ! CTListTest subclass: #CTLinkedListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! !CTLinkedListTest methodsFor: 'accessing' stamp: 'lr 8/7/2011 19:21'! collectionClass ^ CTLinkedList! ! !CTListTest class methodsFor: 'testing' stamp: 'lr 8/7/2011 19:59'! isAbstract ^ self name = #CTListTest! ! !CTListTest methodsFor: 'accessing' stamp: 'lr 11/5/2011 18:42'! collectionClass ^ CTList! ! !CTListTest methodsFor: 'tests-adding' stamp: 'lr 1/11/2012 22:48'! testAdd | collection | collection := self emptyCollection. self assert: (collection add: $a) = $a. self assertIterable: collection equals: #($a). self assert: (collection add: $b) = $b. self assertIterable: collection equals: #($a $b). self assert: (collection add: $c) = $c. self assertIterable: collection equals: #($a $b $c). self assertInvariants: collection ! ! !CTListTest methodsFor: 'tests-adding' stamp: 'lr 1/11/2012 22:48'! testAddAt | collection | collection := self emptyCollection. self should: [ collection add: $a at: 0 ] raise: CTIndexOutOfBoundsError. self should: [ collection add: $a at: 2 ] raise: CTIndexOutOfBoundsError. self assert: (collection add: $a at: 1) = $a. self assertIterable: collection equals: #($a). self assert: (collection add: $b at: 2) = $b. self assertIterable: collection equals: #($a $b). self assert: (collection add: $c at: 2) = $c. self assertIterable: collection equals: #($a $c $b). self assert: (collection add: $d at: 1) = $d. self assertIterable: collection equals: #($d $a $c $b). self assert: (collection add: $e at: 4) = $e. self assertIterable: collection equals: #($d $a $c $e $b). self should: [ collection add: $a at: 0 ] raise: CTIndexOutOfBoundsError. self should: [ collection add: $a at: 7 ] raise: CTIndexOutOfBoundsError. self assertInvariants: collection! ! !CTListTest methodsFor: 'tests-adding' stamp: 'lr 1/11/2012 22:48'! testAddFirst | collection | collection := self emptyCollection. self assert: (collection addFirst: $a) = $a. self assertIterable: collection equals: #($a). self assert: (collection addFirst: $b) = $b. self assertIterable: collection equals: #($b $a). self assert: (collection addFirst: $c) = $c. self assertIterable: collection equals: #($c $b $a). self assertInvariants: collection ! ! !CTListTest methodsFor: 'tests-operations' stamp: 'lr 1/11/2012 22:48'! testAddFirstRemoveLast | collection | collection := self emptyCollection. 0001 to: 1000 do: [ :index | self assert: (collection addFirst: index) = index ]. self assertInvariants: collection. 1001 to: 2000 do: [ :index | self assert: (collection addFirst: index) = index. self assert: collection removeLast = (index - 1000) ]. self assertInvariants: collection. 2001 to: 3000 do: [ :index | self assert: collection removeLast = (index - 1000) ]. self assertInvariants: collection. self assert: collection isEmpty! ! !CTListTest methodsFor: 'tests-adding' stamp: 'lr 1/11/2012 22:48'! testAddLast | collection | collection := self emptyCollection. self assert: (collection addLast: $a) = $a. self assertIterable: collection equals: #($a). self assert: (collection addLast: $b) = $b. self assertIterable: collection equals: #($a $b). self assert: (collection addLast: $c) = $c. self assertIterable: collection equals: #($a $b $c). self assertInvariants: collection ! ! !CTListTest methodsFor: 'tests-operations' stamp: 'lr 1/11/2012 22:48'! testAddLastRemoveFirst | collection | collection := self emptyCollection. 0001 to: 1000 do: [ :index | self assert: (collection addLast: index) = index ]. self assertInvariants: collection. 1001 to: 2000 do: [ :index | self assert: (collection addLast: index) = index. self assert: collection removeFirst = (index - 1000) ]. self assertInvariants: collection. 2001 to: 3000 do: [ :index | self assert: collection removeFirst = (index - 1000) ]. self assertInvariants: collection. self assert: collection isEmpty! ! !CTListTest methodsFor: 'tests-accessing' stamp: 'lr 1/10/2012 22:20'! testAt | collection | collection := self collectionWithAll: #($a $b $c). self should: [ collection at: 0 ] raise: CTIndexOutOfBoundsError. self assert: (collection at: 1) = $a. self assert: (collection at: 2) = $b. self assert: (collection at: 3) = $c. self should: [ collection at: 4 ] raise: CTIndexOutOfBoundsError! ! !CTListTest methodsFor: 'tests-accessing' stamp: 'lr 1/10/2012 07:47'! testAtIfAbsent | collection | collection := self collectionWithAll: #($a $b $c). self assert: (collection at: 0 ifAbsent: [ $x ]) = $x. self assert: (collection at: 1 ifAbsent: [ $x ]) = $a. self assert: (collection at: 2 ifAbsent: [ $x ]) = $b. self assert: (collection at: 3 ifAbsent: [ $x ]) = $c. self assert: (collection at: 4 ifAbsent: [ $x ]) = $x! ! !CTListTest methodsFor: 'tests-accessing' stamp: 'lr 1/11/2012 22:47'! testAtPut | collection | collection := self collectionWithAll: #($a $b $c). self should: [ collection at: 0 put: $x ] raise: CTIndexOutOfBoundsError. self assert: (collection at: 1 put: $x) = $x. self assert: (collection at: 2 put: $x) = $x. self assert: (collection at: 3 put: $x) = $x. self should: [ collection at: 4 put: $x ] raise: CTIndexOutOfBoundsError. self assertInvariants: collection! ! !CTListTest methodsFor: 'tests-iterators' stamp: 'lr 1/13/2012 11:40'! testBackwardIterator | collection | collection := self collectionWithAll: #($a $b $c). self assertIterable: #($c $b $a) equals: collection backwardIterator! ! !CTListTest methodsFor: 'tests-iterators' stamp: 'lr 1/13/2012 11:41'! testBackwardIteratorEmpty | collection | collection := self collectionWithAll: #(). self assertIterable: #() equals: collection backwardIterator! ! !CTListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 20:48'! testFirst | collection | collection := self emptyCollection. self should: [ self emptyCollection first ] raise: CTNoSuchElementError. collection := self collectionWithAll: #($a). self assert: collection first = $a. collection := self collectionWithAll: #($b $a). self assert: collection first = $b! ! !CTListTest methodsFor: 'tests-iterators' stamp: 'lr 1/13/2012 11:40'! testForwardIterator | collection | collection := self collectionWithAll: #($a $b $c). self assertIterable: #($c $b $a) equals: collection backwardIterator! ! !CTListTest methodsFor: 'tests-iterators' stamp: 'lr 1/13/2012 11:41'! testForwardIteratorEmpty | collection | collection := self collectionWithAll: #(). self assertIterable: #() equals: collection forwardIterator! ! !CTListTest methodsFor: 'tests-copying' stamp: 'lr 2/6/2012 23:13'! testImmutable | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assertIterable: immutable equals: #($a $b $c). collection at: 2 put: $x. self assertIterable: immutable equals: #($a $b $c). collection addLast: $y. self assertIterable: immutable equals: #($a $b $c)! ! !CTListTest methodsFor: 'tests-exceptions' stamp: 'lr 1/27/2012 22:06'! testIndexOutOfBounds [ self emptyCollection at: 1 ] on: CTIndexOutOfBoundsError do: [ :exception | self assert: exception index = 1. ^ self ]. self fail! ! !CTListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 20:48'! testLast | collection | collection := self emptyCollection. self should: [ self emptyCollection last ] raise: CTNoSuchElementError. collection := self collectionWithAll: #($a). self assert: collection last = $a. collection := self collectionWithAll: #($a $b). self assert: collection last = $b! ! !CTListTest methodsFor: 'tests-removing' stamp: 'lr 1/10/2012 23:27'! testRemoveAt | collection | collection := self collectionWithAll: #($a $b $c $d $e). self should: [ collection removeAt: 0 ] raise: CTIndexOutOfBoundsError. self should: [ collection removeAt: 6 ] raise: CTIndexOutOfBoundsError. self assert: (collection removeAt: 1) = $a. self assert: (collection removeAt: 4) = $e. self assert: (collection removeAt: 2) = $c. self assertIterable: collection equals: #($b $d)! ! !CTListTest methodsFor: 'tests-removing' stamp: 'lr 1/10/2012 23:28'! testRemoveAtIfAbsent | collection | collection := self collectionWithAll: #($a $b $c $d $e). self assert: (collection removeAt: 0 ifAbsent: [ $x ]) = $x. self assert: (collection removeAt: 6 ifAbsent: [ $x ]) = $x. self assert: (collection removeAt: 1 ifAbsent: [ $x ]) = $a. self assert: (collection removeAt: 4 ifAbsent: [ $x ]) = $e. self assert: (collection removeAt: 2 ifAbsent: [ $x ]) = $c. self assertIterable: collection equals: #($b $d)! ! !CTListTest methodsFor: 'tests-removing' stamp: 'lr 1/10/2012 23:32'! testRemoveFirst | letters collection | letters := #($a $b $c $d $e). collection := self collectionWithAll: letters. letters iterator do: [ :each | self assert: collection removeFirst = each ]. self should: [ collection removeFirst ] raise: CTNoSuchElementError. self assertIterable: collection equals: #()! ! !CTListTest methodsFor: 'tests-removing' stamp: 'lr 1/13/2012 11:34'! testRemoveLast | letters collection | letters := #($a $b $c $d $e). collection := self collectionWithAll: letters. letters backwardIterator do: [ :each | self assert: collection removeLast = each ]. self should: [ collection removeFirst ] raise: CTNoSuchElementError. self assertIterable: collection equals: #()! ! !CTListTest methodsFor: 'tests-sorting' stamp: 'lr 1/23/2012 19:24'! testSortDefault | list | list := self collectionWithAll: #(2 8 6 7 3 9 4 5 1). list sort. self assertIterable: list equals: #(1 2 3 4 5 6 7 8 9)! ! !CTListTest methodsFor: 'tests-sorting' stamp: 'lr 2/6/2012 20:52'! testSortEmpty self emptyCollection sort! ! !CTListTest methodsFor: 'tests-sorting' stamp: 'lr 1/24/2012 19:15'! testSortOrder | list | list := self collectionWithAll: #(2 8 6 7 3 9 4 5 1). list sort: CTNaturalComparator new reverse. self assertIterable: list equals: #(9 8 7 6 5 4 3 2 1)! ! !CTListTest methodsFor: 'tests-sorting' stamp: 'lr 1/24/2012 19:15'! testSortRange | list | list := self collectionWithAll: #(2 8 6 7 3 9 4 5 1). list sort: CTNaturalComparator new from: 4 to: 6. self assertIterable: list equals: #(2 8 6 3 7 9 4 5 1)! ! !CTListTest methodsFor: 'tests-copying' stamp: 'lr 2/6/2012 23:16'! testUnmodifiable | collection unmodifiable | collection := self collectionWithAll: #($a $b $c). unmodifiable := collection unmodifiable. self assertIterable: unmodifiable equals: #($a $b $c). collection at: 2 put: $x. self assertIterable: unmodifiable equals: #($a $x $c). collection addLast: $y. self assertIterable: unmodifiable equals: #($a $x $c $y)! ! CTListTest subclass: #CTSubListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! CTSubListTest subclass: #CTArraySubListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! !CTArraySubListTest methodsFor: 'accessing' stamp: 'lr 2/11/2012 12:13'! collectionClass ^ CTArrayList! ! CTSubListTest subclass: #CTLinkedSubListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! !CTLinkedSubListTest methodsFor: 'accessing' stamp: 'lr 2/11/2012 12:13'! collectionClass ^ CTLinkedList! ! !CTSubListTest class methodsFor: 'testing' stamp: 'lr 2/11/2012 11:32'! isAbstract ^ self name = #CTSubListTest! ! !CTSubListTest methodsFor: 'accessing' stamp: 'lr 2/11/2012 11:35'! collectionWithAll: aCollection ^ self collectionWithAll: aCollection from: 1 to: aCollection size! ! !CTSubListTest methodsFor: 'accessing' stamp: 'lr 2/11/2012 12:14'! collectionWithAll: aCollection from: aStartIndex to: aStopIndex ^ (self collectionClass withAll: aCollection) from: aStartIndex to: aStopIndex! ! !CTSubListTest methodsFor: 'tests-adding' stamp: 'lr 2/11/2012 14:28'! testSubAddAt | collection sub | collection := self collectionWithAll: #($a $b $c $d $e). sub := collection from: 2 to: 4. self should: [ sub add: $x at: 0 ] raise: CTIndexOutOfBoundsError. self assertIterable: sub equals: #($b $c $d). self assertIterable: collection equals: #($a $b $c $d $e). self should: [ sub add: $x at: 5 ] raise: CTIndexOutOfBoundsError. self assertIterable: sub equals: #($b $c $d). self assertIterable: collection equals: #($a $b $c $d $e). self assert: (sub add: $x at: 1) = $x. self assertIterable: sub equals: #($x $b $c $d). self assertIterable: collection equals: #($a $x $b $c $d $e). self assert: (sub add: $y at: 3) = $y. self assertIterable: sub equals: #($x $b $y $c $d). self assertIterable: collection equals: #($a $x $b $y $c $d $e). self assert: (sub add: $z at: 6) = $z. self assertIterable: sub equals: #($x $b $y $c $d $z). self assertIterable: collection equals: #($a $x $b $y $c $d $z $e)! ! !CTSubListTest methodsFor: 'tests-adding' stamp: 'lr 2/11/2012 14:28'! testSubAddFirst | collection sub | collection := self collectionWithAll: #($a $b $c $d $e). sub := collection from: 2 to: 4. self assert: (sub addFirst: $x) = $x. self assertIterable: sub equals: #($x $b $c $d). self assertIterable: collection equals: #($a $x $b $c $d $e)! ! !CTSubListTest methodsFor: 'tests-adding' stamp: 'lr 2/11/2012 14:28'! testSubAddLast | collection sub | collection := self collectionWithAll: #($a $b $c $d $e). sub := collection from: 2 to: 4. self assert: (sub addLast: $x) = $x. self assertIterable: sub equals: #($b $c $d $x ). self assertIterable: collection equals: #($a $b $c $d $x $e)! ! !CTSubListTest methodsFor: 'tests-accessing' stamp: 'lr 2/11/2012 14:18'! testSubAt | collection sub | collection := self collectionWithAll: #($a $b $c $d $e). sub := collection from: 2 to: 4. self should: [ sub at: 0 ] raise: CTIndexOutOfBoundsError. self assert: (sub at: 1) = $b. self assert: (sub at: 2) = $c. self assert: (sub at: 3) = $d. self should: [ sub at: 4 ] raise: CTIndexOutOfBoundsError ! ! !CTSubListTest methodsFor: 'tests-accessing' stamp: 'lr 2/11/2012 14:19'! testSubAtIfAbsent | collection sub | collection := self collectionWithAll: #($a $b $c $d $e). sub := collection from: 2 to: 4. self assert: (sub at: 0 ifAbsent: [ $x ]) = $x. self assert: (sub at: 1 ifAbsent: [ $x ]) = $b. self assert: (sub at: 2 ifAbsent: [ $x ]) = $c. self assert: (sub at: 3 ifAbsent: [ $x ]) = $d. self assert: (sub at: 4 ifAbsent: [ $x ]) = $x! ! !CTSubListTest methodsFor: 'tests-accessing' stamp: 'lr 2/11/2012 14:22'! testSubAtPut | collection sub | collection := self collectionWithAll: #($a $b $c $d $e). sub := collection from: 2 to: 4. self should: [ sub at: 0 put: $x ] raise: CTIndexOutOfBoundsError. self assertIterable: sub equals: #($b $c $d). self assertIterable: collection equals: #($a $b $c $d $e). self assert: (sub at: 1 put: $x) = $x. self assertIterable: sub equals: #($x $c $d). self assertIterable: collection equals: #($a $x $c $d $e). self assert: (sub at: 2 put: $x) = $x. self assertIterable: sub equals: #($x $x $d). self assertIterable: collection equals: #($a $x $x $d $e). self assert: (sub at: 3 put: $x) = $x. self assertIterable: sub equals: #($x $x $x). self assertIterable: collection equals: #($a $x $x $x $e). self should: [ sub at: 4 put: $x ] raise: CTIndexOutOfBoundsError. self assertIterable: sub equals: #($x $x $x). self assertIterable: collection equals: #($a $x $x $x $e)! ! !CTSubListTest methodsFor: 'tests-accessing' stamp: 'lr 2/11/2012 14:16'! testSubFirst | collection sub | collection := self collectionWithAll: #($a $b $c $d $e). sub := collection from: 2 to: 4. self assert: sub first = $b! ! !CTSubListTest methodsFor: 'tests-accessing' stamp: 'lr 2/11/2012 14:16'! testSubLast | collection sub | collection := self collectionWithAll: #($a $b $c $d $e). sub := collection from: 2 to: 4. self assert: sub last = $d! ! !CTSubListTest methodsFor: 'tests-instantiation' stamp: 'lr 2/11/2012 14:30'! testSubNew self should: [ self emptyCollection class new ] raise: CTUnsupportedOperationError. self should: [ self emptyCollection class new: 10 ] raise: CTUnsupportedOperationError! ! !CTSubListTest methodsFor: 'tests-removing' stamp: 'lr 2/11/2012 14:28'! testSubRemoveAll | collection sub | collection := self collectionWithAll: #($a $b $c $d $e). sub := collection from: 2 to: 4. self assert: sub removeAll = sub. self assertIterable: collection equals: #($a $e). self assertIterable: sub equals: #(). self assert: sub removeAll = sub. self assertIterable: collection equals: #($a $e). self assertIterable: sub equals: #()! ! !CTSubListTest methodsFor: 'tests-removing' stamp: 'lr 2/11/2012 14:28'! testSubRemoveAt | collection sub | collection := self collectionWithAll: #($a $b $c $d $e). sub := collection from: 2 to: 4. self assert: (sub removeAt: 2) = $c. self assertIterable: collection equals: #($a $b $d $e). self assertIterable: sub equals: #($b $d). ! ! !CTSubListTest methodsFor: 'tests-removing' stamp: 'lr 2/11/2012 14:28'! testSubRemoveFirst | collection sub | collection := self collectionWithAll: #($a $b $c $d $e). sub := collection from: 2 to: 4. self assert: sub removeFirst = $b. self assertIterable: collection equals: #($a $c $d $e). self assertIterable: sub equals: #($c $d) ! ! !CTSubListTest methodsFor: 'tests-removing' stamp: 'lr 2/11/2012 14:28'! testSubRemoveLast | collection sub | collection := self collectionWithAll: #($a $b $c $d $e). sub := collection from: 2 to: 4. self assert: sub removeLast = $d. self assertIterable: collection equals: #($a $b $c $e). self assertIterable: sub equals: #($b $c) ! ! !CTSubListTest methodsFor: 'tests-instantiation' stamp: 'lr 2/11/2012 14:31'! testSubWith self should: [ self emptyCollection class with: $a ] raise: CTUnsupportedOperationError. self should: [ self emptyCollection class with: $a with: $b ] raise: CTUnsupportedOperationError. self should: [ self emptyCollection class with: $a with: $b with: $c ] raise: CTUnsupportedOperationError. self should: [ self emptyCollection class with: $a with: $b with: $c with: $d ] raise: CTUnsupportedOperationError. self should: [ self emptyCollection class withAll: #() ] raise: CTUnsupportedOperationError! ! CTSubListTest subclass: #CTVectorSubListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! !CTVectorSubListTest methodsFor: 'accessing' stamp: 'lr 2/11/2012 12:14'! collectionClass ^ CTVectorList! ! CTListTest subclass: #CTUnmodifiableListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! !CTUnmodifiableListTest class methodsFor: 'testing' stamp: 'lr 2/6/2012 20:45'! shouldInheritSelectors ^ false! ! !CTUnmodifiableListTest methodsFor: 'accessing' stamp: 'lr 2/6/2012 23:22'! collectionClass ^ CTUnmodifiableList! ! !CTUnmodifiableListTest methodsFor: 'accessing' stamp: 'lr 2/6/2012 20:56'! collectionWithAll: aCollection ^ (CTArrayList withAll: aCollection) unmodifiable! ! !CTUnmodifiableListTest methodsFor: 'accessing' stamp: 'lr 2/6/2012 20:57'! emptyCollection ^ CTArrayList new unmodifiable! ! !CTUnmodifiableListTest methodsFor: 'tests-adding' stamp: 'lr 2/6/2012 22:39'! testAdd self should: [ super testAdd ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-adding' stamp: 'lr 2/6/2012 22:39'! testAddAt self should: [ super testAddAt ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-adding' stamp: 'lr 2/6/2012 22:39'! testAddFirst self should: [ super testAddFirst ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-adding' stamp: 'lr 2/6/2012 22:39'! testAddLast self should: [ super testAddLast ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 22:39'! testAt super testAt! ! !CTUnmodifiableListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 22:39'! testAtIfAbsent super testAtIfAbsent! ! !CTUnmodifiableListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 22:39'! testAtPut self should: [ super testAtPut ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-iterators' stamp: 'lr 2/6/2012 22:39'! testBackwardIterator super testBackwardIterator! ! !CTUnmodifiableListTest methodsFor: 'tests-iterators' stamp: 'lr 2/6/2012 22:39'! testBackwardIteratorEmpty super testBackwardIteratorEmpty! ! !CTUnmodifiableListTest methodsFor: 'tests-copying' stamp: 'lr 2/11/2012 13:13'! testCopy | collection unmodifiable | collection := self collectionWithAll: #($a $b $c). unmodifiable := collection unmodifiable. self assert: unmodifiable copy == unmodifiable! ! !CTUnmodifiableListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 22:39'! testFirst super testFirst! ! !CTUnmodifiableListTest methodsFor: 'tests-iterators' stamp: 'lr 2/6/2012 22:39'! testForwardIterator super testForwardIterator! ! !CTUnmodifiableListTest methodsFor: 'tests-iterators' stamp: 'lr 2/6/2012 22:39'! testForwardIteratorEmpty super testForwardIteratorEmpty! ! !CTUnmodifiableListTest methodsFor: 'tests-copying' stamp: 'lr 2/6/2012 23:23'! testImmutable | collection unmodifiable immutable | collection := CTArrayList withAll: #($a $b $c). unmodifiable := collection unmodifiable. immutable := unmodifiable immutable. collection at: 2 put: $x. self assertIterable: immutable equals: #($a $b $c)! ! !CTUnmodifiableListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 22:39'! testLast super testLast! ! !CTUnmodifiableListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:39'! testRemove self should: [ super testRemove ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:39'! testRemoveAll self should: [ super testRemoveAll ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:39'! testRemoveAt self should: [ super testRemoveAt ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:39'! testRemoveAtIfAbsent self should: [ super testRemoveAtIfAbsent ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:39'! testRemoveFirst self should: [ super testRemoveFirst ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:39'! testRemoveIfAbsent self should: [ super testRemoveIfAbsent ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:39'! testRemoveLast self should: [ super testRemoveLast ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 22:39'! testSize super testSize! ! !CTUnmodifiableListTest methodsFor: 'tests-copying' stamp: 'lr 2/6/2012 23:22'! testUnmodifiable | collection unmodifiable | collection := self collectionWithAll: #($a $b $c). unmodifiable := collection unmodifiable. self assert: unmodifiable unmodifiable == unmodifiable! ! CTListTest subclass: #CTVectorListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! !CTVectorListTest methodsFor: 'accessing' stamp: 'lr 1/21/2012 19:28'! collectionClass ^ CTVectorList! ! CTCollectionTest subclass: #CTPriorityQueueTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Misc'! !CTPriorityQueueTest methodsFor: 'accessing' stamp: 'lr 1/26/2012 18:52'! collectionClass ^ CTPriorityQueue! ! !CTPriorityQueueTest methodsFor: 'tests' stamp: 'lr 1/28/2012 13:19'! testPriority | queue | queue := self collectionWithRandomElements: 100. 1 to: 100 do: [ :index | self assert: queue removeFirst = index. self assert: queue size = (100 - index). self assertInvariants: queue ]. self assert: queue isEmpty! ! CTCollectionTest subclass: #CTSetTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Abstract'! CTSetTest subclass: #CTHashSetTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Sets'! !CTHashSetTest methodsFor: 'accessing' stamp: 'lr 1/13/2012 22:47'! collectionClass ^ CTHashSet! ! CTHashSetTest subclass: #CTLinkedHashSetTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Sets'! !CTLinkedHashSetTest methodsFor: 'accessing' stamp: 'lr 1/13/2012 22:47'! collectionClass ^ CTLinkedHashSet! ! !CTLinkedHashSetTest methodsFor: 'testing' stamp: 'lr 1/14/2012 13:33'! testAddInOrder | collection | collection := self collectionWithAll: #($l $u $k $a $s). self assertIterable: #($l $u $k $a $s) equals: collection.. self assertInvariants: collection. collection add: $k. self assertIterable: #($l $u $a $s $k) equals: collection. self assertInvariants: collection. collection add: $l. self assertIterable: #($u $a $s $k $l) equals: collection. self assertInvariants: collection. collection add: $l. self assertIterable: #($u $a $s $k $l) equals: collection. self assertInvariants: collection. collection add: $x. self assertIterable: #($u $a $s $k $l $x) equals: collection. self assertInvariants: collection! ! !CTLinkedHashSetTest methodsFor: 'testing-iterators' stamp: 'lr 1/27/2012 10:10'! testBackwardIterator | collection | collection := self collectionWithAll: #($l $u $k $a $s). self assertIterable: #($s $a $k $u $l) equals: collection backwardIterator! ! !CTLinkedHashSetTest methodsFor: 'testing-iterators' stamp: 'lr 1/27/2012 10:11'! testForwardIterator | collection | collection := self collectionWithAll: #($l $u $k $a $s). self assertIterable: #($l $u $k $a $s) equals: collection forwardIterator! ! !CTLinkedHashSetTest methodsFor: 'testing' stamp: 'lr 1/14/2012 13:33'! testRemoveInOrder | collection | collection := self collectionWithAll: #($l $u $k $a $s). self assertIterable: #($l $u $k $a $s) equals: collection.. self assertInvariants: collection. collection remove: $u. self assertIterable: #($l $k $a $s) equals: collection. self assertInvariants: collection. collection remove: $l. self assertIterable: #($k $a $s) equals: collection. self assertInvariants: collection. collection remove: $s. self assertIterable: #($k $a) equals: collection. self assertInvariants: collection! ! !CTSetTest class methodsFor: 'testing' stamp: 'lr 1/13/2012 22:47'! isAbstract ^ self name = #CTSetTest! ! !CTSetTest methodsFor: 'accessing' stamp: 'lr 1/13/2012 22:46'! collectionClass ^ CTSet! ! !CTSetTest methodsFor: 'tests-adding' stamp: 'lr 1/14/2012 10:00'! testAddDuplicates | collection | collection := self collectionWithAll: #($a $b $c). self assert: (collection add: $c) = $c. self assert: (collection add: $b) = $b. self assert: (collection add: $a) = $a. self assert: (collection size) = 3. self assert: (collection add: $d) = $d. self assert: (collection size) = 4. self assertInvariants: collection! ! !CTSetTest methodsFor: 'tests-adding' stamp: 'lr 1/14/2012 10:01'! testAddRemove | collection | collection := self emptyCollection. self deny: (collection includes: $a). self assert: (collection add: $a) = $a. self assert: (collection includes: $a). self assert: (collection add: $a) = $a. self assert: (collection includes: $a). self assert: (collection remove: $a) = $a. self deny: (collection includes: $a). self assertInvariants: collection! ! !CTSetTest methodsFor: 'tests-testing' stamp: 'lr 1/14/2012 09:59'! testIncludes | collection | collection := self collectionWithAll: #($a $b $c). self assert: (collection includes: $a). self assert: (collection includes: $b). self assert: (collection includes: $c). self deny: (collection includes: $d)! ! !CTSetTest methodsFor: 'tests-testing' stamp: 'lr 1/14/2012 09:59'! testIncludesAll | collection | collection := self collectionWithAll: #($a $b $c). self assert: (collection includesAll: #()). self assert: (collection includesAll: #($a)). self assert: (collection includesAll: #($a $b)). self assert: (collection includesAll: #($a $b $c)). self deny: (collection includesAll: #($d)). self deny: (collection includesAll: #($a $d))! ! !CTSetTest methodsFor: 'tests' stamp: 'lr 1/28/2012 16:41'! workflowSize ^ 100000! ! CTSetTest subclass: #CTTreeSetTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Sets'! !CTTreeSetTest methodsFor: 'accessing' stamp: 'lr 1/15/2012 15:03'! collectionClass ^ CTTreeSet! ! !CTTreeSetTest methodsFor: 'testing-iterators' stamp: 'lr 1/27/2012 10:12'! testBackwardIterator | collection | collection := self collectionWithAll: #($l $u $k $a $s). self assertIterable: #($u $s $l $k $a) equals: collection backwardIterator! ! !CTTreeSetTest methodsFor: 'testing-iterators' stamp: 'lr 1/27/2012 10:12'! testForwardIterator | collection | collection := self collectionWithAll: #($l $u $k $a $s). self assertIterable: #($a $k $l $s $u) equals: collection forwardIterator! ! CTContainerTest subclass: #CTComparatorTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Comparators'! !CTComparatorTest methodsFor: 'utilities' stamp: 'lr 1/26/2012 13:25'! assertPrintString: anOrder self assert: anOrder printString isString. self deny: anOrder printString isEmpty! ! !CTComparatorTest methodsFor: 'tests-operators' stamp: 'lr 1/26/2012 16:15'! testCombined | comparator | comparator := #size asComparator , #first asComparator , #last asComparator. self assertPrintString: comparator! ! !CTComparatorTest methodsFor: 'tests-operators' stamp: 'lr 1/26/2012 16:15'! testCombinedEquality | comparator | comparator := #first asComparator , #last asComparator. self assert: (comparator equals: #('A' 'B') to: #('A' 'B')). self deny: (comparator equals: #('X' 'B') to: #('A' 'B')). self deny: (comparator equals: #('A' 'X') to: #('A' 'B')). self deny: (comparator equals: #('A' 'B') to: #('X' 'B')). self deny: (comparator equals: #('A' 'B') to: #('A' 'X')).! ! !CTComparatorTest methodsFor: 'tests-operators' stamp: 'lr 1/26/2012 16:15'! testCombinedHash | comparator | comparator := #first asComparator , #last asComparator. self assert: (comparator hashOf: #('A' 'B')) = (comparator hashOf: #('A' 'B')). self deny: (comparator hashOf: #('A' 'B')) = (comparator hashOf: #('B' 'A')). self deny: (comparator hashOf: #('A' 'B')) = (comparator hashOf: #('A' 'X')). self deny: (comparator hashOf: #('A' 'B')) = (comparator hashOf: #('B' 'X'))! ! !CTComparatorTest methodsFor: 'tests-operators' stamp: 'lr 1/26/2012 16:15'! testCombinedInequality | comparator | comparator := #size asComparator , #first asComparator , #last asComparator. self assert: (comparator less: #() than: #($a)). self deny: (comparator less: #($a) than: #()). self assert: (comparator less: #($a) than: #($b)). self deny: (comparator less: #($b) than: #($a)). self assert: (comparator less: #($a $c) than: #($b $d)). self deny: (comparator less: #($b $d) than: #($a $c)). self assert: (comparator less: #($a $c) than: #($a $d)). self deny: (comparator less: #($a $d) than: #($a $c)). self deny: (comparator less: #($a $a) than: #($a $a))! ! !CTComparatorTest methodsFor: 'tests' stamp: 'lr 1/27/2012 10:06'! testDelegate | comparator | comparator := CTDelegateComparator on: #size asComparator. self assertPrintString: comparator! ! !CTComparatorTest methodsFor: 'tests' stamp: 'lr 1/27/2012 10:06'! testDelegateEquality | comparator | comparator := CTDelegateComparator on: #size asComparator. self assert: (comparator equals: 'A' to: 'B'). self deny: (comparator equals: 'A' to: 'BC')! ! !CTComparatorTest methodsFor: 'tests' stamp: 'lr 1/27/2012 10:07'! testDelegateHash | comparator | comparator := CTDelegateComparator on: #size asComparator. self assert: (comparator hashOf: 'A') = 1 hash. self assert: (comparator hashOf: 'AB') = 2 hash! ! !CTComparatorTest methodsFor: 'tests' stamp: 'lr 1/27/2012 10:08'! testDelegateInequality | comparator | comparator := CTDelegateComparator on: #size asComparator. self assert: (comparator less: 'B' than: 'AA'). self deny: (comparator less: 'AA' than: 'B')! ! !CTComparatorTest methodsFor: 'tests' stamp: 'lr 1/26/2012 16:07'! testIdentity | comparator | comparator := CTIdentityComparator new. self assert: CTIdentityComparator new = comparator. self assertPrintString: comparator! ! !CTComparatorTest methodsFor: 'tests' stamp: 'lr 1/26/2012 16:08'! testIdentityEquality | comparator object | comparator := CTIdentityComparator new. object := Object new. self assert: (comparator equals: object to: object). self deny: (comparator equals: object to: Object new). self deny: (comparator equals: Object new to: object)! ! !CTComparatorTest methodsFor: 'tests' stamp: 'lr 1/26/2012 16:09'! testIdentityHash | comparator object | comparator := CTIdentityComparator new. object := Object new. self assert: (comparator hashOf: object) = (comparator hashOf: object). self assert: (comparator hashOf: object) = object identityHash! ! !CTComparatorTest methodsFor: 'tests' stamp: 'pmm 2/6/2012 20:43'! testIdentityInequality | comparator | comparator := CTIdentityComparator new. self assert: (comparator less: 1 than: 2). self deny: (comparator less: 2 than: 1). self deny: (comparator less: 2 than: 2)! ! !CTComparatorTest methodsFor: 'tests-searching' stamp: 'lr 2/7/2012 20:52'! testIndexOf | order | order := CTNaturalComparator new. 0 to: 100 do: [ :size | | array | array := Array new: size. 1 to: size do: [ :index | array at: index put: index ]. self assert: (order indexOf: 0 in: array) = 0. 1 to: size do: [ :index | self assert: (order indexOf: index in: array) = index ]. self assert: (order indexOf: size + 1 in: array) = 0 ]! ! !CTComparatorTest methodsFor: 'tests-searching' stamp: 'lr 2/7/2012 20:52'! testInsertionIndexOf | order | order := CTNaturalComparator new. 0 to: 100 do: [ :size | | array | array := Array new: size. 1 to: size do: [ :index | array at: index put: 2 * index - 1 ]. self assert: (order insertionIndexOf: 0 in: array) = 1. 1 to: size do: [ :index | self assert: (order insertionIndexOf: 2 * index in: array) = (index + 1) ] ]! ! !CTComparatorTest methodsFor: 'tests-testing' stamp: 'lr 1/26/2012 16:20'! testIsPartial | comparator | comparator := CTNaturalComparator new. self assert: (comparator isPartial: #()). self assert: (comparator isPartial: #(1)). self assert: (comparator isPartial: #(1 2)). self assert: (comparator isPartial: #(1 2 3)). self assert: (comparator isPartial: #(1 1 2 3)). self assert: (comparator isPartial: #(1 2 2 3)). self assert: (comparator isPartial: #(1 2 3 3)). self deny: (comparator isPartial: #(2 1 2 3)). self deny: (comparator isPartial: #(1 2 3 2))! ! !CTComparatorTest methodsFor: 'tests-testing' stamp: 'lr 1/26/2012 16:20'! testIsStrict | comparator | comparator := CTNaturalComparator new. self assert: (comparator isStrict: #()). self assert: (comparator isStrict: #(1)). self assert: (comparator isStrict: #(1 2)). self assert: (comparator isStrict: #(1 2 3)). self deny: (comparator isStrict: #(1 1 2 3)). self deny: (comparator isStrict: #(1 2 2 3)). self deny: (comparator isStrict: #(1 2 3 3)). self deny: (comparator isStrict: #(2 1 2 3)). self deny: (comparator isStrict: #(1 2 3 2))! ! !CTComparatorTest methodsFor: 'tests-querying' stamp: 'lr 1/26/2012 16:19'! testMaximum | comparator | comparator := CTNaturalComparator new. self should: [ comparator maximum: #() ] raise: CTNoSuchElementError. self assert: (comparator maximum: #(1)) = 1. self assert: (comparator maximum: #(1 2)) = 2. self assert: (comparator maximum: #(2 1)) = 2. self assert: (comparator maximum: #(3 2 1)) = 3. self assert: (comparator maximum: #(3 2 3)) = 3! ! !CTComparatorTest methodsFor: 'tests-querying' stamp: 'lr 1/26/2012 16:20'! testMinimum | comparator | comparator := CTNaturalComparator new. self should: [ comparator minimum: #() ] raise: CTNoSuchElementError. self assert: (comparator minimum: #(1)) = 1. self assert: (comparator minimum: #(1 2)) = 1. self assert: (comparator minimum: #(2 1)) = 1. self assert: (comparator minimum: #(3 2 1)) = 1. self assert: (comparator minimum: #(3 2 2)) = 2! ! !CTComparatorTest methodsFor: 'tests-operators' stamp: 'lr 1/26/2012 16:16'! testMutating | comparator | comparator := #size asComparator. self assertPrintString: comparator! ! !CTComparatorTest methodsFor: 'tests-operators' stamp: 'lr 1/26/2012 16:15'! testMutatingEquality | comparator | comparator := #size asComparator. self assert: (comparator equals: 'Tina' to: 'Ilke'). self assert: (comparator equals: 'Ilke' to: 'Tina'). self deny: (comparator equals: 'Tina' to: 'Kimberley'). self deny: (comparator equals: 'Kimberley' to: 'Tina')! ! !CTComparatorTest methodsFor: 'tests-operators' stamp: 'lr 1/26/2012 16:16'! testMutatingHash | comparator | comparator := #size asComparator. self assert: (comparator hashOf: 'Tina') = (comparator hashOf: 'Tina'). self deny: (comparator hashOf: 'Tina') = (comparator hashOf: 'Kimberley')! ! !CTComparatorTest methodsFor: 'tests-operators' stamp: 'lr 1/26/2012 16:16'! testMutatingInequality | comparator | comparator := #yourself asComparator. self assert: (comparator less: 'a' than: 'b'). self deny: (comparator less: 'b' than: 'a'). self deny: (comparator less: 'a' than: 'a'). comparator := #size asComparator. self assert: (comparator less: 'a' than: 'bb'). self deny: (comparator less: 'bb' than: 'a'). self deny: (comparator less: 'a' than: 'a')! ! !CTComparatorTest methodsFor: 'tests' stamp: 'lr 1/26/2012 16:07'! testNatural | comparator | comparator := CTNaturalComparator new. self assert: CTNaturalComparator new = comparator. self assertPrintString: comparator! ! !CTComparatorTest methodsFor: 'tests' stamp: 'lr 1/26/2012 16:12'! testNaturalEquality | comparator object | comparator := CTNaturalComparator new. object := 'foo'. self assert: (comparator equals: object to: object). self assert: (comparator equals: object to: object copy). self assert: (comparator equals: object copy to: object). self assert: (comparator equals: object copy to: object copy). self deny: (comparator equals: object to: 'bar'). self deny: (comparator equals: 'bar' to: object)! ! !CTComparatorTest methodsFor: 'tests' stamp: 'pmm 2/6/2012 20:43'! testNaturalHash | comparator | comparator := CTNaturalComparator new. self assert: (comparator hashOf: 'foo') = (comparator hashOf: 'foo'). self assert: (comparator hashOf: 'foo') = 'foo' hash! ! !CTComparatorTest methodsFor: 'tests' stamp: 'pmm 2/6/2012 20:43'! testNaturalInequality | comparator | comparator := CTNaturalComparator new. self assert: (comparator less: 1 than: 2). self deny: (comparator less: 2 than: 1). self deny: (comparator less: 2 than: 2)! ! !CTComparatorTest methodsFor: 'tests-operators' stamp: 'lr 1/26/2012 16:17'! testReverse | comparator | comparator := CTNaturalComparator new reverse. self assertPrintString: comparator! ! !CTComparatorTest methodsFor: 'tests-operators' stamp: 'lr 1/26/2012 16:16'! testReverseEquality | comparator | comparator := CTNaturalComparator new reverse. self assert: (comparator equals: 'Gerald' to: 'Gerald'). self deny: (comparator equals: 'Gerald' to: 'Betty'). self deny: (comparator equals: 'Betty' to: 'Gerald'). self assert: (comparator equals: 'Betty' to: 'Betty')! ! !CTComparatorTest methodsFor: 'tests-operators' stamp: 'lr 1/26/2012 16:16'! testReverseHash | comparator reversed | comparator := CTNaturalComparator new. reversed := comparator reverse. self assert: (comparator hashOf: 'Gerald') = (reversed hashOf: 'Gerald'). self assert: (comparator hashOf: 'Betty') = (reversed hashOf: 'Betty')! ! !CTComparatorTest methodsFor: 'tests-operators' stamp: 'lr 1/26/2012 16:16'! testReverseInequality | comparator | comparator := CTNaturalComparator new reverse. self assert: (comparator less: $b than: $a). self deny: (comparator less: $a than: $b). self deny: (comparator less: $a than: $a). comparator := comparator reverse. self assert: (comparator less: $a than: $b). self deny: (comparator less: $b than: $a). self deny: (comparator less: $a than: $a) ! ! !CTComparatorTest methodsFor: 'tests-operators' stamp: 'lr 1/26/2012 16:19'! testReverseMaximum | comparator | comparator := CTNaturalComparator new reverse. self should: [ comparator maximum: #() ] raise: CTNoSuchElementError. self assert: (comparator maximum: #(1)) = 1. self assert: (comparator maximum: #(1 2)) = 1. self assert: (comparator maximum: #(2 1)) = 1. self assert: (comparator maximum: #(3 2 1)) = 1. self assert: (comparator maximum: #(3 2 2)) = 2! ! !CTComparatorTest methodsFor: 'tests-operators' stamp: 'lr 1/26/2012 16:18'! testReverseMinimum | comparator | comparator := CTNaturalComparator new reverse. self should: [ comparator minimum: #() ] raise: CTNoSuchElementError. self assert: (comparator minimum: #(1)) = 1. self assert: (comparator minimum: #(1 2)) = 2. self assert: (comparator minimum: #(2 1)) = 2. self assert: (comparator minimum: #(3 2 1)) = 3. self assert: (comparator minimum: #(3 2 3)) = 3! ! !CTComparatorTest methodsFor: 'tests-sorting' stamp: 'lr 1/24/2012 19:15'! testSortRandomizedArray | array | array := Array new: 10000. 1 to: 10000 do: [ :index | array at: index put: index ]. CTNaturalComparator new sort: array shuffled. 1 to: 10000 do: [ :index | self assert: (array at: index) = index ]! ! !CTComparatorTest methodsFor: 'tests-sorting' stamp: 'lr 1/24/2012 19:15'! testSortReversedArray | array | array := Array new: 10000. 1 to: 10000 do: [ :index | array at: index put: 10001 - index ]. CTNaturalComparator new sort: array. 1 to: 10000 do: [ :index | self assert: (array at: index) = index ]! ! !CTComparatorTest methodsFor: 'tests-sorting' stamp: 'lr 1/24/2012 19:15'! testSortSortedArray | array | array := Array new: 10000. 1 to: 10000 do: [ :index | array at: index put: index ]. CTNaturalComparator new sort: array. 1 to: 10000 do: [ :index | self assert: (array at: index) = index ]! ! !CTContainerTest class methodsFor: 'testing' stamp: 'lr 1/14/2012 11:15'! isAbstract ^ self name = #CTContainerTest! ! !CTContainerTest class methodsFor: 'accessing' stamp: 'lr 1/14/2012 14:37'! packageNamesUnderTest ^ #('Container-Core')! ! !CTContainerTest class methodsFor: 'testing' stamp: 'lr 1/14/2012 14:36'! shouldInheritSelectors ^ true! ! !CTContainerTest methodsFor: 'assertions' stamp: 'lr 1/24/2012 19:25'! assertInvariants: anObject anObject assertInvariants: self! ! !CTContainerTest methodsFor: 'assertions' stamp: 'lr 1/14/2012 12:05'! assertIsEmpty: anIterable self assert: anIterable iterator isEmpty. self deny: anIterable iterator hasNext! ! !CTContainerTest methodsFor: 'assertions' stamp: 'lr 1/27/2012 10:22'! assertIterable: firstCollection equals: secondCollection | firstIterator secondIterator | firstIterator := firstCollection iterator. secondIterator := secondCollection iterator. [ firstIterator hasNext and: [ secondIterator hasNext ] ] whileTrue: [ self assert: firstIterator next = secondIterator next ]. self assertIsEmpty: firstIterator; assertIsEmpty: secondIterator! ! !CTContainerTest methodsFor: 'utilities' stamp: 'lr 1/28/2012 13:19'! randomSequence: anInteger "Adds the randomly shuffled numbers from 1 to anInteger into aCollection: http://en.wikipedia.org/wiki/Fisher Yates_shuffle" | numbers | numbers := Array new: anInteger. 1 to: anInteger do: [ :index | numbers at: index put: index ]. anInteger to: 2 by: -1 do: [ :index | numbers swap: index with: index atRandom ]. ^ numbers! ! CTContainerTest subclass: #CTFingerTreeTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Misc'! !CTFingerTreeTest methodsFor: 'accessing' stamp: 'lr 2/5/2012 10:07'! newEmptyTree ^ CTEmptyFingerTree new! ! !CTFingerTreeTest methodsFor: 'utilities' stamp: 'lr 2/5/2012 14:51'! stringsAddFirst ^ #('<>' '<1>' '<2 <> 1>' '<3 2 <> 1>' '<4 3 2 <> 1>' '<5 4 3 2 <> 1>' '<6 5 <(4 3 2)> 1>' '<7 6 5 <(4 3 2)> 1>' '<8 7 6 5 <(4 3 2)> 1>' '<9 8 <(7 6 5) <> (4 3 2)> 1>' '<10 9 8 <(7 6 5) <> (4 3 2)> 1>' '<11 10 9 8 <(7 6 5) <> (4 3 2)> 1>' '<12 11 <(10 9 8) (7 6 5) <> (4 3 2)> 1>' '<13 12 11 <(10 9 8) (7 6 5) <> (4 3 2)> 1>' '<14 13 12 11 <(10 9 8) (7 6 5) <> (4 3 2)> 1>' '<15 14 <(13 12 11) (10 9 8) (7 6 5) <> (4 3 2)> 1>' '<16 15 14 <(13 12 11) (10 9 8) (7 6 5) <> (4 3 2)> 1>' '<17 16 15 14 <(13 12 11) (10 9 8) (7 6 5) <> (4 3 2)> 1>' '<18 17 <(16 15 14) (13 12 11) (10 9 8) (7 6 5) <> (4 3 2)> 1>' '<19 18 17 <(16 15 14) (13 12 11) (10 9 8) (7 6 5) <> (4 3 2)> 1>' '<20 19 18 17 <(16 15 14) (13 12 11) (10 9 8) (7 6 5) <> (4 3 2)> 1>')! ! !CTFingerTreeTest methodsFor: 'utilities' stamp: 'lr 2/5/2012 14:52'! stringsAddLast ^ #('<>' '<1>' '<1 <> 2>' '<1 <> 2 3>' '<1 <> 2 3 4>' '<1 <> 2 3 4 5>' '<1 <(2 3 4)> 5 6>' '<1 <(2 3 4)> 5 6 7>' '<1 <(2 3 4)> 5 6 7 8>' '<1 <(2 3 4) <> (5 6 7)> 8 9>' '<1 <(2 3 4) <> (5 6 7)> 8 9 10>' '<1 <(2 3 4) <> (5 6 7)> 8 9 10 11>' '<1 <(2 3 4) <> (5 6 7) (8 9 10)> 11 12>' '<1 <(2 3 4) <> (5 6 7) (8 9 10)> 11 12 13>' '<1 <(2 3 4) <> (5 6 7) (8 9 10)> 11 12 13 14>' '<1 <(2 3 4) <> (5 6 7) (8 9 10) (11 12 13)> 14 15>' '<1 <(2 3 4) <> (5 6 7) (8 9 10) (11 12 13)> 14 15 16>' '<1 <(2 3 4) <> (5 6 7) (8 9 10) (11 12 13)> 14 15 16 17>' '<1 <(2 3 4) <> (5 6 7) (8 9 10) (11 12 13) (14 15 16)> 17 18>' '<1 <(2 3 4) <> (5 6 7) (8 9 10) (11 12 13) (14 15 16)> 17 18 19>' '<1 <(2 3 4) <> (5 6 7) (8 9 10) (11 12 13) (14 15 16)> 17 18 19 20>')! ! !CTFingerTreeTest methodsFor: 'tests-adding' stamp: 'lr 2/4/2012 19:22'! testAddFirst | tree | tree := self newEmptyTree. self stringsAddFirst iterator do: [ :index :string | self assert: tree printString = string. tree := tree addFirst: index. self assertInvariants: tree ]! ! !CTFingerTreeTest methodsFor: 'tests-adding' stamp: 'lr 2/4/2012 19:22'! testAddLast | tree | tree := self newEmptyTree. self stringsAddLast iterator do: [ :index :string | self assert: tree printString = string. tree := tree addLast: index. self assertInvariants: tree ]! ! !CTFingerTreeTest methodsFor: 'tests-accessing' stamp: 'pmm 2/6/2012 20:43'! testAllButFirst | tree | tree := self newEmptyTree. 1 to: 100 do: [ :index | tree := tree addFirst: index ]. 100 to: 1 by: -1 do: [ :index | self assert: tree first = index. tree := tree allButFirst. self assertInvariants: tree ]. self should: [ tree allButFirst ] raise: CTNoSuchElementError. self assert: tree isEmpty! ! !CTFingerTreeTest methodsFor: 'tests-accessing' stamp: 'pmm 2/6/2012 20:44'! testAllButLast | tree | tree := self newEmptyTree. 1 to: 100 do: [ :index | tree := tree addLast: index ]. 100 to: 1 by: -1 do: [ :index | self assert: tree last = index. tree := tree allButLast. self assertInvariants: tree ]. self should: [ tree allButLast ] raise: CTNoSuchElementError. self assert: tree isEmpty! ! !CTFingerTreeTest methodsFor: 'tests-iterators' stamp: 'lr 2/4/2012 16:03'! testBackwardIterator | tree tally | tree := self newEmptyTree. 1 to: 100 do: [ :index | tree := tree addLast: index ]. tally := 101. tree backwardIterator do: [ :each | self assert: (tally := tally - 1) = each ]. self assert: tally = 1! ! !CTFingerTreeTest methodsFor: 'tests-operators' stamp: 'lr 2/4/2012 19:38'! testConcate | lowercase uppercase | lowercase := ($a to: $z) inject: self newEmptyTree into: [ :tree :char | tree addLast: char ]. uppercase := ($A to: $Z) inject: self newEmptyTree into: [ :tree :char | tree addLast: char ]. self assertIterable: lowercase , lowercase equals: lowercase iterator , lowercase iterator. self assertIterable: lowercase , uppercase equals: lowercase iterator , uppercase iterator. self assertIterable: uppercase , lowercase equals: uppercase iterator , lowercase iterator. self assertIterable: uppercase , uppercase equals: uppercase iterator , uppercase iterator! ! !CTFingerTreeTest methodsFor: 'tests-operators' stamp: 'lr 2/4/2012 19:20'! testConcateWithDeep | tree deep | tree := self newEmptyTree. deep := (self newEmptyTree addLast: $x) addLast: $y. self assertIterable: tree , deep equals: #($x $y). tree := tree addLast: $a. self assertIterable: tree , deep equals: #($a $x $y). tree := tree addLast: $b. self assertIterable: tree , deep equals: #($a $b $x $y). tree := tree addLast: $c. self assertIterable: tree , deep equals: #($a $b $c $x $y). tree := tree addLast: $d. self assertIterable: tree , deep equals: #($a $b $c $d $x $y)! ! !CTFingerTreeTest methodsFor: 'tests-operators' stamp: 'lr 2/4/2012 18:40'! testConcateWithDeeper | tree deep | tree := self newEmptyTree. deep := ((self newEmptyTree addLast: $x) addLast: $y) addLast: $z. self assertIterable: tree , deep equals: #($x $y $z). tree := tree addLast: $a. self assertIterable: tree , deep equals: #($a $x $y $z). tree := tree addLast: $b. self assertIterable: tree , deep equals: #($a $b $x $y $z). tree := tree addLast: $c. self assertIterable: tree , deep equals: #($a $b $c $x $y $z). tree := tree addLast: $d. self assertIterable: tree , deep equals: #($a $b $c $d $x $y $z)! ! !CTFingerTreeTest methodsFor: 'tests-operators' stamp: 'lr 2/4/2012 19:23'! testConcateWithEmpty | tree empty | tree := self newEmptyTree. empty := self newEmptyTree. self assertInvariants: tree , empty. self assertIterable: tree , empty equals: #(). tree := tree addLast: $a. self assertInvariants: tree , empty. self assertIterable: tree , empty equals: #($a). tree := tree addLast: $b. self assertInvariants: tree , empty. self assertIterable: tree , empty equals: #($a $b)! ! !CTFingerTreeTest methodsFor: 'tests-operators' stamp: 'lr 2/4/2012 19:23'! testConcateWithSingle | tree single | tree := self newEmptyTree. single := self newEmptyTree addLast: $x. self assertInvariants: tree , single. self assertIterable: tree , single equals: #($x). tree := tree addLast: $a. self assertInvariants: tree , single. self assertIterable: tree , single equals: #($a $x). tree := tree addLast: $b. self assertInvariants: tree , single. self assertIterable: tree , single equals: #($a $b $x)! ! !CTFingerTreeTest methodsFor: 'tests-accessing' stamp: 'pmm 2/6/2012 20:44'! testFirst | tree | tree := self newEmptyTree. self should: [ tree first ] raise: CTNoSuchElementError. 1 to: 100 do: [ :index | tree := tree addFirst: index. self assert: tree first = index ]! ! !CTFingerTreeTest methodsFor: 'tests-iterators' stamp: 'lr 2/4/2012 16:03'! testForwardIterator | tree tally | tree := self newEmptyTree. 1 to: 100 do: [ :index | tree := tree addLast: index ]. tally := 0. tree forwardIterator do: [ :each | self assert: (tally := tally + 1) = each ]. self assert: tally = 100! ! !CTFingerTreeTest methodsFor: 'tests-testing' stamp: 'lr 2/4/2012 14:24'! testIsEmpty | tree | tree := self newEmptyTree. self assert: tree isEmpty. tree := tree addLast: $a. self deny: tree isEmpty. tree := tree addFirst: $b. self deny: tree isEmpty! ! !CTFingerTreeTest methodsFor: 'tests-accessing' stamp: 'pmm 2/6/2012 20:44'! testLast | tree | tree := self newEmptyTree. self should: [ tree last ] raise: CTNoSuchElementError. 1 to: 100 do: [ :index | tree := tree addLast: index. self assert: tree last = index ]! ! CTContainerTest subclass: #CTIteratorTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Iterators'! !CTIteratorTest methodsFor: 'tests-modifications' stamp: 'lr 1/20/2012 22:16'! testAddTo | collection | collection := CTArrayList new. #(1 2 3 4) iterator addTo: collection. self assertIterable: collection equals: #(1 2 3 4)! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/13/2012 11:02'! testAllSatisfy self assert: (#() forwardIterator allSatisfy: [ :each | each > 2 ]). self assert: (#() backwardIterator allSatisfy: [ :each | each > 2 ]). self deny: (#(1) forwardIterator allSatisfy: [ :each | each > 2 ]). self deny: (#(1) backwardIterator allSatisfy: [ :each | each > 2 ]). self assert: (#(3) forwardIterator allSatisfy: [ :each | each > 2 ]). self assert: (#(3) backwardIterator allSatisfy: [ :each | each > 2 ]). self deny: (#(2 3 4) forwardIterator allSatisfy: [ :each | each > 2 ]). self deny: (#(2 3 4) backwardIterator allSatisfy: [ :each | each > 2 ]). self assert: (#(3 4 5) forwardIterator allSatisfy: [ :each | each > 2 ]). self assert: (#(3 4 5) backwardIterator allSatisfy: [ :each | each > 2 ])! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/13/2012 11:01'! testAnySatisfy self deny: (#() forwardIterator anySatisfy: [ :each | each > 2 ]). self deny: (#() backwardIterator anySatisfy: [ :each | each > 2 ]). self assert: (#(3) forwardIterator anySatisfy: [ :each | each > 2 ]). self assert: (#(3) backwardIterator anySatisfy: [ :each | each > 2 ]). self deny: (#(1) forwardIterator anySatisfy: [ :each | each > 2 ]). self deny: (#(1) backwardIterator anySatisfy: [ :each | each > 2 ]). self assert: (#(1 2 3) forwardIterator anySatisfy: [ :each | each > 2 ]). self assert: (#(1 2 3) backwardIterator anySatisfy: [ :each | each > 2 ]). self deny: (#(0 1 2) forwardIterator anySatisfy: [ :each | each > 2 ]). self deny: (#(0 1 2) backwardIterator anySatisfy: [ :each | each > 2 ])! ! !CTIteratorTest methodsFor: 'tests-array' stamp: 'lr 1/13/2012 11:01'! testArrayIteratorBidirectional self assertIterable: #() forwardIterator equals: #() backwardIterator. self assertIterable: #(1) forwardIterator equals: #(1) backwardIterator. self assertIterable: #(1 2) forwardIterator equals: #(2 1) backwardIterator. self assertIterable: #(1 2 3) forwardIterator equals: #(3 2 1) backwardIterator. self assertIterable: #(1 2 3 4) forwardIterator equals: #(4 3 2 1) backwardIterator. self assertIterable: #(1 2 3 4 5) forwardIterator equals: #(5 4 3 2 1) backwardIterator! ! !CTIteratorTest methodsFor: 'tests-array' stamp: 'lr 1/10/2012 22:30'! testArrayIteratorForwardCollect | letters expected | letters := #($a $b $c). expected := #(1 $A 2 $B 3 $C) iterator. (letters iterator collect: [ :each | each asUppercase ]) do: [ :index :each | self assert: index = expected next. self assert: each = expected next ]. self assertIsEmpty: expected. expected := #(10 20 30) iterator. (letters iterator collect: [ :index :each | index * 10 ]) do: [ :each | self assert: each = expected next ]. self assertIsEmpty: expected! ! !CTIteratorTest methodsFor: 'tests-array' stamp: 'pmm 2/6/2012 20:44'! testArrayIteratorForwardDo | expected | expected := #(1 $a 2 $b 3 $c 4 $d) iterator. #($a $b $c $d) iterator do: [ :index :each | self assert: index = expected next. self assert: each = expected next ]. self assertIsEmpty: expected! ! !CTIteratorTest methodsFor: 'tests-array' stamp: 'lr 1/10/2012 22:30'! testArrayIteratorForwardInject | letters expected | letters := #($a $b $c). expected := #(0 $a 10 $b 20 $c) iterator. letters iterator inject: 0 into: [ :result :each | self assert: result = expected next. self assert: each = expected next. result + 10 ]. self assertIsEmpty: expected. expected := #(0 1 $a 10 2 $b 20 3 $c) iterator. letters iterator inject: 0 into: [ :result :index :each | self assert: result = expected next. self assert: index = expected next. self assert: each = expected next. result + 10 ]. self assertIsEmpty: expected! ! !CTIteratorTest methodsFor: 'tests-array' stamp: 'lr 1/10/2012 22:30'! testArrayIteratorForwardSelect | letters expected | letters := #($a $b $c $d $e $f $g). expected := #(1 $a 5 $e) iterator. (letters iterator select: [ :each | each isVowel ]) do: [ :index :each | self assert: index = expected next. self assert: each = expected next ]. self assertIsEmpty: expected. expected := #($b $d $f) iterator. (letters iterator select: [ :index :each | index even ]) do: [ :each | self assert: each = expected next ]. self assertIsEmpty: expected! ! !CTIteratorTest methodsFor: 'tests-array' stamp: 'pmm 2/6/2012 20:44'! testArrayIteratorReverseDo | expected | expected := #(4 $d 3 $c 2 $b 1 $a) iterator. #($a $b $c $d) backwardIterator do: [ :index :each | self assert: index = expected next. self assert: each = expected next ]. self assertIsEmpty: expected! ! !CTIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 2/4/2012 20:18'! testChaining2 self assertIterable: #() iterator , #() iterator equals: #(). self assertIterable: #(1) iterator , #() iterator equals: #(1). self assertIterable: #() iterator , #(1) iterator equals: #(1). self assertIterable: #(1 2) iterator , #() iterator equals: #(1 2). self assertIterable: #(1) iterator , #(2) iterator equals: #(1 2). self assertIterable: #() iterator , #(1 2) iterator equals: #(1 2)! ! !CTIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 2/4/2012 20:18'! testChaining3 self assertIterable: #() iterator , #() iterator , #() iterator equals: #(). self assertIterable: #(1) iterator , #() iterator , #() iterator equals: #(1). self assertIterable: #() iterator , #(1) iterator , #() iterator equals: #(1). self assertIterable: #() iterator , #() iterator , #(1) iterator equals: #(1). self assertIterable: #(1 2) iterator , #() iterator , #() iterator equals: #(1 2). self assertIterable: #(1) iterator , #(2) iterator , #() iterator equals: #(1 2). self assertIterable: #(1) iterator , #() iterator , #(2) iterator equals: #(1 2). self assertIterable: #() iterator , #(1 2) iterator , #() iterator equals: #(1 2). self assertIterable: #() iterator , #(1) iterator , #(2) iterator equals: #(1 2). self assertIterable: #() iterator , #() iterator , #(1 2) iterator equals: #(1 2)! ! !CTIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 1/10/2012 22:33'! testCollect self assertIterable: (#() iterator collect: [ :each | 2 * each ]) equals: #(). self assertIterable: (#(1) iterator collect: [ :each | 2 * each ]) equals: #(2). self assertIterable: (#(1 2) iterator collect: [ :each | 2 * each ]) equals: #(2 4). self assertIterable: (#(1 2 3 4) iterator collect: [ :each | 2 * each ]) equals: #(2 4 6 8)! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/13/2012 11:02'! testCount self assert: (#() forwardIterator count: [ :each | each > 2 ]) = 0. self assert: (#() backwardIterator count: [ :each | each > 2 ]) = 0. self assert: (#(1) forwardIterator count: [ :each | each > 2 ]) = 0. self assert: (#(1) backwardIterator count: [ :each | each > 2 ]) = 0. self assert: (#(1 2) forwardIterator count: [ :each | each > 2 ]) = 0. self assert: (#(1 2) backwardIterator count: [ :each | each > 2 ]) = 0. self assert: (#(1 2 3) forwardIterator count: [ :each | each > 2 ]) = 1. self assert: (#(1 2 3) backwardIterator count: [ :each | each > 2 ]) = 1. self assert: (#(1 2 3 4) forwardIterator count: [ :each | each > 2 ]) = 2. self assert: (#(1 2 3 4) backwardIterator count: [ :each | each > 2 ]) = 2! ! !CTIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 1/10/2012 22:33'! testCycle self assertIterable: (#() iterator cycle limit: 5) equals: #(). self assertIterable: (#(1) iterator cycle limit: 5) equals: #(1 1 1 1 1). self assertIterable: (#(1 2) iterator cycle limit: 5) equals: #(1 2 1 2 1). self assertIterable: (#(1 2 3) iterator cycle limit: 5) equals: #(1 2 3 1 2). self assertIterable: (#(1 2 3 4) iterator cycle limit: 5) equals: #(1 2 3 4 1)! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/13/2012 11:02'! testDetect self should: [ #() forwardIterator detect: [ :each | each > 2 ] ] raise: CTNoSuchElementError. self should: [ #() backwardIterator detect: [ :each | each > 2 ] ] raise: CTNoSuchElementError. self should: [ #(1) forwardIterator detect: [ :each | each > 2 ] ] raise: CTNoSuchElementError. self should: [ #(1) backwardIterator detect: [ :each | each > 2 ] ] raise: CTNoSuchElementError. self assert: (#(3) forwardIterator detect: [ :each | each > 2 ]) = 3. self assert: (#(3) backwardIterator detect: [ :each | each > 2 ]) = 3. self assert: (#(2 3 4) forwardIterator detect: [ :each | each > 2 ]) = 3. self assert: (#(2 3 4) backwardIterator detect: [ :each | each > 2 ]) = 4. self assert: (#(3 4 5) forwardIterator detect: [ :each | each > 2 ]) = 3. self assert: (#(3 4 5) backwardIterator detect: [ :each | each > 2 ]) = 5! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/13/2012 11:02'! testDetectIfNone self assert: (#() forwardIterator detect: [ :each | each > 2 ] ifNone: [ true ]). self assert: (#() backwardIterator detect: [ :each | each > 2 ] ifNone: [ true ]). self assert: (#(1) forwardIterator detect: [ :each | each > 2 ] ifNone: [ true ]). self assert: (#(1) backwardIterator detect: [ :each | each > 2 ] ifNone: [ true ]). self assert: (#(3) forwardIterator detect: [ :each | each > 2 ] ifNone: [ true ]) = 3. self assert: (#(3) backwardIterator detect: [ :each | each > 2 ] ifNone: [ true ]) = 3. self assert: (#(2 3 4) forwardIterator detect: [ :each | each > 2 ] ifNone: [ true ]) = 3. self assert: (#(2 3 4) backwardIterator detect: [ :each | each > 2 ] ifNone: [ true ]) = 4. self assert: (#(3 4 5) forwardIterator detect: [ :each | each > 2 ] ifNone: [ true ]) = 3. self assert: (#(3 4 5) backwardIterator detect: [ :each | each > 2 ] ifNone: [ true ]) = 5! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/10/2012 22:30'! testDo | iterator | #() iterator do: [ :each | self assert: false ]. iterator := #(1 2 3 4) iterator. #(1 2 3 4) iterator do: [ :each | self assert: each = iterator next ]. self assertIsEmpty: iterator! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/10/2012 22:30'! testDoSeparatedBy | iterator | #() iterator do: [ :each | self assert: false ] separatedBy: [ self assert: false ]. iterator := #(1 nil 2 nil 3 nil 4) iterator. #(1 2 3 4) iterator do: [ :each | self assert: each = iterator next ] separatedBy: [ self assert: iterator next isNil ]. self assertIsEmpty: iterator! ! !CTIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 1/10/2012 22:33'! testEmpty self assertIterable: CTEmptyIterator new equals: #(). self deny: CTEmptyIterator new hasNext. self should: [ CTEmptyIterator new next ] raise: CTNoSuchElementError ! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/13/2012 11:02'! testFind self assert: (#() forwardIterator find: [ :each | each > 2 ]) = 0. self assert: (#() backwardIterator find: [ :each | each > 2 ]) = 0. self assert: (#(1) forwardIterator find: [ :each | each > 2 ]) = 0. self assert: (#(1) backwardIterator find: [ :each | each > 2 ]) = 0. self assert: (#(3) forwardIterator find: [ :each | each > 2 ]) = 1. self assert: (#(3) backwardIterator find: [ :each | each > 2 ]) = 1. self assert: (#(2 3 4) forwardIterator find: [ :each | each > 2 ]) = 2. self assert: (#(2 3 4) backwardIterator find: [ :each | each > 2 ]) = 1. self assert: (#(3 4 5) forwardIterator find: [ :each | each > 2 ]) = 1. self assert: (#(3 4 5) backwardIterator find: [ :each | each > 2 ]) = 1! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/13/2012 11:03'! testFindIfAbsent self assert: (#() forwardIterator find: [ :each | each > 2 ] ifAbsent: [ true ]). self assert: (#() backwardIterator find: [ :each | each > 2 ] ifAbsent: [ true ]). self assert: (#(1) forwardIterator find: [ :each | each > 2 ] ifAbsent: [ true ]). self assert: (#(1) backwardIterator find: [ :each | each > 2 ] ifAbsent: [ true ]). self assert: (#(3) forwardIterator find: [ :each | each > 2 ] ifAbsent: [ true ]) = 1. self assert: (#(3) backwardIterator find: [ :each | each > 2 ] ifAbsent: [ true ]) = 1. self assert: (#(2 3 4) forwardIterator find: [ :each | each > 2 ] ifAbsent: [ true ]) = 2. self assert: (#(2 3 4) backwardIterator find: [ :each | each > 2 ] ifAbsent: [ true ]) = 1. self assert: (#(3 4 5) forwardIterator find: [ :each | each > 2 ] ifAbsent: [ true ]) = 1. self assert: (#(3 4 5) backwardIterator find: [ :each | each > 2 ] ifAbsent: [ true ]) = 1! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/13/2012 11:04'! testIncludes self deny: (#() forwardIterator includes: 2). self deny: (#() backwardIterator includes: 2). self deny: (#(1) forwardIterator includes: 2). self deny: (#(1) backwardIterator includes: 2). self deny: (#(3) forwardIterator includes: 2). self deny: (#(3) backwardIterator includes: 2). self deny: (#(3 4 5) forwardIterator includes: 2). self deny: (#(3 4 5) backwardIterator includes: 2). self assert: (#(2 3 4) forwardIterator includes: 2). self assert: (#(2 3 4) backwardIterator includes: 2)! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/13/2012 11:04'! testIndexOf self assert: (#() forwardIterator indexOf: 2) = 0. self assert: (#() backwardIterator indexOf: 2) = 0. self assert: (#(1) forwardIterator indexOf: 2) = 0. self assert: (#(1) backwardIterator indexOf: 2) = 0. self assert: (#(2) forwardIterator indexOf: 2) = 1. self assert: (#(2) backwardIterator indexOf: 2) = 1. self assert: (#(3 4 5) forwardIterator indexOf: 2) = 0. self assert: (#(3 4 5) backwardIterator indexOf: 2) = 0. self assert: (#(2 3 4) forwardIterator indexOf: 2) = 1. self assert: (#(2 3 4) backwardIterator indexOf: 2) = 3! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/13/2012 11:03'! testIndexOfIfAbsent self assert: (#() forwardIterator indexOf: 2 ifAbsent: [ true ]). self assert: (#() backwardIterator indexOf: 2 ifAbsent: [ true ]). self assert: (#(1) forwardIterator indexOf: 2 ifAbsent: [ true ]). self assert: (#(1) backwardIterator indexOf: 2 ifAbsent: [ true ]). self assert: (#(2) forwardIterator indexOf: 2 ifAbsent: [ true ]) = 1. self assert: (#(2) backwardIterator indexOf: 2 ifAbsent: [ true ]) = 1. self assert: (#(3 4 5) forwardIterator indexOf: 2 ifAbsent: [ true ]). self assert: (#(3 4 5) backwardIterator indexOf: 2 ifAbsent: [ true ]). self assert: (#(2 3 4) forwardIterator indexOf: 2 ifAbsent: [ true ]) = 1. self assert: (#(2 3 4) backwardIterator indexOf: 2 ifAbsent: [ true ]) = 3! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/13/2012 11:03'! testInjectInto self assert: (#() forwardIterator inject: 1 into: [ :a :b | a - b ]) = 1. self assert: (#() backwardIterator inject: 1 into: [ :a :b | a - b ]) = 1. self assert: (#(2) forwardIterator inject: 1 into: [ :a :b | a - b ]) = -1. self assert: (#(2) backwardIterator inject: 1 into: [ :a :b | a - b ]) = -1. self assert: (#(3 4) forwardIterator inject: 1 into: [ :a :b | a - b ]) = -6. self assert: (#(3 4) backwardIterator inject: 1 into: [ :a :b | a - b ]) = -6. self assert: (#(4 5 6) forwardIterator inject: 1 into: [ :a :b | a - b ]) = -14. self assert: (#(4 5 6) backwardIterator inject: 1 into: [ :a :b | a - b ]) = -14. self assert: (#(5 6 7 8) forwardIterator inject: 1 into: [ :a :b | a - b ]) = -25. self assert: (#(5 6 7 8) backwardIterator inject: 1 into: [ :a :b | a - b ]) = -25! ! !CTIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 1/10/2012 22:33'! testLimit self assertIterable: (#() iterator limit: 0) equals: #(). self assertIterable: (#(1) iterator limit: 0) equals: #(). self assertIterable: (#(1 2) iterator limit: 0) equals: #(). self assertIterable: (#(1 2 3) iterator limit: 0) equals: #(). self assertIterable: (#() iterator limit: 1) equals: #(). self assertIterable: (#(1) iterator limit: 1) equals: #(1). self assertIterable: (#(1 2) iterator limit: 1) equals: #(1). self assertIterable: (#(1 2 3) iterator limit: 1) equals: #(1). self assertIterable: (#() iterator limit: 2) equals: #(). self assertIterable: (#(1) iterator limit: 2) equals: #(1). self assertIterable: (#(1 2) iterator limit: 2) equals: #(1 2). self assertIterable: (#(1 2 3) iterator limit: 2) equals: #(1 2). self assertIterable: (#() iterator limit: 3) equals: #(). self assertIterable: (#(1) iterator limit: 3) equals: #(1). self assertIterable: (#(1 2) iterator limit: 3) equals: #(1 2). self assertIterable: (#(1 2 3) iterator limit: 3) equals: #(1 2 3). self assertIterable: (#() iterator limit: 4) equals: #(). self assertIterable: (#(1) iterator limit: 4) equals: #(1). self assertIterable: (#(1 2) iterator limit: 4) equals: #(1 2). self assertIterable: (#(1 2 3) iterator limit: 4) equals: #(1 2 3)! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/13/2012 11:04'! testNoneSatisfy self assert: (#() forwardIterator noneSatisfy: [ :each | each > 2 ]). self assert: (#() backwardIterator noneSatisfy: [ :each | each > 2 ]). self deny: (#(3) forwardIterator noneSatisfy: [ :each | each > 2 ]). self deny: (#(3) backwardIterator noneSatisfy: [ :each | each > 2 ]). self assert: (#(1) forwardIterator noneSatisfy: [ :each | each > 2 ]). self assert: (#(1) backwardIterator noneSatisfy: [ :each | each > 2 ]). self deny: (#(1 2 3) forwardIterator noneSatisfy: [ :each | each > 2 ]). self deny: (#(1 2 3) backwardIterator noneSatisfy: [ :each | each > 2 ]). self assert: (#(0 1 2) forwardIterator noneSatisfy: [ :each | each > 2 ]). self assert: (#(0 1 2) backwardIterator noneSatisfy: [ :each | each > 2 ])! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/13/2012 11:04'! testReduce self should: [ #() forwardIterator reduce: [ :a :b | a - b ] ] raise: CTNoSuchElementError. self should: [ #() backwardIterator reduce: [ :a :b | a - b ] ] raise: CTNoSuchElementError. self assert: (#(2) forwardIterator reduce: [ :a :b | a - b ]) = 2. self assert: (#(2) backwardIterator reduce: [ :a :b | a - b ]) = 2. self assert: (#(3 4) forwardIterator reduce: [ :a :b | a - b ]) = -1. self assert: (#(3 4) backwardIterator reduce: [ :a :b | a - b ]) = 1. self assert: (#(4 5 6) forwardIterator reduce: [ :a :b | a - b ]) = -7. self assert: (#(4 5 6) backwardIterator reduce: [ :a :b | a - b ]) = -3. self assert: (#(5 6 7 8) forwardIterator reduce: [ :a :b | a - b ]) = -16. self assert: (#(5 6 7 8) backwardIterator reduce: [ :a :b | a - b ]) = -10! ! !CTIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 1/10/2012 22:32'! testReject self assertIterable: (#() iterator reject: [ :each | each even ]) equals: #(). self assertIterable: (#(1) iterator reject: [ :each | each even ]) equals: #(1). self assertIterable: (#(1 3) iterator reject: [ :each | each even ]) equals: #(1 3). self assertIterable: (#(1 3 5) iterator reject: [ :each | each even ]) equals: #(1 3 5). self assertIterable: (#(2) iterator reject: [ :each | each even ]) equals: #(). self assertIterable: (#(2 4) iterator reject: [ :each | each even ]) equals: #(). self assertIterable: (#(2 4 6) iterator reject: [ :each | each even ]) equals: #(). self assertIterable: (#(1 2 3 4 5 6) iterator reject: [ :each | each even ]) equals: #(1 3 5). self assertIterable: (#(1 3 5 2 4 6) iterator reject: [ :each | each even ]) equals: #(1 3 5). self assertIterable: (#(2 4 6 1 3 5) iterator reject: [ :each | each even ]) equals: #(1 3 5)! ! !CTIteratorTest methodsFor: 'tests-modifications' stamp: 'lr 1/20/2012 22:16'! testRemoveFrom | collection | collection := CTArrayList new. collection add: 1; add: 2; add: 3; add: 4. #(2 4 3 1) iterator removeFrom: collection. self assert: collection isEmpty! ! !CTIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 1/10/2012 22:31'! testSelect self assertIterable: (#() iterator select: [ :each | each even ]) equals: #(). self assertIterable: (#(1) iterator select: [ :each | each even ]) equals: #(). self assertIterable: (#(1 3) iterator select: [ :each | each even ]) equals: #(). self assertIterable: (#(1 3 5) iterator select: [ :each | each even ]) equals: #(). self assertIterable: (#(2) iterator select: [ :each | each even ]) equals: #(2). self assertIterable: (#(2 4) iterator select: [ :each | each even ]) equals: #(2 4). self assertIterable: (#(2 4 6) iterator select: [ :each | each even ]) equals: #(2 4 6). self assertIterable: (#(1 2 3 4 5 6) iterator select: [ :each | each even ]) equals: #(2 4 6). self assertIterable: (#(1 3 5 2 4 6) iterator select: [ :each | each even ]) equals: #(2 4 6). self assertIterable: (#(2 4 6 1 3 5) iterator select: [ :each | each even ]) equals: #(2 4 6) ! ! !CTIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 1/1/2012 00:50'! testSize self assert: #() iterator size = 0. self assert: #(1) iterator size = 1. self assert: #(1 2) iterator size = 2. self assert: #(1 2 3) iterator size = 3! ! CTContainerTest subclass: #CTMapTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Abstract'! CTMapTest subclass: #CTHashMapTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Maps'! !CTHashMapTest methodsFor: 'accessing' stamp: 'lr 1/14/2012 11:28'! mapClass ^ CTHashMap! ! CTHashMapTest subclass: #CTLinkedHashMapTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Maps'! !CTLinkedHashMapTest methodsFor: 'accessing' stamp: 'lr 1/14/2012 11:28'! mapClass ^ CTLinkedHashMap! ! !CTLinkedHashMapTest methodsFor: 'testing' stamp: 'lr 1/14/2012 13:33'! testAddInOrder | map | map := self emptyMap. map at: $l put: 1; at: $u put: 2; at: $k put: 3; at: $a put: 4; at: $s put: 5. self assertIterable: map keys equals: #($l $u $k $a $s). self assertIterable: map values equals: #(1 2 3 4 5). self assertInvariants: map. map at: $k put: 6. self assertIterable: map keys equals: #($l $u $a $s $k). self assertIterable: map values equals: #(1 2 4 5 6). self assertInvariants: map. map at: $l put: 7. self assertIterable: map keys equals: #($u $a $s $k $l). self assertIterable: map values equals: #(2 4 5 6 7). self assertInvariants: map. map at: $l put: 8. self assertIterable: map keys equals: #($u $a $s $k $l). self assertIterable: map values equals: #(2 4 5 6 8). self assertInvariants: map. map at: $x put: 9. self assertIterable: map keys equals: #($u $a $s $k $l $x). self assertIterable: map values equals: #(2 4 5 6 8 9). self assertInvariants: map! ! !CTLinkedHashMapTest methodsFor: 'testing-iterators' stamp: 'lr 1/27/2012 14:08'! testBackwardIterator | map | map := self emptyMap. map at: $l put: 1; at: $u put: 2; at: $k put: 3; at: $a put: 4; at: $s put: 5. self assertIterable: #(5 4 3 2 1) equals: (map backwardIterator collect: [ :key :value | value ])! ! !CTLinkedHashMapTest methodsFor: 'testing-iterators' stamp: 'lr 1/27/2012 14:09'! testForwardIterator | map | map := self emptyMap. map at: $l put: 1; at: $u put: 2; at: $k put: 3; at: $a put: 4; at: $s put: 5. self assertIterable: #(1 2 3 4 5) equals: (map forwardIterator collect: [ :key :value | value ])! ! !CTLinkedHashMapTest methodsFor: 'testing' stamp: 'lr 1/14/2012 13:35'! testRemoveInOrder| map | map := self emptyMap. map at: $l put: 1; at: $u put: 2; at: $k put: 3; at: $a put: 4; at: $s put: 5. self assertIterable: map keys equals: #($l $u $k $a $s). self assertIterable: map values equals: #(1 2 3 4 5). self assertInvariants: map. map removeKey: $k. self assertIterable: map keys equals: #($l $u $a $s). self assertIterable: map values equals: #(1 2 4 5). self assertInvariants: map. map removeKey: $l. self assertIterable: map keys equals: #($u $a $s). self assertIterable: map values equals: #(2 4 5). self assertInvariants: map. map removeKey: $s. self assertIterable: map keys equals: #($u $a). self assertIterable: map values equals: #(2 4). self assertInvariants: map! ! !CTMapTest class methodsFor: 'testing' stamp: 'lr 1/14/2012 11:14'! isAbstract ^ self name = #CTMapTest! ! !CTMapTest methodsFor: 'accessing' stamp: 'lr 1/14/2012 11:26'! emptyMap ^ self mapClass new! ! !CTMapTest methodsFor: 'accessing' stamp: 'lr 1/14/2012 11:26'! mapClass ^ CTMap! ! !CTMapTest methodsFor: 'tests-accessing' stamp: 'lr 1/14/2012 11:32'! testAt | map | map := self emptyMap. map at: $a put: $b; at: $c put: $d; at: $e put: $f. self assert: (map at: $a) = $b. self assert: (map at: $c) = $d. self assert: (map at: $e) = $f. self should: [ map at: $b ] raise: CTKeyNotFoundError ! ! !CTMapTest methodsFor: 'tests-accessing' stamp: 'lr 1/14/2012 11:33'! testAtIfAbsent | map | map := self emptyMap. map at: $a put: $b; at: $c put: $d; at: $e put: $f. self assert: (map at: $a ifAbsent: [ $x ]) = $b. self assert: (map at: $c ifAbsent: [ $x ]) = $d. self assert: (map at: $e ifAbsent: [ $x ]) = $f. self assert: (map at: $b ifAbsent: [ $x ]) = $x! ! !CTMapTest methodsFor: 'tests-accessing' stamp: 'lr 1/14/2012 11:34'! testAtIfPresent | map | map := self emptyMap. map at: $a put: $b; at: $c put: $d; at: $e put: $f. self assert: (map at: $a ifPresent: [ :v | v asUppercase ]) = $B. self assert: (map at: $c ifPresent: [ :v | v asUppercase ]) = $D. self assert: (map at: $e ifPresent: [ :v | v asUppercase ]) = $F. self assert: (map at: $b ifPresent: [ :v | v asUppercase ]) isNil! ! !CTMapTest methodsFor: 'tests-accessing' stamp: 'lr 1/14/2012 11:41'! testAtPut | map | map := self emptyMap. self assert: (map at: $a put: $b) = $b. self assert: (map at: $c put: $d) = $d. self assert: (map at: $e put: $f) = $f. self assert: (map at: $a put: $x) = $x. self assert: (map at: $a) = $x. self assertInvariants: map! ! !CTMapTest methodsFor: 'tests-copying' stamp: 'lr 1/14/2012 12:07'! testCopyEmpty | old new | old := self emptyMap. new := old copy. self deny: old == new. self assertInvariants: old. self assertInvariants: new. old at: $a put: $b. new at: $c put: $d. self assert: old size = 1. self assert: new size = 1. self assert: old keys next = $a. self assert: new keys next = $c. self assert: old values next = $b. self assert: new values next = $d! ! !CTMapTest methodsFor: 'tests-copying' stamp: 'lr 1/25/2012 23:00'! testCopyMany | old new | old := self emptyMap. 1 to: 100 do: [ :index | old at: index put: 2 * index ]. new := old copy. self deny: old == new. self assertInvariants: old. self assertInvariants: new. 1 to: 100 do: [ :index | self assert: (old at: index) = (2 * index). self assert: (new at: index) = (2 * index) ]. old at: 101 put: 202. new at: 102 put: 204. self assert: old size = 101. self assert: new size = 101. self assert: (old at: 101) = 202. self assert: (new at: 102) = 204. self deny: (old includesKey: 102). self deny: (new includesKey: 101)! ! !CTMapTest methodsFor: 'tests-iterating' stamp: 'pmm 2/6/2012 20:44'! testInjectInto | map | map := self emptyMap. map at: 1 put: 10; at: 2 put: 20; at: 3 put: 30. self assert: (map iterator inject: 0 into: [ :result :key :value | result + key + value ]) = 66! ! !CTMapTest methodsFor: 'tests-testing' stamp: 'lr 1/14/2012 11:31'! testIsEmpty | map | map := self emptyMap. self assert: map isEmpty. map at: $a put: $b. self deny: map isEmpty! ! !CTMapTest methodsFor: 'tests-iterating' stamp: 'lr 1/25/2012 22:48'! testIterator | map keys values | map := self emptyMap. map at: $a put: $b; at: $c put: $d; at: $e put: $f. values := CTArrayList new. map iterator do: [ :value | values add: value ]. self assert: values size = 3. self assert: (values iterator includes: $b). self assert: (values iterator includes: $d). self assert: (values iterator includes: $f). keys := CTArrayList new. values := CTArrayList new. map iterator do: [ :key :value | keys add: key. values add: value ]. self assert: keys size = 3. self assert: (keys iterator includes: $a). self assert: (keys iterator includes: $c). self assert: (keys iterator includes: $e). self assert: values size = 3. self assert: (values iterator includes: $b). self assert: (values iterator includes: $d). self assert: (values iterator includes: $f).! ! !CTMapTest methodsFor: 'tests-exceptions' stamp: 'lr 1/27/2012 22:05'! testKeyNotFound [ self emptyMap at: $b ] on: CTKeyNotFoundError do: [ :exception | self assert: exception key = $b. ^ self ]. self fail! ! !CTMapTest methodsFor: 'tests-instantiation' stamp: 'lr 1/26/2012 10:26'! testKeyValue1 | map | map := self mapClass key: 1 value: 2. self assertInvariants: map. self assert: (map size = 1). self assert: (map at: 1) = 2! ! !CTMapTest methodsFor: 'tests-instantiation' stamp: 'lr 1/26/2012 10:27'! testKeyValue2 | map | map := self mapClass key: 1 value: 2 key: 3 value: 4. self assertInvariants: map. self assert: (map size = 2). self assert: (map at: 1) = 2. self assert: (map at: 3) = 4! ! !CTMapTest methodsFor: 'tests-instantiation' stamp: 'lr 1/26/2012 10:26'! testKeyValue3 | map | map := self mapClass key: 1 value: 2 key: 3 value: 4 key: 5 value: 6. self assertInvariants: map. self assert: (map size = 3). self assert: (map at: 1) = 2. self assert: (map at: 3) = 4. self assert: (map at: 5) = 6! ! !CTMapTest methodsFor: 'tests-instantiation' stamp: 'lr 1/26/2012 10:27'! testKeyValue4 | map | map := self mapClass key: 1 value: 2 key: 3 value: 4 key: 5 value: 6 key: 7 value: 8. self assertInvariants: map. self assert: (map size = 4). self assert: (map at: 1) = 2. self assert: (map at: 3) = 4. self assert: (map at: 5) = 6. self assert: (map at: 7) = 8! ! !CTMapTest methodsFor: 'tests-iterating' stamp: 'lr 1/20/2012 22:16'! testKeys | map keys | map := self emptyMap. map at: $a put: $b; at: $c put: $d; at: $e put: $f. keys := CTArrayList new. map keys do: [ :key | keys add: key ]. self assert: keys size = 3. self assert: (keys iterator includes: $a). self assert: (keys iterator includes: $c). self assert: (keys iterator includes: $e)! ! !CTMapTest methodsFor: 'tests-instantiation' stamp: 'lr 1/26/2012 10:31'! testNew1 | map | map := self mapClass new. self assert: map isEmpty! ! !CTMapTest methodsFor: 'tests-instantiation' stamp: 'lr 1/26/2012 10:31'! testNew2 | map | map := self mapClass new: 100. self assertInvariants: map. self assert: map isEmpty! ! !CTMapTest methodsFor: 'tests' stamp: 'lr 1/28/2012 16:36'! testPrinting | map | map := self emptyMap. self assert: map printString isString. map at: $a put: $b; at: $c put: $d; at: $e put: $f. self assert: map printString isString! ! !CTMapTest methodsFor: 'tests-removing' stamp: 'lr 1/14/2012 11:43'! testRemoveAll | map | map := self emptyMap. map at: $a put: $b; at: $c put: $d; at: $e put: $f. map removeAll. self assert: map isEmpty. self assertInvariants: map! ! !CTMapTest methodsFor: 'tests-removing' stamp: 'lr 1/14/2012 11:42'! testRemoveKey | map | map := self emptyMap. map at: $a put: $b; at: $c put: $d; at: $e put: $f. self should: [ map removeKey: $x ] raise: CTKeyNotFoundError. self assert: (map removeKey: $a) = $b. self assert: map size = 2. self assertInvariants: map! ! !CTMapTest methodsFor: 'tests-removing' stamp: 'lr 1/14/2012 11:43'! testRemoveKeyIfAbsent | map | map := self emptyMap. map at: $a put: $b; at: $c put: $d; at: $e put: $f. self assert: (map removeKey: $x ifAbsent: [ $y ]) = $y. self assert: (map removeKey: $a) = $b. self assert: map size = 2. self assertInvariants: map! ! !CTMapTest methodsFor: 'tests-accessing' stamp: 'lr 1/14/2012 11:38'! testSize | map | map := self emptyMap. self assert: map size = 0. map at: $a put: $b. self assert: map size = 1. map at: $c put: $d. self assert: map size = 2. map at: $a put: $x. self assert: map size = 2! ! !CTMapTest methodsFor: 'tests-iterating' stamp: 'lr 1/20/2012 22:16'! testValues | map values | map := self emptyMap. map at: $a put: $b; at: $c put: $d; at: $e put: $f. values := CTArrayList new. map values do: [ :value | values add: value ]. self assert: values size = 3. self assert: (values iterator includes: $b). self assert: (values iterator includes: $d). self assert: (values iterator includes: $f)! ! !CTMapTest methodsFor: 'tests-instantiation' stamp: 'lr 1/25/2012 22:52'! testWithAll | old new | old := self emptyMap. 1 to: 100 do: [ :index | old at: index put: 2 * index ]. new := self mapClass withAll: old. self deny: old == new. self assertInvariants: old. self assertInvariants: new. 1 to: 100 do: [ :index | self assert: (old at: index) = (2 * index). self assert: (new at: index) = (2 * index) ]. old at: 101 put: 202. new at: 102 put: 204. self assert: old size = 101. self assert: new size = 101. self assert: (old at: 101) = 202. self assert: (new at: 102) = 204. self deny: (old includesKey: 102). self deny: (new includesKey: 101)! ! !CTMapTest methodsFor: 'tests' stamp: 'lr 1/28/2012 16:38'! testWorkflow | map | map := self mapClass new. self assertInvariants: map. self assert: map isEmpty. (self randomSequence: self workflowSize) do: [ :each | map at: each put: each ]. self assertInvariants: map. self assert: map size = self workflowSize. 1 to: self workflowSize do: [ :each | self assert: (map includesKey: each) ]. (self randomSequence: self workflowSize) do: [ :each | map at: each put: each ]. self assertInvariants: map. self assert: map size = self workflowSize. 1 to: self workflowSize do: [ :each | self assert: (map includesKey: each) ]. (self randomSequence: self workflowSize) do: [ :each | map removeKey: each ]. self assertInvariants: map. self assert: map isEmpty! ! !CTMapTest methodsFor: 'tests' stamp: 'lr 1/28/2012 16:41'! workflowSize ^ 100000! ! CTMapTest subclass: #CTTreeMapTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Maps'! !CTTreeMapTest methodsFor: 'accessing' stamp: 'lr 1/24/2012 20:45'! mapClass ^ CTTreeMap! ! !CTTreeMapTest methodsFor: 'testing-iterators' stamp: 'lr 1/27/2012 14:08'! testBackwardIterator | map | map := self emptyMap. map at: $l put: 1; at: $u put: 2; at: $k put: 3; at: $a put: 4; at: $s put: 5. self assertIterable: #(2 5 1 3 4) equals: (map backwardIterator collect: [ :key :value | value ])! ! !CTTreeMapTest methodsFor: 'testing-iterators' stamp: 'lr 1/27/2012 14:09'! testForwardIterator | map | map := self emptyMap. map at: $l put: 1; at: $u put: 2; at: $k put: 3; at: $a put: 4; at: $s put: 5. self assertIterable: #(4 3 1 5 2) equals: (map forwardIterator collect: [ :key :value | value ])! ! !CTFingerTree methodsFor: '*container-tests-core' stamp: 'lr 2/4/2012 19:32'! assertInvariants: anAsserter self assertInvariants: anAsserter inner: false! ! !CTFingerTree methodsFor: '*container-tests-core' stamp: 'lr 2/4/2012 19:31'! assertInvariants: anAsserter inner: aBoolean! ! !CTSplayTreeNode methodsFor: '*container-tests-core' stamp: 'lr 1/25/2012 19:22'! assertInvariants: anAsserter comparator: aComparator self left isNil ifFalse: [ anAsserter assert: (aComparator less: self left key than: self key). self left assertInvariants: anAsserter comparator: aComparator ]. self right isNil ifFalse: [ anAsserter assert: (aComparator less: self key than: self right key). self right assertInvariants: anAsserter comparator: aComparator ]! ! !CTLinkedHashMap methodsFor: '*container-tests-core' stamp: 'lr 1/14/2012 11:19'! assertInvariants: anAsserter super assertInvariants: anAsserter. root assertInvariants: anAsserter. self assert: table size = root forwardIterator size! ! !CTComparator methodsFor: '*container-tests-core' stamp: 'lr 1/24/2012 19:29'! assertInvariants: anAsserter self assert: self printString isString! ! !CTPriorityQueue methodsFor: '*container-tests-core' stamp: 'lr 1/26/2012 19:17'! assertInvariants: anAsserter | left right | super assertInvariants: anAsserter. 1 to: size // 2 do: [ :index | (left := 2 * index) <= size ifTrue: [ self assert: (comparator less: (array at: index) than: (array at: left)). (right := left + 1) <= size ifTrue: [ self assert: (comparator less: (array at: index) than: (array at: right)) ] ] ]. size + 1 to: array size do: [ :index | self assert: (array at: index) isNil ] ! ! !CTHashSet methodsFor: '*container-tests-core' stamp: 'lr 1/13/2012 23:57'! assertInvariants: anAsserter super assertInvariants: anAsserter. table assertInvariants: anAsserter! !