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! ! !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)! ! !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! ! !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 ]! ! !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/4/2012 19:33'! assertInvariants: anAsserter inner: aBoolean super assertInvariants: anAsserter inner: aBoolean. anAsserter assert: (prefix size between: 1 and: 4). aBoolean ifTrue: [ self assertInvariants: anAsserter nodes: prefix ]. tree assertInvariants: anAsserter inner: true. anAsserter assert: (suffix size between: 1 and: 4). aBoolean ifTrue: [ self assertInvariants: anAsserter nodes: suffix ]! ! !CTDeepFingerTree methodsFor: '*container-tests-core' stamp: 'lr 2/4/2012 19:35'! assertInvariants: anAsserter nodes: anArray anArray do: [ :each | each isArray ifTrue: [ anAsserter assert: (each size between: 2 and: 3). self assertInvariants: anAsserter nodes: each ] ]! ! !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 1/28/2012 13:19'! collectionWithRandomElements: anInteger | collection | collection := self collectionClass new: anInteger. collection addAll: (self randomSequence: anInteger). ^ collection! ! !CTCollectionTest methodsFor: 'accessing' stamp: 'lr 1/11/2012 22:44'! emptyCollection ^ self collectionClass new! ! !CTCollectionTest methodsFor: 'tests-copying' stamp: 'lr 1/13/2012 12:06'! 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 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 1/25/2012 22:59'! 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 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! ! 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 1/11/2012 22:44'! testFirst | collection | collection := self emptyCollection. self should: [ self emptyCollection last ] raise: CTNoSuchElementError. 10 to: 20 do: [ :index | collection addFirst: index. self assert: collection first = index ]! ! !CTListTest methodsFor: 'tests-iterators' stamp: 'lr 1/13/2012 11:40'! testForwardIterator | collection | collection := self collectionWithAll: #($a $b $c). self assertIterable: #($a $b $c) equals: collection forwardIterator! ! !CTListTest methodsFor: 'tests-iterators' stamp: 'lr 1/13/2012 11:41'! testForwardIteratorEmpty | collection | collection := self collectionWithAll: #(). self assertIterable: #() equals: collection forwardIterator! ! !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 1/11/2012 22:44'! testLast | collection | collection := self emptyCollection. self should: [ self emptyCollection last ] raise: CTNoSuchElementError. 10 to: 20 do: [ :index | collection addLast: index. self assert: collection last = index ]! ! !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 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 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: 'utilies' 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: 'lr 1/26/2012 16:10'! testIdentityInequality | comparator object | 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-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: 'lr 1/26/2012 16:13'! testNaturalHash | comparator object | comparator := CTNaturalComparator new. self assert: (comparator hashOf: 'foo') = (comparator hashOf: 'foo'). self assert: (comparator hashOf: 'foo') = 'foo' hash! ! !CTComparatorTest methodsFor: 'tests' stamp: 'lr 1/26/2012 16:14'! testNaturalInequality | comparator object | 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/4/2012 15:53'! 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/4/2012 15:53'! 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: 'lr 2/4/2012 19:22'! testAllButFirst | tree strings | 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: 'lr 2/4/2012 19:22'! testAllButLast | tree strings | 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: 'lr 2/4/2012 15:39'! testFirst | tree strings | 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: 'lr 2/4/2012 15:39'! testLast | tree strings | 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: 'lr 1/10/2012 22:30'! testArrayIteratorForwardDo | letters expected | letters := #($a $b $c $d). 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: 'lr 1/13/2012 10:59'! testArrayIteratorReverseDo | letters expected | letters := #($a $b $c $d). 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: 'lr 1/14/2012 13:38'! testInjectInto | map values | 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! !