SystemOrganization addCategory: #'Container-Tests-Core'! SystemOrganization addCategory: #'Container-Tests-Core-Iterators'! SystemOrganization addCategory: #'Container-Tests-Core-Comparators'! 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! ! !CTSubList methodsFor: '*container-tests-core' stamp: 'lr 4/22/2012 10:32'! assertInvariants: anAsserter super assertInvariants: anAsserter. self isEmpty ifTrue: [ ^ self ]. delegate at: firstIndex ifAbsent: [ anAsserter fail ]. delegate at: lastIndex ifAbsent: [ anAsserter fail ]! ! !CTLinkedHashSet methodsFor: '*container-tests-core' stamp: 'lr 4/21/2012 09:20'! assertInvariants: anAsserter super assertInvariants: anAsserter. root assertInvariants: anAsserter. self assert: table size = root iterator size! ! !CTDelegateList methodsFor: '*container-tests-core' stamp: 'lr 4/21/2012 14:17'! assertInvariants: anAsserter super assertInvariants: anAsserter. delegate assertInvariants: anAsserter! ! !CTLinkedList methodsFor: '*container-tests-core' stamp: 'lr 1/13/2012 11:08'! assertInvariants: anAsserter super assertInvariants: anAsserter. root assertInvariants: anAsserter! ! !CTDelegateSet methodsFor: '*container-tests-core' stamp: 'lr 4/22/2012 10:29'! assertInvariants: anAsserter super assertInvariants: anAsserter. delegate 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 4/21/2012 09:21'! assertInvariants: anAsserter self assertInvariants: anAsserter forNode: self. self iterator do: [ :node | self assertInvariants: anAsserter forNode: node ]. self iterator 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! ! !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 ]! ! !CTContainer methodsFor: '*container-tests-core' stamp: 'lr 4/22/2012 10:49'! assertInvariants: anAsserter "Asserts the internal invariants of this container." anAsserter assert: self size = self iterator size description: 'Container and iterator are not of equal size'! ! !CTArrayList methodsFor: '*container-tests-core' stamp: 'lr 4/21/2012 09:51'! assertInvariants: anAsserter super assertInvariants: anAsserter. 1 to: firstIndex - 1 do: [ :index | anAsserter assert: (array at: index) isNil description: 'Element slots smaller than firstIndex must be nil' ]. lastIndex + 1 to: array size do: [ :index | anAsserter assert: (array at: index) isNil description: 'Element slots larger than lastIndex must be nil' ]! ! !CTHashMap methodsFor: '*container-tests-core' stamp: 'lr 1/14/2012 10:28'! assertInvariants: anAsserter super assertInvariants: anAsserter. table assertInvariants: anAsserter! ! !CTRedBlackTreeNode methodsFor: '*container-tests-core' stamp: 'lr 3/31/2012 15:18'! assertInvariants: anAsserter owner: aTree comparator: aComparator black: anInteger | black | black := self red ifTrue: [ anInteger ] ifFalse: [ anInteger - 1 ]. self left isNil ifFalse: [ anAsserter assert: (aComparator less: self left key than: self key) description: 'Left node must be smaller than its parent'. self left assertInvariants: anAsserter owner: aTree comparator: aComparator black: black ]. self right isNil ifFalse: [ anAsserter assert: (aComparator less: self key than: self right key) description: 'Right node must be larger than its parent'. self right assertInvariants: anAsserter owner: aTree comparator: aComparator black: black ]. (self left isNil or: [ self right isNil ]) ifTrue: [ anAsserter assert: black = 0 description: 'Every path to a leaf must have the same number of black links' ]. anAsserter deny: (aTree isRed: self right) description: 'No red links to the right'. anAsserter deny: (self red and: [ (aTree isRed: self left) and: [ aTree isRed: self left left ] ]) description: 'At most two red links to the left'! ! !CTRedBlackTree class methodsFor: '*container-tests-core' stamp: 'lr 4/22/2012 10:34'! stress | tree asserter | tree := CTTreeSet new. asserter := TestAsserter new. [ (1 to: 10000) asArray shuffled do: [ :each | tree add: each. each \\ 100 = 0 ifTrue: [ tree assertInvariants: asserter ] ]. tree assertInvariants: asserter. asserter assert: (tree size = 10000). asserter assert: (tree includesAll: (1 to: 10000) asArray shuffled). (1 to: 10000) asArray shuffled do: [ :each | tree remove: each. each \\ 100 = 0 ifTrue: [ tree assertInvariants: asserter ] ]. tree assertInvariants: asserter. asserter assert: tree isEmpty ] repeat! ! !CTRedBlackTree methodsFor: '*container-tests-core' stamp: 'lr 3/31/2012 15:13'! assertInvariants: anAsserter | black current | anAsserter deny: (self isRed: root) description: 'The root node must be black'. root isNil ifTrue: [ ^ anAsserter assert: size = 0 ]. black := 0. current := root. [ current isNil ] whileFalse: [ (self isRed: current) ifFalse: [ black := black + 1 ]. current := current left ]. root assertInvariants: anAsserter owner: self comparator: comparator black: black! ! TestCase subclass: #CTContainerTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core'! CTContainerTest subclass: #CTCollectionTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core'! !CTCollectionTest class methodsFor: 'testing' stamp: 'lr 8/7/2011 19:59'! isAbstract ^ self name = #CTCollectionTest! ! !CTCollectionTest methodsFor: 'accessing' stamp: 'lr 4/5/2012 11:00'! collectionClass self subclassResponsibility! ! !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-testing' stamp: 'lr 4/5/2012 11:48'! testNotEmpty self deny: (self collectionWithAll: #()) notEmpty. self assert: (self collectionWithAll: #($a)) notEmpty. self assert: (self collectionWithAll: #($a $b)) notEmpty! ! !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 4/5/2012 11:17'! testWithAll | old new | old := self collectionWithRandomElements: 100. new := self collectionWithAll: old. self deny: old == new. self assertIterable: old equals: new. self assertInvariants: old. self assertInvariants: new. [ old add: 101 ] on: CTUnsupportedOperationError do: [ :error | ^ self ]. [ new add: 102 ] on: CTUnsupportedOperationError do: [ :error | ^ self ]. 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 4/5/2012 11:06'! testWorkflow | collection | collection := self collectionWithAll: #(). 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: 'accessing' stamp: 'lr 1/28/2012 16:42'! workflowSize ^ 1000! ! CTCollectionTest subclass: #CTListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core'! 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: #CTConstructorListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! !CTConstructorListTest class methodsFor: 'testing' stamp: 'lr 2/6/2012 20:45'! shouldInheritSelectors ^ false! ! !CTConstructorListTest methodsFor: 'accessing' stamp: 'lr 2/6/2012 20:47'! collectionClass ^ CTImmutableList! ! !CTConstructorListTest methodsFor: 'tests-adding' stamp: 'lr 2/6/2012 20:50'! testAdd self should: [ super testAdd ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-adding' stamp: 'lr 2/6/2012 20:50'! testAddAt self should: [ super testAddAt ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-adding' stamp: 'lr 2/6/2012 20:50'! testAddFirst self should: [ super testAddFirst ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-adding' stamp: 'lr 2/6/2012 20:50'! testAddLast self should: [ super testAddLast ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 20:46'! testAt super testAt! ! !CTConstructorListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 20:46'! testAtIfAbsent super testAtIfAbsent! ! !CTConstructorListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 20:49'! testAtPut self should: [ super testAtPut ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-copying' stamp: 'lr 2/12/2012 15:20'! testCopy | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable copy == immutable! ! !CTConstructorListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 20:46'! testFirst super testFirst! ! !CTConstructorListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 23:18'! testImmutable | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable immutable == immutable! ! !CTConstructorListTest methodsFor: 'tests-exceptions' stamp: 'lr 4/5/2012 11:57'! testIndexOutOfBounds super testIndexOutOfBounds! ! !CTConstructorListTest methodsFor: 'tests-testing' stamp: 'lr 4/5/2012 11:57'! testIsEmpty super testIsEmpty! ! !CTConstructorListTest methodsFor: 'tests-iterators' stamp: 'lr 4/21/2012 10:53'! testIterator super testIterator! ! !CTConstructorListTest methodsFor: 'tests-iterators' stamp: 'lr 4/21/2012 10:53'! testIteratorEmpty super testIteratorEmpty! ! !CTConstructorListTest methodsFor: 'tests-iterators' stamp: 'lr 4/21/2012 10:53'! testIteratorIndexed super testIteratorIndexed! ! !CTConstructorListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 20:46'! testLast super testLast! ! !CTConstructorListTest methodsFor: 'tests-instantiation' stamp: 'lr 2/6/2012 22:41'! testNew1 super testNew1! ! !CTConstructorListTest methodsFor: 'tests-testing' stamp: 'lr 4/5/2012 11:57'! testNotEmpty super testNotEmpty! ! !CTConstructorListTest methodsFor: 'tests' stamp: 'lr 4/5/2012 11:56'! testPrinting super testPrinting! ! !CTConstructorListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:36'! testRemove self should: [ super testRemove ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:36'! testRemoveAll self should: [ super testRemoveAll ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:36'! testRemoveAt self should: [ super testRemoveAt ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:36'! testRemoveAtIfAbsent self should: [ super testRemoveAtIfAbsent ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:36'! testRemoveFirst self should: [ super testRemoveFirst ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:36'! testRemoveIfAbsent self should: [ super testRemoveIfAbsent ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-removing' stamp: 'lr 2/6/2012 22:36'! testRemoveLast self should: [ super testRemoveLast ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-accessing' stamp: 'lr 4/21/2012 23:55'! testReversed super testReversed! ! !CTConstructorListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 22:38'! testSize super testSize! ! !CTConstructorListTest methodsFor: 'tests-sorting' stamp: 'lr 4/5/2012 11:57'! testSortDefault self should: [ super testSortDefault ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-sorting' stamp: 'lr 4/5/2012 11:57'! testSortEmpty self should: [ super testSortEmpty ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-sorting' stamp: 'lr 4/5/2012 11:57'! testSortOrder self should: [ super testSortOrder ] raise: CTUnsupportedOperationError! ! !CTConstructorListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 23:18'! testUnmodifiable | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable unmodifiable == immutable! ! !CTConstructorListTest methodsFor: 'tests-instantiation' stamp: 'lr 2/6/2012 22:41'! testWith1 super testWith1! ! !CTConstructorListTest methodsFor: 'tests-instantiation' stamp: 'lr 2/6/2012 22:41'! testWith2 super testWith2! ! !CTConstructorListTest methodsFor: 'tests-instantiation' stamp: 'lr 2/6/2012 22:41'! testWith3 super testWith3! ! !CTConstructorListTest methodsFor: 'tests-instantiation' stamp: 'lr 2/6/2012 22:41'! testWith4 super testWith4! ! CTListTest subclass: #CTDelegateListTest instanceVariableNames: 'collectionClass' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! !CTDelegateListTest methodsFor: 'accessing' stamp: 'lr 4/5/2012 11:22'! collectionClass ^ collectionClass! ! !CTDelegateListTest methodsFor: 'accessing' stamp: 'lr 4/21/2012 10:59'! collectionClasses ^ Array with: CTArrayList with: CTLinkedList with: CTVectorList! ! !CTDelegateListTest methodsFor: 'accessing' stamp: 'lr 4/21/2012 23:28'! collectionWithAll: aCollection ^ CTDelegateList on: (self collectionClass withAll: aCollection)! ! !CTDelegateListTest methodsFor: 'running' stamp: 'lr 4/21/2012 11:05'! runCase self collectionClasses do: [ :class | collectionClass := class. super runCase ]! ! CTDelegateListTest subclass: #CTImmutableListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! !CTImmutableListTest class methodsFor: 'testing' stamp: 'lr 4/5/2012 12:04'! shouldInheritSelectors ^ false! ! !CTImmutableListTest methodsFor: 'accessing' stamp: 'lr 4/21/2012 23:28'! collectionWithAll: aCollection ^ (self collectionClass withAll: aCollection) immutable! ! !CTImmutableListTest methodsFor: 'tests-adding' stamp: 'lr 4/5/2012 12:04'! testAdd self should: [ super testAdd ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-adding' stamp: 'lr 4/5/2012 12:04'! testAddAt self should: [ super testAddAt ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-adding' stamp: 'lr 4/5/2012 12:04'! testAddFirst self should: [ super testAddFirst ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-adding' stamp: 'lr 4/5/2012 12:04'! testAddLast self should: [ super testAddLast ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 4/5/2012 12:04'! testAt super testAt! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 4/5/2012 12:04'! testAtIfAbsent super testAtIfAbsent! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 4/5/2012 12:04'! testAtPut self should: [ super testAtPut ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-copying' stamp: 'lr 4/5/2012 12:05'! testCopy | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable copy == immutable! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 4/5/2012 12:04'! testFirst super testFirst! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 4/5/2012 12:05'! testImmutable | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable immutable == immutable! ! !CTImmutableListTest methodsFor: 'tests-exceptions' stamp: 'lr 4/5/2012 12:05'! testIndexOutOfBounds super testIndexOutOfBounds! ! !CTImmutableListTest methodsFor: 'tests-testing' stamp: 'lr 4/5/2012 12:05'! testIsEmpty super testIsEmpty! ! !CTImmutableListTest methodsFor: 'tests-iterators' stamp: 'lr 4/21/2012 10:54'! testIterator super testIterator! ! !CTImmutableListTest methodsFor: 'tests-iterators' stamp: 'lr 4/5/2012 12:05'! testIteratorCopy super testIteratorCopy! ! !CTImmutableListTest methodsFor: 'tests-iterators' stamp: 'lr 4/21/2012 10:54'! testIteratorEmpty super testIteratorEmpty! ! !CTImmutableListTest methodsFor: 'tests-iterators' stamp: 'lr 4/21/2012 10:54'! testIteratorIndexed super testIteratorIndexed! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 4/5/2012 12:04'! testLast super testLast! ! !CTImmutableListTest methodsFor: 'tests-testing' stamp: 'lr 4/5/2012 12:05'! testNotEmpty super testNotEmpty! ! !CTImmutableListTest methodsFor: 'tests' stamp: 'lr 4/5/2012 12:04'! testPrinting super testPrinting! ! !CTImmutableListTest methodsFor: 'tests-removing' stamp: 'lr 4/5/2012 12:05'! testRemove self should: [ super testRemove ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-removing' stamp: 'lr 4/5/2012 12:05'! testRemoveAll self should: [ super testRemoveAll ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-removing' stamp: 'lr 4/5/2012 12:05'! testRemoveAt self should: [ super testRemoveAt ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-removing' stamp: 'lr 4/5/2012 12:05'! testRemoveAtIfAbsent self should: [ super testRemoveAtIfAbsent ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-removing' stamp: 'lr 4/5/2012 12:05'! testRemoveFirst self should: [ super testRemoveFirst ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-removing' stamp: 'lr 4/5/2012 12:05'! testRemoveIfAbsent self should: [ super testRemoveIfAbsent ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-removing' stamp: 'lr 4/5/2012 12:05'! testRemoveLast self should: [ super testRemoveLast ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 4/21/2012 23:54'! testReversed super testReversed! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 4/5/2012 12:04'! testSize super testSize! ! !CTImmutableListTest methodsFor: 'tests-sorting' stamp: 'lr 4/5/2012 12:05'! testSortDefault self should: [ super testSortDefault ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-sorting' stamp: 'lr 4/5/2012 12:05'! testSortEmpty self should: [ super testSortEmpty ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-sorting' stamp: 'lr 4/5/2012 12:05'! testSortOrder self should: [ super testSortOrder ] raise: CTUnsupportedOperationError! ! !CTImmutableListTest methodsFor: 'tests-accessing' stamp: 'lr 4/5/2012 12:05'! testUnmodifiable | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable unmodifiable == immutable! ! CTDelegateListTest subclass: #CTReversedListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! !CTReversedListTest class methodsFor: 'testing' stamp: 'lr 4/21/2012 10:56'! shouldInheritSelectors ^ false! ! !CTReversedListTest methodsFor: 'accessing' stamp: 'lr 4/21/2012 23:27'! collectionWithAll: aCollection ^ (self collectionClass withAll: aCollection) reversed! ! !CTReversedListTest methodsFor: 'tests-adding' stamp: 'lr 4/21/2012 23:20'! testAdd super testAdd! ! !CTReversedListTest methodsFor: 'tests-adding' stamp: 'lr 4/21/2012 23:20'! testAddAt super testAddAt! ! !CTReversedListTest methodsFor: 'tests-adding' stamp: 'lr 4/21/2012 23:19'! testAddFirst super testAddFirst! ! !CTReversedListTest methodsFor: 'tests-adding' stamp: 'lr 4/21/2012 23:19'! testAddLast super testAddLast! ! !CTReversedListTest methodsFor: 'tests-accessing' stamp: 'lr 4/21/2012 23:09'! testAt | collection | collection := self collectionWithAll: #($a $b $c). self should: [ collection at: 0 ] raise: CTIndexOutOfBoundsError. self assert: (collection at: 1) = $c. self assert: (collection at: 2) = $b. self assert: (collection at: 3) = $a. self should: [ collection at: 4 ] raise: CTIndexOutOfBoundsError! ! !CTReversedListTest methodsFor: 'tests-accessing' stamp: 'lr 4/21/2012 23:10'! testAtIfAbsent | collection | collection := self collectionWithAll: #($a $b $c). self assert: (collection at: 0 ifAbsent: [ $x ]) = $x. self assert: (collection at: 1 ifAbsent: [ $x ]) = $c. self assert: (collection at: 2 ifAbsent: [ $x ]) = $b. self assert: (collection at: 3 ifAbsent: [ $x ]) = $a. self assert: (collection at: 4 ifAbsent: [ $x ]) = $x! ! !CTReversedListTest methodsFor: 'tests-accessing' stamp: 'lr 4/21/2012 23:13'! testAtPut super testAtPut! ! !CTReversedListTest methodsFor: 'tests-copying' stamp: 'lr 4/21/2012 23:07'! testCopy | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable copy == immutable! ! !CTReversedListTest methodsFor: 'tests-accessing' stamp: 'lr 4/21/2012 23:10'! testFirst | collection | collection := self collectionWithAll: #($a $b $c). self assert: collection first = $c! ! !CTReversedListTest methodsFor: 'tests-exceptions' stamp: 'lr 4/21/2012 23:07'! testIndexOutOfBounds super testIndexOutOfBounds! ! !CTReversedListTest methodsFor: 'tests-testing' stamp: 'lr 4/21/2012 23:07'! testIsEmpty super testIsEmpty! ! !CTReversedListTest methodsFor: 'tests-iterators' stamp: 'lr 4/21/2012 23:31'! testIterator | collection | collection := self collectionWithAll: #($a $b $c). self assertIterable: #($c $b $a) equals: collection! ! !CTReversedListTest methodsFor: 'tests-iterators' stamp: 'lr 4/21/2012 23:07'! testIteratorCopy super testIteratorCopy! ! !CTReversedListTest methodsFor: 'tests-iterators' stamp: 'lr 4/21/2012 23:07'! testIteratorEmpty super testIteratorEmpty! ! !CTReversedListTest methodsFor: 'tests-iterators' stamp: 'lr 4/21/2012 23:07'! testIteratorIndexed super testIteratorIndexed! ! !CTReversedListTest methodsFor: 'tests-accessing' stamp: 'lr 4/21/2012 23:13'! testLast | collection | collection := self collectionWithAll: #($a $b $c). self assert: collection last = $a! ! !CTReversedListTest methodsFor: 'tests-testing' stamp: 'lr 4/21/2012 23:07'! testNotEmpty super testNotEmpty! ! !CTReversedListTest methodsFor: 'tests' stamp: 'lr 4/21/2012 23:07'! testPrinting super testPrinting! ! !CTReversedListTest methodsFor: 'tests-removing' stamp: 'lr 4/21/2012 23:34'! testRemove super testRemove! ! !CTReversedListTest methodsFor: 'tests-removing' stamp: 'lr 4/21/2012 23:34'! testRemoveAll super testRemoveAll! ! !CTReversedListTest methodsFor: 'tests-removing' stamp: 'lr 4/21/2012 23:40'! 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) = $e. self assert: (collection removeAt: 4) = $a. self assert: (collection removeAt: 2) = $c. self assertIterable: collection equals: #($d $b)! ! !CTReversedListTest methodsFor: 'tests-removing' stamp: 'lr 4/21/2012 23:41'! 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 ]) = $e. self assert: (collection removeAt: 4 ifAbsent: [ $x ]) = $a. self assert: (collection removeAt: 2 ifAbsent: [ $x ]) = $c. self assertIterable: collection equals: #($d $b)! ! !CTReversedListTest methodsFor: 'tests-removing' stamp: 'lr 4/21/2012 23:39'! testRemoveFirst | letters collection | letters := #($a $b $c $d $e). collection := self collectionWithAll: letters. #($e $d $c $b $a) iterator do: [ :each | self assert: collection removeFirst = each ]. self should: [ collection removeFirst ] raise: CTNoSuchElementError. self assertIterable: collection equals: #()! ! !CTReversedListTest methodsFor: 'tests-removing' stamp: 'lr 4/21/2012 23:34'! testRemoveIfAbsent super testRemoveIfAbsent! ! !CTReversedListTest methodsFor: 'tests-removing' stamp: 'lr 4/21/2012 23:39'! testRemoveLast | letters collection | letters := #($a $b $c $d $e). collection := self collectionWithAll: letters. #($a $b $c $d $e) iterator do: [ :each | self assert: collection removeLast = each ]. self should: [ collection removeLast ] raise: CTNoSuchElementError. self assertIterable: collection equals: #()! ! !CTReversedListTest methodsFor: 'tests-accessing' stamp: 'lr 4/21/2012 23:58'! testReversed | collection reversed | collection := self collectionClass withAll: #($a $b $c $d $e). reversed := collection reversed. self assert: reversed reversed == collection. self assertIterable: #($e $d $c $b $a) equals: reversed! ! !CTReversedListTest methodsFor: 'tests-accessing' stamp: 'lr 4/21/2012 23:07'! testSize super testSize! ! !CTReversedListTest methodsFor: 'tests-sorting' stamp: 'lr 4/21/2012 23:44'! testSortDefault super testSortDefault! ! !CTReversedListTest methodsFor: 'tests-sorting' stamp: 'lr 4/21/2012 23:44'! testSortEmpty super testSortEmpty! ! !CTReversedListTest methodsFor: 'tests-sorting' stamp: 'lr 4/21/2012 23:44'! testSortOrder super testSortOrder! ! CTDelegateListTest subclass: #CTSubListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! !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 4/21/2012 22:30'! testSubAddAt | collection sub | collection := self collectionClass withAll: #($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 4/21/2012 22:30'! testSubAddFirst | collection sub | collection := self collectionClass withAll: #($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 4/21/2012 22:30'! testSubAddLast | collection sub | collection := self collectionClass withAll: #($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 4/21/2012 22:30'! testSubAt | collection sub | collection := self collectionClass withAll: #($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 4/21/2012 22:30'! testSubAtIfAbsent | collection sub | collection := self collectionClass withAll: #($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 4/21/2012 22:30'! testSubAtPut | collection sub | collection := self collectionClass withAll: #($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 4/21/2012 22:30'! testSubFirst | collection sub | collection := self collectionClass withAll: #($a $b $c $d $e). sub := collection from: 2 to: 4. self assert: sub first = $b! ! !CTSubListTest methodsFor: 'tests-accessing' stamp: 'lr 4/22/2012 09:55'! testSubFromTo | collection sub subsub | collection := self collectionClass withAll: #($a $b $c $d $e). sub := collection from: 2 to: 4. subsub := sub from: 2 to: 2. self assert: (subsub removeAt: 1) = $c. self assertIterable: subsub equals: #(). self assertIterable: sub equals: #($b $d). self assertIterable: collection equals: #($a $b $d $e). ! ! !CTSubListTest methodsFor: 'tests-accessing' stamp: 'lr 4/21/2012 22:30'! testSubLast | collection sub | collection := self collectionClass withAll: #($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 4/21/2012 22:30'! testSubRemoveAll | collection sub | collection := self collectionClass withAll: #($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 4/21/2012 22:30'! testSubRemoveAt | collection sub | collection := self collectionClass withAll: #($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 4/21/2012 22:30'! testSubRemoveFirst | collection sub | collection := self collectionClass withAll: #($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 4/21/2012 22:31'! testSubRemoveLast | collection sub | collection := self collectionClass withAll: #($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-sorting' stamp: 'lr 4/21/2012 22:40'! testSubSort | collection sub | collection := self collectionClass withAll: #(3 2 1 5 4). sub := collection from: 2 to: 4. sub sort. self assertIterable: collection equals: #(3 1 2 5 4). self assertIterable: sub equals: #(1 2 5). ! ! !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! ! CTDelegateListTest subclass: #CTUnmodifiableListTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Lists'! !CTUnmodifiableListTest class methodsFor: 'testing' stamp: 'lr 4/5/2012 11:30'! shouldInheritSelectors ^ false! ! !CTUnmodifiableListTest methodsFor: 'accessing' stamp: 'lr 4/21/2012 23:28'! collectionWithAll: aCollection ^ (self collectionClass withAll: aCollection) 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-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-accessing' 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-exceptions' stamp: 'lr 4/5/2012 11:51'! testIndexOutOfBounds super testIndexOutOfBounds! ! !CTUnmodifiableListTest methodsFor: 'tests-testing' stamp: 'lr 4/5/2012 11:48'! testIsEmpty super testIsEmpty! ! !CTUnmodifiableListTest methodsFor: 'tests-iterators' stamp: 'lr 4/21/2012 10:55'! testIterator super testIterator! ! !CTUnmodifiableListTest methodsFor: 'tests-iterators' stamp: 'lr 4/5/2012 11:47'! testIteratorCopy super testIteratorCopy! ! !CTUnmodifiableListTest methodsFor: 'tests-iterators' stamp: 'lr 4/21/2012 10:55'! testIteratorEmpty super testIteratorEmpty! ! !CTUnmodifiableListTest methodsFor: 'tests-iterators' stamp: 'lr 4/21/2012 10:55'! testIteratorIndexed super testIteratorIndexed! ! !CTUnmodifiableListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 22:39'! testLast super testLast! ! !CTUnmodifiableListTest methodsFor: 'tests-testing' stamp: 'lr 4/5/2012 11:48'! testNotEmpty super testNotEmpty! ! !CTUnmodifiableListTest methodsFor: 'tests' stamp: 'lr 4/5/2012 11:46'! testPrinting super testPrinting! ! !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 4/21/2012 23:55'! testReversed super testReversed! ! !CTUnmodifiableListTest methodsFor: 'tests-accessing' stamp: 'lr 2/6/2012 22:39'! testSize super testSize! ! !CTUnmodifiableListTest methodsFor: 'tests-sorting' stamp: 'lr 4/5/2012 11:51'! testSortDefault self should: [ super testSortDefault ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-sorting' stamp: 'lr 4/5/2012 11:51'! testSortEmpty self should: [ super testSortEmpty ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-sorting' stamp: 'lr 4/5/2012 11:52'! testSortOrder self should: [ super testSortOrder ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableListTest methodsFor: 'tests-accessing' 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: #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: '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 4/21/2012 23:24'! 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 isEmpty). self assert: (collection add: $a at: 1) = $a. self assert: (collection at: 1) = $a. self assert: (collection size) = 1. self assert: (collection add: $b at: 2) = $b. self assert: (collection at: 2) = $b. self assert: (collection size) = 2. self assert: (collection add: $c at: 2) = $c. self assert: (collection at: 2) = $c. self assert: (collection size) = 3. self assert: (collection add: $d at: 1) = $d. self assert: (collection at: 1) = $d. self assert: (collection size) = 4. self assert: (collection add: $e at: 4) = $e. self assert: (collection at: 4) = $e. self assert: (collection size) = 5. self should: [ collection add: $a at: 0 ] raise: CTIndexOutOfBoundsError. self should: [ collection add: $a at: 7 ] raise: CTIndexOutOfBoundsError. self assert: (collection size) = 5. 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 4/21/2012 23:17'! testAtPut | collection | collection := self collectionWithAll: #($a $b $c). self should: [ collection at: 0 put: $u ] raise: CTIndexOutOfBoundsError. self assert: (collection at: 1 put: $x) = $x; assert: (collection at: 1) = $x. self assert: (collection at: 2 put: $y) = $y; assert: (collection at: 2) = $y. self assert: (collection at: 3 put: $z) = $z; assert: (collection at: 3) = $z. self should: [ collection at: 4 put: $v ] raise: CTIndexOutOfBoundsError. self assertInvariants: collection! ! !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-accessing' 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-iterators' stamp: 'lr 4/21/2012 09:16'! testIterator | collection | collection := self collectionWithAll: #($a $b $c). self assertIterable: #($a $b $c) equals: collection! ! !CTListTest methodsFor: 'tests-iterators' stamp: 'lr 4/21/2012 22:05'! testIteratorIndexed | collection | collection := self collectionWithAll: #($a $b $c). collection iterator withIndex do: [ :index :value | self assert: (collection at: index) = value ]! ! !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 4/21/2012 23:45'! testRemoveLast | letters collection | letters := #($a $b $c $d $e). collection := self collectionWithAll: letters. #($e $d $c $b $a) iterator do: [ :each | self assert: collection removeLast = each ]. self should: [ collection removeFirst ] raise: CTNoSuchElementError. self assertIterable: collection equals: #()! ! !CTListTest methodsFor: 'tests-accessing' stamp: 'lr 4/21/2012 23:54'! testReversed | collection | collection := self collectionWithAll: #($a $b $c $d $e). self assertIterable: #($e $d $c $b $a) equals: collection reversed! ! !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-accessing' 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: #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-copying' stamp: 'lr 4/1/2012 16:56'! testImmutable self should: [ self emptyCollection immutable ] raise: CTUnsupportedOperationError! ! !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! ! !CTPriorityQueueTest methodsFor: 'tests-copying' stamp: 'lr 4/1/2012 16:56'! testUnmodifiable self should: [ self emptyCollection unmodifiable ] raise: CTUnsupportedOperationError! ! CTCollectionTest subclass: #CTSetTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core'! CTSetTest subclass: #CTConstructorSetTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Sets'! !CTConstructorSetTest class methodsFor: 'testing' stamp: 'lr 4/22/2012 10:17'! shouldInheritSelectors ^ false! ! !CTConstructorSetTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 10:18'! collectionClass ^ CTImmutableSet! ! !CTConstructorSetTest methodsFor: 'tests-adding' stamp: 'lr 4/22/2012 10:17'! testAddDuplicates self should: [ super testAddDuplicates ] raise: CTUnsupportedOperationError! ! !CTConstructorSetTest methodsFor: 'tests-adding' stamp: 'lr 4/22/2012 10:17'! testAddRemove self should: [ super testAddRemove ] raise: CTUnsupportedOperationError! ! !CTConstructorSetTest methodsFor: 'tests-copying' stamp: 'lr 4/22/2012 10:17'! testCopy | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable copy == immutable! ! !CTConstructorSetTest methodsFor: 'tests-copying' stamp: 'lr 4/22/2012 10:17'! testImmutable | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable immutable == immutable! ! !CTConstructorSetTest methodsFor: 'tests-testing' stamp: 'lr 4/22/2012 10:32'! testIncludes super testIncludes! ! !CTConstructorSetTest methodsFor: 'tests-testing' stamp: 'lr 4/22/2012 10:17'! testIsEmpty super testIsEmpty! ! !CTConstructorSetTest methodsFor: 'tests-iterators' stamp: 'lr 4/22/2012 10:17'! testIteratorEmpty super testIteratorEmpty! ! !CTConstructorSetTest methodsFor: 'tests-iterators' stamp: 'lr 4/22/2012 10:17'! testIteratorMultiple super testIteratorMultiple! ! !CTConstructorSetTest methodsFor: 'tests-iterators' stamp: 'lr 4/22/2012 10:17'! testIteratorSingle super testIteratorSingle! ! !CTConstructorSetTest methodsFor: 'tests-instantiation' stamp: 'lr 4/22/2012 10:17'! testNew1 super testNew1! ! !CTConstructorSetTest methodsFor: 'tests-removing' stamp: 'lr 4/22/2012 10:17'! testRemove self should: [ super testRemove ] raise: CTUnsupportedOperationError! ! !CTConstructorSetTest methodsFor: 'tests-removing' stamp: 'lr 4/22/2012 10:17'! testRemoveAll self should: [ super testRemoveAll ] raise: CTUnsupportedOperationError! ! !CTConstructorSetTest methodsFor: 'tests-removing' stamp: 'lr 4/22/2012 10:17'! testRemoveIfAbsent self should: [ super testRemoveIfAbsent ] raise: CTUnsupportedOperationError! ! !CTConstructorSetTest methodsFor: 'tests-accessing' stamp: 'lr 4/22/2012 10:17'! testSize super testSize! ! !CTConstructorSetTest methodsFor: 'tests-copying' stamp: 'lr 4/22/2012 10:17'! testUnmodifiable | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable unmodifiable == immutable! ! !CTConstructorSetTest methodsFor: 'tests-instantiation' stamp: 'lr 4/22/2012 10:17'! testWith1 super testWith1! ! !CTConstructorSetTest methodsFor: 'tests-instantiation' stamp: 'lr 4/22/2012 10:17'! testWith2 super testWith2! ! !CTConstructorSetTest methodsFor: 'tests-instantiation' stamp: 'lr 4/22/2012 10:17'! testWith3 super testWith3! ! !CTConstructorSetTest methodsFor: 'tests-instantiation' stamp: 'lr 4/22/2012 10:17'! testWith4 super testWith4! ! CTSetTest subclass: #CTDelegateSetTest instanceVariableNames: 'collectionClass' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Sets'! !CTDelegateSetTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 09:35'! collectionClass ^ collectionClass! ! !CTDelegateSetTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 09:35'! collectionClasses ^ Array with: CTHashSet with: CTLinkedHashSet with: CTTreeSet! ! !CTDelegateSetTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 09:35'! collectionWithAll: aCollection ^ CTDelegateSet on: (self collectionClass withAll: aCollection)! ! !CTDelegateSetTest methodsFor: 'running' stamp: 'lr 4/22/2012 09:35'! runCase self collectionClasses do: [ :class | collectionClass := class. super runCase ]! ! CTDelegateSetTest subclass: #CTImmutableSetTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Sets'! !CTImmutableSetTest class methodsFor: 'testing' stamp: 'lr 2/17/2012 23:43'! shouldInheritSelectors ^ false! ! !CTImmutableSetTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 09:37'! collectionWithAll: aCollection ^ (self collectionClass withAll: aCollection) immutable! ! !CTImmutableSetTest methodsFor: 'tests-adding' stamp: 'lr 2/18/2012 00:03'! testAddDuplicates self should: [ super testAddDuplicates ] raise: CTUnsupportedOperationError! ! !CTImmutableSetTest methodsFor: 'tests-adding' stamp: 'lr 2/18/2012 00:03'! testAddRemove self should: [ super testAddRemove ] raise: CTUnsupportedOperationError! ! !CTImmutableSetTest methodsFor: 'tests-copying' stamp: 'lr 2/17/2012 23:43'! testCopy | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable copy == immutable! ! !CTImmutableSetTest methodsFor: 'tests-copying' stamp: 'lr 2/17/2012 23:43'! testImmutable | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable immutable == immutable! ! !CTImmutableSetTest methodsFor: 'tests-testing' stamp: 'lr 4/22/2012 10:32'! testIncludes super testIncludes! ! !CTImmutableSetTest methodsFor: 'tests-testing' stamp: 'lr 2/18/2012 00:03'! testIsEmpty super testIsEmpty! ! !CTImmutableSetTest methodsFor: 'tests-iterators' stamp: 'lr 2/18/2012 00:03'! testIteratorEmpty super testIteratorEmpty! ! !CTImmutableSetTest methodsFor: 'tests-iterators' stamp: 'lr 2/18/2012 00:03'! testIteratorMultiple super testIteratorMultiple! ! !CTImmutableSetTest methodsFor: 'tests-iterators' stamp: 'lr 2/18/2012 00:03'! testIteratorSingle super testIteratorSingle! ! !CTImmutableSetTest methodsFor: 'tests-removing' stamp: 'lr 2/18/2012 00:03'! testRemove self should: [ super testRemove ] raise: CTUnsupportedOperationError! ! !CTImmutableSetTest methodsFor: 'tests-removing' stamp: 'lr 2/18/2012 00:03'! testRemoveAll self should: [ super testRemoveAll ] raise: CTUnsupportedOperationError! ! !CTImmutableSetTest methodsFor: 'tests-removing' stamp: 'lr 2/18/2012 00:03'! testRemoveIfAbsent self should: [ super testRemoveIfAbsent ] raise: CTUnsupportedOperationError! ! !CTImmutableSetTest methodsFor: 'tests-accessing' stamp: 'lr 2/18/2012 00:03'! testSize super testSize! ! !CTImmutableSetTest methodsFor: 'tests-copying' stamp: 'lr 2/17/2012 23:43'! testUnmodifiable | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assert: immutable unmodifiable == immutable! ! CTDelegateSetTest subclass: #CTUnmodifiableSetTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Sets'! !CTUnmodifiableSetTest class methodsFor: 'testing' stamp: 'lr 2/17/2012 23:43'! shouldInheritSelectors ^ false! ! !CTUnmodifiableSetTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 09:37'! collectionWithAll: aCollection ^ (self collectionClass withAll: aCollection) unmodifiable! ! !CTUnmodifiableSetTest methodsFor: 'tests-adding' stamp: 'lr 2/17/2012 23:56'! testAddDuplicates self should: [ super testAddDuplicates ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableSetTest methodsFor: 'tests-adding' stamp: 'lr 2/17/2012 23:56'! testAddRemove self should: [ super testAddRemove ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableSetTest methodsFor: 'tests-copying' stamp: 'lr 2/17/2012 23:43'! testCopy | collection unmodifiable | collection := self collectionWithAll: #($a $b $c). unmodifiable := collection unmodifiable. self assert: unmodifiable copy == unmodifiable! ! !CTUnmodifiableSetTest methodsFor: 'tests-copying' stamp: 'lr 2/17/2012 23:57'! testImmutable | collection unmodifiable immutable | collection := CTLinkedHashSet withAll: #($a $b $c). unmodifiable := collection unmodifiable. immutable := unmodifiable immutable. collection add: $x. self assertIterable: immutable equals: #($a $b $c)! ! !CTUnmodifiableSetTest methodsFor: 'tests-testing' stamp: 'lr 4/22/2012 10:32'! testIncludes super testIncludes! ! !CTUnmodifiableSetTest methodsFor: 'tests-testing' stamp: 'lr 2/18/2012 00:02'! testIsEmpty super testIsEmpty! ! !CTUnmodifiableSetTest methodsFor: 'tests-iterators' stamp: 'lr 2/18/2012 00:00'! testIteratorEmpty super testIteratorEmpty! ! !CTUnmodifiableSetTest methodsFor: 'tests-iterators' stamp: 'lr 2/18/2012 00:00'! testIteratorMultiple super testIteratorMultiple! ! !CTUnmodifiableSetTest methodsFor: 'tests-iterators' stamp: 'lr 2/18/2012 00:00'! testIteratorSingle super testIteratorSingle! ! !CTUnmodifiableSetTest methodsFor: 'tests-removing' stamp: 'lr 2/18/2012 00:01'! testRemove self should: [ super testRemove ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableSetTest methodsFor: 'tests-removing' stamp: 'lr 2/18/2012 00:01'! testRemoveAll self should: [ super testRemoveAll ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableSetTest methodsFor: 'tests-removing' stamp: 'lr 2/18/2012 00:01'! testRemoveIfAbsent self should: [ super testRemoveIfAbsent ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableSetTest methodsFor: 'tests-accessing' stamp: 'lr 2/17/2012 23:43'! testSize super testSize! ! !CTUnmodifiableSetTest methodsFor: 'tests-copying' stamp: 'lr 2/17/2012 23:43'! testUnmodifiable | collection unmodifiable | collection := self collectionWithAll: #($a $b $c). unmodifiable := collection unmodifiable. self assert: unmodifiable unmodifiable == unmodifiable! ! 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 4/21/2012 09:20'! testForwardIterator | collection | collection := self collectionWithAll: #($l $u $k $a $s). self assertIterable: #($l $u $k $a $s) equals: collection iterator! ! !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: '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-copying' stamp: 'lr 2/18/2012 00:12'! testCopy | one two | one := self collectionWithAll: #($a $b $c). two := one copy. self deny: one == two. self assertIterable: one equalsIgnoringOrder: two. one add: $x. two add: $y. self assertIterable: one equalsIgnoringOrder: #($a $b $c $x). self assertIterable: two equalsIgnoringOrder: #($a $b $c $y)! ! !CTSetTest methodsFor: 'tests-copying' stamp: 'lr 2/18/2012 00:09'! testImmutable | collection immutable | collection := self collectionWithAll: #($a $b $c). immutable := collection immutable. self assertIterable: immutable equalsIgnoringOrder: #($a $b $c). collection add: $x. self assertIterable: immutable equalsIgnoringOrder: #($a $b $c)! ! !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-copying' stamp: 'lr 2/18/2012 00:10'! testUnmodifiable | collection unmodifiable | collection := self collectionWithAll: #($a $b $c). unmodifiable := collection unmodifiable. self assertIterable: unmodifiable equalsIgnoringOrder: #($a $b $c). collection add: $x. self assertIterable: unmodifiable equalsIgnoringOrder: #($a $b $c $x)! ! !CTSetTest methodsFor: 'accessing' stamp: 'lr 2/13/2012 07:09'! workflowSize ^ 10000! ! 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 4/21/2012 09:20'! testForwardIterator | collection | collection := self collectionWithAll: #($l $u $k $a $s). self assertIterable: #($a $k $l $s $u) equals: collection iterator! ! 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 subclass: #CTContainerIteratorTest instanceVariableNames: 'builder' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Iterators'! !CTContainerIteratorTest commentStamp: 'lr 4/23/2012 07:47' prior: 0! Tests iterators on various container implementations.! !CTContainerIteratorTest class methodsFor: 'testing' stamp: 'lr 4/22/2012 21:49'! isAbstract ^ self name = #CTContainerIteratorTest! ! !CTContainerIteratorTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 17:35'! iterableBuilders self subclassResponsibility ! ! !CTContainerIteratorTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 17:34'! iteratorWithAll: aCollection ^ (builder value: aCollection) iterator! ! !CTContainerIteratorTest methodsFor: 'running' stamp: 'lr 4/22/2012 17:35'! runCase self iterableBuilders iterator do: [ :block | builder := block. super runCase ]! ! !CTContainerIteratorTest methodsFor: 'tests-modifying' stamp: 'lr 4/23/2012 21:41'! testAddTo | collection iterator | collection := CTArrayList withAll: #($a $b). iterator := self iteratorWithAll: #($c $d $e). self assert: (iterator addTo: collection) = collection. self assertIterable: collection equals: #($a $b $c $d $e)! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:31'! testAllSatisfy0 | iterator | iterator := self iteratorWithAll: #(). self assert: (iterator allSatisfy: [ :each | self fail ])! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:31'! testAllSatisfy1 | iterator | iterator := self iteratorWithAll: #($a). self assert: (iterator allSatisfy: [ :each | each isVowel ]). iterator := self iteratorWithAll: #($b). self deny: (iterator allSatisfy: [ :each | each isVowel ])! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:31'! testAllSatisfy2 | iterator | iterator := self iteratorWithAll: #($a $e $i). self assert: (iterator allSatisfy: [ :each | each isVowel ]). iterator := self iteratorWithAll: #($a $e $k). self deny: (iterator allSatisfy: [ :each | each isVowel ])! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:31'! testAnySatisfy0 | iterator | iterator := self iteratorWithAll: #(). self deny: (iterator anySatisfy: [ :each | self fail ])! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:31'! testAnySatisfy1 | iterator | iterator := self iteratorWithAll: #($a). self assert: (iterator anySatisfy: [ :each | each isVowel ]). iterator := self iteratorWithAll: #($b). self deny: (iterator anySatisfy: [ :each | each isVowel ])! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:31'! testAnySatisfy2 | iterator | iterator := self iteratorWithAll: #($c $d $e). self assert: (iterator anySatisfy: [ :each | each isVowel ]). iterator := self iteratorWithAll: #($f $g $h). self deny: (iterator anySatisfy: [ :each | each isVowel ])! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:40'! testAt0 | iterator | iterator := self iteratorWithAll: #(). self should: [ iterator at: 0 ] raise: CTIndexOutOfBoundsError. iterator := self iteratorWithAll: #(). self should: [ iterator at: 1 ] raise: CTIndexOutOfBoundsError! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:40'! testAt1 | iterator | iterator := self iteratorWithAll: #($a). self should: [ iterator at: 0 ] raise: CTIndexOutOfBoundsError. iterator := self iteratorWithAll: #($a). self assert: (iterator at: 1) = $a. iterator := self iteratorWithAll: #($a). self should: [ iterator at: 2 ] raise: CTIndexOutOfBoundsError! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:40'! testAt2 self subclassResponsibility! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:42'! testAtIfAbsent0 | iterator | iterator := self iteratorWithAll: #(). self assert: (iterator at: 0 ifAbsent: [ true ]). iterator := self iteratorWithAll: #(). self assert: (iterator at: 1 ifAbsent: [ true ])! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:42'! testAtIfAbsent1 | iterator | iterator := self iteratorWithAll: #($a). self assert: (iterator at: 0 ifAbsent: [ true ]). iterator := self iteratorWithAll: #($a). self assert: (iterator at: 1 ifAbsent: [ self fail ]) = $a. iterator := self iteratorWithAll: #($a). self assert: (iterator at: 2 ifAbsent: [ true ])! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:41'! testAtIfAbsent2 self subclassResponsibility! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/22/2012 22:32'! testChaining2 self assertIterable: (self iteratorWithAll: #()) , (self iteratorWithAll: #()) equals: #(). self assertIterable: (self iteratorWithAll: #(1)) , (self iteratorWithAll: #()) equals: #(1). self assertIterable: (self iteratorWithAll: #()) , (self iteratorWithAll: #(1)) equals: #(1). self assertIterable: (self iteratorWithAll: #(1 2)) , (self iteratorWithAll: #()) equals: #(1 2). self assertIterable: (self iteratorWithAll: #(1)) , (self iteratorWithAll: #(2)) equals: #(1 2). self assertIterable: (self iteratorWithAll: #()) , (self iteratorWithAll: #(1 2)) equals: #(1 2). self assertIterable: (self iteratorWithAll: #(1 2 3)) , (self iteratorWithAll: #()) equals: #(1 2 3). self assertIterable: (self iteratorWithAll: #(1 2)) , (self iteratorWithAll: #(3)) equals: #(1 2 3). self assertIterable: (self iteratorWithAll: #(1)) , (self iteratorWithAll: #(2 3)) equals: #(1 2 3). self assertIterable: (self iteratorWithAll: #()) , (self iteratorWithAll: #(1 2 3)) equals: #(1 2 3)! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/22/2012 22:34'! testChaining3 self assertIterable: (self iteratorWithAll: #()) , (self iteratorWithAll: #()) , (self iteratorWithAll: #()) equals: #(). self assertIterable: (self iteratorWithAll: #(1)) , (self iteratorWithAll: #()) , (self iteratorWithAll: #()) equals: #(1). self assertIterable: (self iteratorWithAll: #()) , (self iteratorWithAll: #(1)) , (self iteratorWithAll: #()) equals: #(1). self assertIterable: (self iteratorWithAll: #()) , (self iteratorWithAll: #()) , (self iteratorWithAll: #(1)) equals: #(1). self assertIterable: (self iteratorWithAll: #(1)) , (self iteratorWithAll: #(2)) , (self iteratorWithAll: #()) equals: #(1 2). self assertIterable: (self iteratorWithAll: #(1)) , (self iteratorWithAll: #()) , (self iteratorWithAll: #(2)) equals: #(1 2). self assertIterable: (self iteratorWithAll: #()) , (self iteratorWithAll: #(1)) , (self iteratorWithAll: #(2)) equals: #(1 2). self assertIterable: (self iteratorWithAll: #(1)) , (self iteratorWithAll: #(2)) , (self iteratorWithAll: #(3)) equals: #(1 2 3). self assertIterable: (self iteratorWithAll: #(1)) , (self iteratorWithAll: #(2 3)) , (self iteratorWithAll: #()) equals: #(1 2 3). self assertIterable: (self iteratorWithAll: #()) , (self iteratorWithAll: #(1 2)) , (self iteratorWithAll: #(3)) equals: #(1 2 3)! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/22/2012 22:35'! testCollect self assertIterable: ((self iteratorWithAll: #()) collect: [ :each | self fail ]) equals: #(). self assertIterable: ((self iteratorWithAll: #($a)) collect: [ :each | each asUppercase ]) equals: #($A). self assertIterable: ((self iteratorWithAll: #($a $b)) collect: [ :each | each asUppercase ]) equals: #($A $B). self assertIterable: ((self iteratorWithAll: #($a $b $c)) collect: [ :each | each asUppercase ]) equals: #($A $B $C)! ! !CTContainerIteratorTest methodsFor: 'tests' stamp: 'lr 4/22/2012 20:14'! testCopy | iterator | iterator := self iteratorWithAll: #($a $b $c). self should: [ iterator copy ] raise: CTUnsupportedOperationError! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:31'! testCount0 | iterator | iterator := self iteratorWithAll: #(). self assert: (iterator count: [ :each | self fail ]) = 0! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:32'! testCount1 | iterator | iterator := self iteratorWithAll: #($a). self assert: (iterator count: [ :each | each isVowel ]) = 1. iterator := self iteratorWithAll: #($b). self assert: (iterator count: [ :each | each isVowel ]) = 0! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:31'! testCount2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator count: [ :each | each isVowel ]) = 1. iterator := self iteratorWithAll: #($d $e $f $g $h $i). self assert: (iterator count: [ :each | each isVowel ]) = 2! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:36'! testDetect0 | iterator | iterator := self iteratorWithAll: #(). self should: [ iterator detect: [ :each | self fail ] ] raise: CTNoSuchElementError ! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:36'! testDetect1 | iterator | iterator := self iteratorWithAll: #($a). self assert: (iterator detect: [ :each | each isVowel ]) = $a. iterator := self iteratorWithAll: #($b). self should: [ iterator detect: [ :each | each isVowel ] ] raise: CTNoSuchElementError! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:37'! testDetect2 | iterator | iterator := self iteratorWithAll: #($a $b $c $d). self assert: (iterator detect: [ :each | each isVowel ]) = $a. iterator := self iteratorWithAll: #($b $c $d $e). self assert: (iterator detect: [ :each | each isVowel ]) = $e. iterator := self iteratorWithAll: #($b $c $d $f). self should: [ iterator detect: [ :each | each isVowel ] ] raise: CTNoSuchElementError! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:39'! testDetectIfNone0 | iterator | iterator := self iteratorWithAll: #(). self assert: (iterator detect: [ :each | self fail ] ifNone: [ true ])! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:39'! testDetectIfNone1 | iterator | iterator := self iteratorWithAll: #($a). self assert: (iterator detect: [ :each | each isVowel ] ifNone: [ self fail ]) = $a. iterator := self iteratorWithAll: #($b). self assert: (iterator detect: [ :each | each isVowel ] ifNone: [ true ])! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:39'! testDetectIfNone2 | iterator | iterator := self iteratorWithAll: #($a $b $c $d). self assert: (iterator detect: [ :each | each isVowel ] ifNone: [ self fail ]) = $a. iterator := self iteratorWithAll: #($b $c $d $e). self assert: (iterator detect: [ :each | each isVowel ] ifNone: [ self fail ]) = $e. iterator := self iteratorWithAll: #($b $c $d $f). self assert: (iterator detect: [ :each | each isVowel ] ifNone: [ true ])! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:32'! testDo0 | iterator | iterator := self iteratorWithAll: #(). iterator do: [ :each | self fail ]! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:33'! testDo1 | iterator | iterator := self iteratorWithAll: #($a). iterator do: [ :each | ^ self assert: each = $a ]. self fail! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:33'! testDo2 | elements iterator | elements := CTArrayList new. iterator := self iteratorWithAll: #($a $b $c $d). iterator do: [ :each | elements add: each ]. self assertIterable: #($a $b $c $d) equals: elements! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:33'! testDoSeparatedBy0 | iterator | iterator := self iteratorWithAll: #(). iterator do: [ :each | self fail ] separatedBy: [ self fail ]! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:33'! testDoSeparatedBy1 | iterator | iterator := self iteratorWithAll: #($a). iterator do: [ :each | ^ self assert: each = $a ] separatedBy: [ self fail ]. self fail! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:34'! testDoSeparatedBy2 | elements iterator | elements := CTArrayList new. iterator := self iteratorWithAll: #($a $b $c $d). iterator do: [ :each | elements add: each ] separatedBy: [ elements add: elements size ]. self assertIterable: #($a 1 $b 3 $c 5 $d) equals: elements! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:09'! testFind0 | iterator | iterator := self iteratorWithAll: #(). self assert: (iterator find: [ :each | self fail ]) = 0! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:11'! testFind1 | iterator | iterator := self iteratorWithAll: #($a). self assert: (iterator find: [ :each | each = $a ]) = 1. iterator := self iteratorWithAll: #($a). self assert: (iterator find: [ :each | each = $b ]) = 0! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:10'! testFind2 self subclassResponsibility! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:12'! testFindIfAbsent0 | iterator | iterator := self iteratorWithAll: #(). self assert: (iterator find: [ :each | self fail ] ifAbsent: [ true ])! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:12'! testFindIfAbsent1 | iterator | iterator := self iteratorWithAll: #($a). self assert: (iterator find: [ :each | each = $a ] ifAbsent: [ self fail ]) = 1. iterator := self iteratorWithAll: #($a). self assert: (iterator find: [ :each | each = $b ] ifAbsent: [ true ])! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:11'! testFindIfAbsent2 self subclassResponsibility! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:25'! testGroupBy0 | iterator grouping | iterator := self iteratorWithAll: #(). grouping := iterator groupBy: [ :each | each isVowel ]. self assert: grouping isEmpty! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:25'! testGroupBy1 | iterator grouping | iterator := self iteratorWithAll: #($a). grouping := iterator groupBy: [ :each | each isVowel ]. self assertIterable: (grouping keys) equals: #(true). self assertIterable: (grouping at: true) equals: #($a)! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:25'! testGroupBy2 | iterator grouping | iterator := self iteratorWithAll: #($a $b $c $d $e $f $g $h $i). grouping := iterator groupBy: [ :each | each isVowel ]. self assertIterable: (grouping keys) equals: #(true false). self assertIterable: (grouping at: true) equals: #($a $e $i). self assertIterable: (grouping at: false) equals: #($b $c $d $f $g $h)! ! !CTContainerIteratorTest methodsFor: 'tests-testing' stamp: 'lr 4/22/2012 17:34'! testHasNext self deny: (self iteratorWithAll: #()) hasNext. self assert: (self iteratorWithAll: #(1)) hasNext. self assert: (self iteratorWithAll: #(1 2)) hasNext! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:49'! testIncludes0 | iterator | iterator := self iteratorWithAll: #(). self deny: (iterator includes: $a)! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:49'! testIncludes1 | iterator | iterator := self iteratorWithAll: #($a). self assert: (iterator includes: $a). iterator := self iteratorWithAll: #($a). self deny: (iterator includes: $b)! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:49'! testIncludes2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator includes: $a). iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator includes: $b). iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator includes: $c). iterator := self iteratorWithAll: #($a $b $c). self deny: (iterator includes: $d)! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:18'! testIndexOf0 | iterator | iterator := self iteratorWithAll: #(). self assert: (iterator indexOf: $a) = 0! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:18'! testIndexOf1 | iterator | iterator := self iteratorWithAll: #($a). self assert: (iterator indexOf: $a) = 1. iterator := self iteratorWithAll: #($a). self assert: (iterator indexOf: $b) = 0! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:19'! testIndexOf2 self subclassResponsibility! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:19'! testIndexOfIfAbsent0 | iterator | iterator := self iteratorWithAll: #(). self assert: (iterator indexOf: $a ifAbsent: [ true ])! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:20'! testIndexOfIfAbsent1 | iterator | iterator := self iteratorWithAll: #($a). self assert: (iterator indexOf: $a ifAbsent: [ self fail ]) = 1. iterator := self iteratorWithAll: #($a). self assert: (iterator indexOf: $b ifAbsent: [ true ])! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:20'! testIndexOfIfAbsent2 self subclassResponsibility! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:52'! testInjectInto0 | iterator | iterator := self iteratorWithAll: #(). self assert: (iterator inject: 1 into: [ :a :b | self fail ]) = 1! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:56'! testInjectInto1 | iterator | iterator := self iteratorWithAll: #(2). self assert: (iterator inject: 1 into: [ :a :b | a - b ]) = -1! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:56'! testInjectInto2 self subclassResponsibility! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:43'! testLast0 | iterator | iterator := self iteratorWithAll: #(). self should: [ iterator last ] raise: CTNoSuchElementError! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:43'! testLast1 | iterator | iterator := self iteratorWithAll: #($a). self assert: iterator last = $a! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:43'! testLast2 self subclassResponsibility! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/23/2012 09:12'! testLimit self assert: ((self iteratorWithAll: #()) limit: 0) size = 0. self assert: ((self iteratorWithAll: #(1)) limit: 0) size = 0. self assert: ((self iteratorWithAll: #(1 2)) limit: 0) size = 0. self assert: ((self iteratorWithAll: #(1 2 3)) limit: 0) size = 0. self assert: ((self iteratorWithAll: #()) limit: 1) size = 0. self assert: ((self iteratorWithAll: #(1)) limit: 1) size = 1. self assert: ((self iteratorWithAll: #(1 2)) limit: 1) size = 1. self assert: ((self iteratorWithAll: #(1 2 3)) limit: 1) size = 1. self assert: ((self iteratorWithAll: #()) limit: 2) size = 0. self assert: ((self iteratorWithAll: #(1)) limit: 2) size = 1. self assert: ((self iteratorWithAll: #(1 2)) limit: 2) size = 2. self assert: ((self iteratorWithAll: #(1 2 3)) limit: 2) size = 2. self assert: ((self iteratorWithAll: #()) limit: 3) size = 0. self assert: ((self iteratorWithAll: #(1)) limit: 3) size = 1. self assert: ((self iteratorWithAll: #(1 2)) limit: 3) size = 2. self assert: ((self iteratorWithAll: #(1 2 3)) limit: 3) size = 3! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/23/2012 15:12'! testLimitEmpty | iterator | iterator := (self iteratorWithAll: #()) limit: 3. self should: [ iterator next ] raise: CTNoSuchElementError. self deny: iterator hasNext. iterator := (self iteratorWithAll: #(1 2 3)) limit: 0. self should: [ iterator next ] raise: CTNoSuchElementError. self deny: iterator hasNext! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/23/2012 09:12'! testLimitSize self assert: ((self iteratorWithAll: #()) limit: 0) size = 0. self assert: ((self iteratorWithAll: #(1)) limit: 0) size = 0. self assert: ((self iteratorWithAll: #(1 2)) limit: 0) size = 0. self assert: ((self iteratorWithAll: #(1 2 3)) limit: 0) size = 0. self assert: ((self iteratorWithAll: #()) limit: 1) size = 0. self assert: ((self iteratorWithAll: #(1)) limit: 1) size = 1. self assert: ((self iteratorWithAll: #(1 2)) limit: 1) size = 1. self assert: ((self iteratorWithAll: #(1 2 3)) limit: 1) size = 1. self assert: ((self iteratorWithAll: #()) limit: 2) size = 0. self assert: ((self iteratorWithAll: #(1)) limit: 2) size = 1. self assert: ((self iteratorWithAll: #(1 2)) limit: 2) size = 2. self assert: ((self iteratorWithAll: #(1 2 3)) limit: 2) size = 2. self assert: ((self iteratorWithAll: #()) limit: 3) size = 0. self assert: ((self iteratorWithAll: #(1)) limit: 3) size = 1. self assert: ((self iteratorWithAll: #(1 2)) limit: 3) size = 2. self assert: ((self iteratorWithAll: #(1 2 3)) limit: 3) size = 3! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/23/2012 15:12'! testMerge2 | a b | a := #(1 2 5). b := #(3 4 6 7). self assertIterable: (self iteratorWithAll: a) <> (self iteratorWithAll: b) equals: #(1 2 3 4 5 6 7). self assertIterable: (self iteratorWithAll: b) <> (self iteratorWithAll: a) equals: #(1 2 3 4 5 6 7)! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/23/2012 15:12'! testMerge3 | a b c | a := #(5 6 7). b := #(1 2 3). c := #(4 8 9). self assertIterable: (self iteratorWithAll: a) <> (self iteratorWithAll: b) <> (self iteratorWithAll: c) equals: #(1 2 3 4 5 6 7 8 9). self assertIterable: (self iteratorWithAll: b) <> (self iteratorWithAll: a) <> (self iteratorWithAll: c) equals: #(1 2 3 4 5 6 7 8 9). self assertIterable: (self iteratorWithAll: c) <> (self iteratorWithAll: b) <> (self iteratorWithAll: a) equals: #(1 2 3 4 5 6 7 8 9). self assertIterable: (self iteratorWithAll: a) <> (self iteratorWithAll: c) <> (self iteratorWithAll: b) equals: #(1 2 3 4 5 6 7 8 9). self assertIterable: (self iteratorWithAll: b) <> (self iteratorWithAll: c) <> (self iteratorWithAll: a) equals: #(1 2 3 4 5 6 7 8 9). self assertIterable: (self iteratorWithAll: c) <> (self iteratorWithAll: a) <> (self iteratorWithAll: b) equals: #(1 2 3 4 5 6 7 8 9)! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:44'! testNext0 | iterator | iterator := self iteratorWithAll: #(). self should: [ iterator next ] raise: CTNoSuchElementError! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:44'! testNext1 | iterator | iterator := self iteratorWithAll: #($a). self assert: iterator next = $a! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:44'! testNext2 self subclassResponsibility! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:44'! testNextOr0 | iterator | iterator := self iteratorWithAll: #(). self assert: (iterator nextOr: $x) = $x! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:45'! testNextOr1 | iterator | iterator := self iteratorWithAll: #($a). self assert: (iterator nextOr: $x) = $a. self assert: (iterator nextOr: $x) = $x! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:45'! testNextOr2 self subclassResponsibility! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:45'! testNextOrNil0 | iterator | iterator := self iteratorWithAll: #(). self assert: iterator nextOrNil isNil! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:45'! testNextOrNil1 | iterator | iterator := self iteratorWithAll: #($a). self assert: iterator nextOrNil = $a. self assert: iterator nextOrNil isNil! ! !CTContainerIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:45'! testNextOrNil2 self subclassResponsibility! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:32'! testNoneSatisfy0 | iterator | iterator := self iteratorWithAll: #(). self assert: (iterator noneSatisfy: [ :each | self fail ])! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:32'! testNoneSatisfy1 | iterator | iterator := self iteratorWithAll: #($a). self deny: (iterator noneSatisfy: [ :each | each isVowel ]). iterator := self iteratorWithAll: #($b). self assert: (iterator noneSatisfy: [ :each | each isVowel ])! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:32'! testNoneSatisfy2 | iterator | iterator := self iteratorWithAll: #($c $d $e). self deny: (iterator noneSatisfy: [ :each | each isVowel ]). iterator := self iteratorWithAll: #($f $g $h). self assert: (iterator noneSatisfy: [ :each | each isVowel ])! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/23/2012 09:09'! testPartitionEmpty | iterator | iterator := (self iteratorWithAll: #()) partition: 2. self deny: iterator hasNext. iterator := (self iteratorWithAll: #()) partition: 2. self should: [ iterator next ] raise: CTNoSuchElementError ! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/23/2012 09:03'! testPeeking | iterator | iterator := (self iteratorWithAll: #($a)) peeking. self assert: iterator peek = $a. self assert: iterator peek = $a. self assert: iterator hasNext. self assert: iterator peek = $a. self assert: iterator peek = $a. self assert: iterator next = $a. self should: [ iterator peek ] raise: CTNoSuchElementError. self should: [ iterator next ] raise: CTNoSuchElementError. self deny: iterator hasNext! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/23/2012 09:03'! testPeekingEmpty | iterator | iterator := (self iteratorWithAll: #()) peeking. self deny: iterator hasNext. iterator := (self iteratorWithAll: #()) peeking. self should: [ iterator next ] raise: CTNoSuchElementError. iterator := (self iteratorWithAll: #()) peeking. self should: [ iterator peek ] raise: CTNoSuchElementError. ! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:04'! testReduce0 | iterator | iterator := self iteratorWithAll: #(). self should: [ iterator reduce: [ :a | self fail ] ] raise: CTIllegalArgumentError. self should: [ iterator reduce: [ :a :b | self fail ] ] raise: CTNoSuchElementError! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:04'! testReduce1 | iterator | iterator := self iteratorWithAll: #(1). self assert: (iterator reduce: [ :a :b | self fail ]) = 1! ! !CTContainerIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:05'! testReduce2 self subclassResponsibility! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/22/2012 22:40'! testReject self assertIterable: ((self iteratorWithAll: #()) reject: [ :each | each even ]) equals: #(). self assertIterable: ((self iteratorWithAll: #(1)) reject: [ :each | each even ]) equals: #(1). self assertIterable: ((self iteratorWithAll: #(1 3)) reject: [ :each | each even ]) equals: #(1 3). self assertIterable: ((self iteratorWithAll: #(1 3 5)) reject: [ :each | each even ]) equals: #(1 3 5). self assertIterable: ((self iteratorWithAll: #(2)) reject: [ :each | each even ]) equals: #(). self assertIterable: ((self iteratorWithAll: #(2 4)) reject: [ :each | each even ]) equals: #(). self assertIterable: ((self iteratorWithAll: #(2 4 6)) reject: [ :each | each even ]) equals: #(). self assertIterable: ((self iteratorWithAll: #(1 2 3 4 5 6)) reject: [ :each | each even ]) equals: #(1 3 5). self assertIterable: ((self iteratorWithAll: #(1 3 5 2 4 6)) reject: [ :each | each even ]) equals: #(1 3 5). self assertIterable: ((self iteratorWithAll: #(2 4 6 1 3 5)) reject: [ :each | each even ]) equals: #(1 3 5)! ! !CTContainerIteratorTest methodsFor: 'tests-modifying' stamp: 'lr 4/23/2012 21:41'! testRemoveFrom | collection iterator | collection := CTArrayList withAll: #($a $b $c $d $e). iterator := self iteratorWithAll: #($b $d $f). self assert: (iterator removeFrom: collection) = collection. self assertIterable: collection equals: #($a $c $e)! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/22/2012 22:40'! testSelect self assertIterable: ((self iteratorWithAll: #()) select: [ :each | each even ]) equals: #(). self assertIterable: ((self iteratorWithAll: #(1)) select: [ :each | each even ]) equals: #(). self assertIterable: ((self iteratorWithAll: #(1 3)) select: [ :each | each even ]) equals: #(). self assertIterable: ((self iteratorWithAll: #(1 3 5)) select: [ :each | each even ]) equals: #(). self assertIterable: ((self iteratorWithAll: #(2)) select: [ :each | each even ]) equals: #(2). self assertIterable: ((self iteratorWithAll: #(2 4)) select: [ :each | each even ]) equals: #(2 4). self assertIterable: ((self iteratorWithAll: #(2 4 6)) select: [ :each | each even ]) equals: #(2 4 6). self assertIterable: ((self iteratorWithAll: #(1 2 3 4 5 6)) select: [ :each | each even ]) equals: #(2 4 6). self assertIterable: ((self iteratorWithAll: #(1 3 5 2 4 6)) select: [ :each | each even ]) equals: #(2 4 6). self assertIterable: ((self iteratorWithAll: #(2 4 6 1 3 5)) select: [ :each | each even ]) equals: #(2 4 6)! ! !CTContainerIteratorTest methodsFor: 'tests' stamp: 'lr 4/23/2012 20:45'! testSize0 | iterator | iterator := self iteratorWithAll: #(). self assert: iterator size = 0! ! !CTContainerIteratorTest methodsFor: 'tests' stamp: 'lr 4/23/2012 20:46'! testSize1 | iterator | iterator := self iteratorWithAll: #($a). self assert: iterator size = 1! ! !CTContainerIteratorTest methodsFor: 'tests' stamp: 'lr 4/23/2012 20:46'! testSize2 | iterator | iterator := self iteratorWithAll: #($a $b). self assert: iterator size = 2. iterator := self iteratorWithAll: #($a $b $c). self assert: iterator size = 3! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/23/2012 15:12'! testZipping2 | a b | a := #($a $b $c $d). b := #($x $y $z). self assertIterable: (self iteratorWithAll: a) | (self iteratorWithAll: b) equals: #(#($a $x) #($b $y) #($c $z)). self assertIterable: (self iteratorWithAll: b) | (self iteratorWithAll: a) equals: #(#($x $a) #($y $b) #($z $c)). self assertIterable: (a := self iteratorWithAll: a) | a equals: #(#($a $b) #($c $d))! ! !CTContainerIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/23/2012 15:12'! testZipping3 | a b c | a := #($a $b $c $d). b := #($x $y $z). c := #(2 3 4 5 6). self assertIterable: (self iteratorWithAll: a) | (self iteratorWithAll: b) | (self iteratorWithAll: c) equals: #(#($a $x 2) #($b $y 3) #($c $z 4)). self assertIterable: (self iteratorWithAll: c) | (self iteratorWithAll: b) | (self iteratorWithAll: a) equals: #(#(2 $x $a) #(3 $y $b) #(4 $z $c))! ! CTContainerIteratorTest subclass: #CTOrderedIteratorTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Iterators'! !CTOrderedIteratorTest commentStamp: 'lr 4/23/2012 20:15' prior: 0! Tests iterators on containers that preserve the order of elements.! !CTOrderedIteratorTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 17:35'! iterableBuilders ^ CTArrayList new add: [ :items | Array withAll: items ]; add: [ :items | CTArrayList withAll: items ]; add: [ :items | CTVectorList withAll: items ]; add: [ :items | CTLinkedList withAll: items ]; add: [ :items | CTLinkedHashSet withAll: items ]; add: [ :items | (CTLinkedHashMap keys: items values: (1 to: items size)) keys ]; add: [ :items | (CTLinkedHashMap keys: (1 to: items size) values: items) values ]; yourself! ! !CTOrderedIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:40'! testAt2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self should: [ iterator at: 0 ] raise: CTIndexOutOfBoundsError. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator at: 1) = $a. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator at: 2) = $b. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator at: 3) = $c. iterator := self iteratorWithAll: #($a $b $c). self should: [ iterator at: 4 ] raise: CTIndexOutOfBoundsError! ! !CTOrderedIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:43'! testAtIfAbsent2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator at: 0 ifAbsent: [ true ]). iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator at: 1 ifAbsent: [ self fail ]) = $a. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator at: 2 ifAbsent: [ self fail ]) = $b. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator at: 3 ifAbsent: [ self fail ]) = $c. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator at: 4 ifAbsent: [ true ])! ! !CTOrderedIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:22'! testFind2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator find: [ :each | each = $a ]) = 1. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator find: [ :each | each = $b ]) = 2. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator find: [ :each | each = $c ]) = 3. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator find: [ :each | each = $d ]) = 0! ! !CTOrderedIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:23'! testFindIfAbsent2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator find: [ :each | each = $a ] ifAbsent: [ self fail ]) = 1. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator find: [ :each | each = $b ] ifAbsent: [ self fail ]) = 2. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator find: [ :each | each = $c ] ifAbsent: [ self fail ]) = 3. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator find: [ :each | each = $d ] ifAbsent: [ true ])! ! !CTOrderedIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:21'! testIndexOf2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator indexOf: $a) = 1. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator indexOf: $b) = 2. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator indexOf: $c) = 3. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator indexOf: $d) = 0! ! !CTOrderedIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:22'! testIndexOfIfAbsent2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator indexOf: $a ifAbsent: [ self fail ]) = 1. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator indexOf: $b ifAbsent: [ self fail ]) = 2. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator indexOf: $c ifAbsent: [ self fail ]) = 3. iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator indexOf: $d ifAbsent: [ true ])! ! !CTOrderedIteratorTest methodsFor: 'tests-indexed' stamp: 'lr 4/23/2012 15:12'! testIndexedCollect | letters expected | letters := #($a $b $c). expected := self iteratorWithAll: #(1 $A 2 $B 3 $C). ((self iteratorWithAll: letters) withIndex collect: [ :index :each | each asUppercase ]) do: [ :index :each | self assert: index = expected next. self assert: each = expected next ]. self assertIsEmpty: expected! ! !CTOrderedIteratorTest methodsFor: 'tests-indexed' stamp: 'lr 4/23/2012 15:12'! testIndexedCollectAfter | letters expected | letters := #($a $b $c). expected := self iteratorWithAll: #(1 $A 2 $B 3 $C). ((self iteratorWithAll: letters) collect: [ :each | each asUppercase ]) withIndex do: [ :index :each | self assert: index = expected next. self assert: each = expected next ]. self assertIsEmpty: expected! ! !CTOrderedIteratorTest methodsFor: 'tests-indexed' stamp: 'lr 4/23/2012 08:18'! testIndexedDo | expected | expected := self iteratorWithAll: #(1 $a 2 $b 3 $c). (self iteratorWithAll: #($a $b $c)) withIndex do: [ :index :each | self assert: index = expected next. self assert: each = expected next ]. self assertIsEmpty: expected! ! !CTOrderedIteratorTest methodsFor: 'tests-indexed' stamp: 'lr 4/23/2012 15:12'! testIndexedInject | letters expected | letters := #($a $b $c). expected := self iteratorWithAll: #(0 1 $a 10 2 $b 20 3 $c). (self iteratorWithAll: letters) withIndex 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! ! !CTOrderedIteratorTest methodsFor: 'tests-indexed' stamp: 'lr 4/23/2012 15:12'! testIndexedSelect | letters expected | letters := #($a $b $c $d $e $f $g). expected := self iteratorWithAll: #(1 $a 5 $e). ((self iteratorWithAll: letters) withIndex select: [ :index :each | each isVowel ]) do: [ :index :each | self assert: index = expected next. self assert: each = expected next ]. self assertIsEmpty: expected! ! !CTOrderedIteratorTest methodsFor: 'tests-indexed' stamp: 'lr 4/23/2012 15:12'! testIndexedSelectAfter | letters expected | letters := #($a $b $c $d $e $f $g). expected := self iteratorWithAll: #(1 $a 2 $e). ((self iteratorWithAll: letters) select: [ :each | each isVowel ]) withIndex do: [ :index :each | self assert: index = expected next. self assert: each = expected next ]. self assertIsEmpty: expected! ! !CTOrderedIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:57'! testInjectInto2 | iterator | iterator := self iteratorWithAll: #(3 4). self assert: (iterator inject: 1 into: [ :a :b | a - b ]) = -6. iterator := self iteratorWithAll: #(4 5 6). self assert: (iterator inject: 1 into: [ :a :b | a - b ]) = -14. iterator := self iteratorWithAll: #(5 6 7 8). self assert: (iterator inject: 1 into: [ :a :b | a - b ]) = -25! ! !CTOrderedIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:43'! testLast2 | iterator | iterator := self iteratorWithAll: #($a $b). self assert: iterator last = $b. iterator := self iteratorWithAll: #($a $b $c). self assert: iterator last = $c! ! !CTOrderedIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/22/2012 22:19'! testLimit super testLimit. self assertIterable: ((self iteratorWithAll: #(1 2)) limit: 1) equals: #(1). self assertIterable: ((self iteratorWithAll: #(1 2 3)) limit: 1) equals: #(1). self assertIterable: ((self iteratorWithAll: #()) limit: 2) equals: #(). self assertIterable: ((self iteratorWithAll: #(1)) limit: 2) equals: #(1). self assertIterable: ((self iteratorWithAll: #(1 2)) limit: 2) equals: #(1 2). self assertIterable: ((self iteratorWithAll: #(1 2 3)) limit: 2) equals: #(1 2). self assertIterable: ((self iteratorWithAll: #()) limit: 3) equals: #(). self assertIterable: ((self iteratorWithAll: #(1)) limit: 3) equals: #(1). self assertIterable: ((self iteratorWithAll: #(1 2)) limit: 3) equals: #(1 2). self assertIterable: ((self iteratorWithAll: #(1 2 3)) limit: 3) equals: #(1 2 3). self assertIterable: ((self iteratorWithAll: #()) limit: 4) equals: #(). self assertIterable: ((self iteratorWithAll: #(1)) limit: 4) equals: #(1). self assertIterable: ((self iteratorWithAll: #(1 2)) limit: 4) equals: #(1 2). self assertIterable: ((self iteratorWithAll: #(1 2 3)) limit: 4) equals: #(1 2 3)! ! !CTOrderedIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:44'! testNext2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: iterator next = $a. self assert: iterator next = $b. self assert: iterator next = $c. self should: [ iterator next ] raise: CTNoSuchElementError! ! !CTOrderedIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:44'! testNextOr2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator nextOr: $x) = $a. self assert: (iterator nextOr: $x) = $b. self assert: (iterator nextOr: $x) = $c. self assert: (iterator nextOr: $x) = $x! ! !CTOrderedIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 20:44'! testNextOrNil2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: iterator nextOrNil = $a. self assert: iterator nextOrNil = $b. self assert: iterator nextOrNil = $c. self assert: iterator nextOrNil isNil! ! !CTOrderedIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/23/2012 21:41'! testPartition | comparator | comparator := CTPluggableComparator equals: [ :a :b | self assertIterable: a equals: b. true ]. self assertIterable: ((self iteratorWithAll: #()) partition: 2) equals: #() comparator: comparator. self assertIterable: ((self iteratorWithAll: #(1)) partition: 2) equals: #(#(1)) comparator: comparator. self assertIterable: ((self iteratorWithAll: #(1 2)) partition: 2) equals: #(#(1 2)) comparator: comparator. self assertIterable: ((self iteratorWithAll: #(1 2 3)) partition: 2) equals: #(#(1 2) #(3)) comparator: comparator. self assertIterable: ((self iteratorWithAll: #(1 2 3 4)) partition: 2) equals: #(#(1 2) #(3 4)) comparator: comparator. self assertIterable: ((self iteratorWithAll: #(1 2 3 4 5)) partition: 2) equals: #(#(1 2) #(3 4) #(5)) comparator: comparator. self assertIterable: ((self iteratorWithAll: #(1 2 3 4 5 6)) partition: 2) equals: #(#(1 2) #(3 4) #(5 6)) comparator: comparator. self assertIterable: ((self iteratorWithAll: #()) partition: 3) equals: #() comparator: comparator. self assertIterable: ((self iteratorWithAll: #(1)) partition: 3) equals: #(#(1)) comparator: comparator. self assertIterable: ((self iteratorWithAll: #(1 2)) partition: 3) equals: #(#(1 2)) comparator: comparator. self assertIterable: ((self iteratorWithAll: #(1 2 3)) partition: 3) equals: #(#(1 2 3)) comparator: comparator. self assertIterable: ((self iteratorWithAll: #(1 2 3 4)) partition: 3) equals: #(#(1 2 3) #(4)) comparator: comparator. self assertIterable: ((self iteratorWithAll: #(1 2 3 4 5)) partition: 3) equals: #(#(1 2 3) #(4 5)) comparator: comparator. self assertIterable: ((self iteratorWithAll: #(1 2 3 4 5 6)) partition: 3) equals: #(#(1 2 3) #(4 5 6)) comparator: comparator! ! !CTOrderedIteratorTest methodsFor: 'tests-iterators' stamp: 'lr 4/23/2012 09:05'! testPeekingLong | iterator | iterator := (self iteratorWithAll: #($a $b $c)) peeking. self assert: iterator peek = $a. self assert: iterator next = $a. self assert: iterator peek = $b. self assert: iterator next = $b. self assert: iterator peek = $c. self assert: iterator next = $c. self deny: iterator hasNext ! ! !CTOrderedIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:07'! testReduce2 | iterator | iterator := self iteratorWithAll: #(3 4). self assert: (iterator reduce: [ :a :b | a - b ]) = -1. iterator := self iteratorWithAll: #(4 5 6). self assert: (iterator reduce: [ :a :b | a - b ]) = -7. iterator := self iteratorWithAll: #(5 6 7 8). self assert: (iterator reduce: [ :a :b | a - b ]) = -16! ! CTContainerIteratorTest subclass: #CTUnorderedIteratorTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Iterators'! !CTUnorderedIteratorTest commentStamp: 'lr 4/23/2012 20:14' prior: 0! Tests iterators on containers that do not preserve the order of elements.! !CTUnorderedIteratorTest methodsFor: 'assertions' stamp: 'lr 4/22/2012 22:24'! assertIterable: firstCollection equals: secondCollection self assertIterable: firstCollection equalsIgnoringOrder: secondCollection! ! !CTUnorderedIteratorTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 17:35'! iterableBuilders ^ CTArrayList new add: [ :items | CTHashSet withAll: items ]; add: [ :items | (CTHashMap keys: items values: (1 to: items size)) keys ]; add: [ :items | (CTHashMap keys: (1 to: items size) values: items) values ]; add: [ :items | CTTreeSet withAll: items ]; add: [ :items | (CTTreeMap keys: items values: (1 to: items size)) keys ]; add: [ :items | (CTTreeMap keys: (1 to: items size) values: items) values ]; add: [ :items | CTPriorityQueue withAll: items ]; yourself! ! !CTUnorderedIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 21:29'! testAt2 | iterator elements | iterator := self iteratorWithAll: #($a $b $c). self should: [ iterator at: 0 ] raise: CTIndexOutOfBoundsError. iterator := self iteratorWithAll: #($a $b $c). self assert: (#($a $b $c) includes: (iterator at: 1)). iterator := self iteratorWithAll: #($a $b $c). self assert: (#($a $b $c) includes: (iterator at: 2)). iterator := self iteratorWithAll: #($a $b $c). self assert: (#($a $b $c) includes: (iterator at: 3)). iterator := self iteratorWithAll: #($a $b $c). self should: [ iterator at: 4 ] raise: CTIndexOutOfBoundsError! ! !CTUnorderedIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 21:30'! testAtIfAbsent2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator at: 0 ifAbsent: [ true ]). iterator := self iteratorWithAll: #($a $b $c). self assert: (#($a $b $c) includes: (iterator at: 1 ifAbsent: [ self fail ])). iterator := self iteratorWithAll: #($a $b $c). self assert: (#($a $b $c) includes: (iterator at: 2 ifAbsent: [ self fail ])). iterator := self iteratorWithAll: #($a $b $c). self assert: (#($a $b $c) includes: (iterator at: 3 ifAbsent: [ self fail ])). iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator at: 4 ifAbsent: [ true ])! ! !CTUnorderedIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:35'! testFind2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: ((iterator find: [ :each | each = $a ]) between: 1 and: 3). iterator := self iteratorWithAll: #($a $b $c). self assert: ((iterator find: [ :each | each = $b ]) between: 1 and: 3). iterator := self iteratorWithAll: #($a $b $c). self assert: ((iterator find: [ :each | each = $c ]) between: 1 and: 3). iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator find: [ :each | each = $d ]) = 0! ! !CTUnorderedIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:35'! testFindIfAbsent2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: ((iterator find: [ :each | each = $a ] ifAbsent: [ self fail ]) between: 1 and: 3). iterator := self iteratorWithAll: #($a $b $c). self assert: ((iterator find: [ :each | each = $b ] ifAbsent: [ self fail ]) between: 1 and: 3). iterator := self iteratorWithAll: #($a $b $c). self assert: ((iterator find: [ :each | each = $c ] ifAbsent: [ self fail ]) between: 1 and: 3). iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator find: [ :each | each = $d ] ifAbsent: [ true ])! ! !CTUnorderedIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:36'! testIndexOf2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: ((iterator indexOf: $a) between: 1 and: 3). iterator := self iteratorWithAll: #($a $b $c). self assert: ((iterator indexOf: $b) between: 1 and: 3). iterator := self iteratorWithAll: #($a $b $c). self assert: ((iterator indexOf: $c) between: 1 and: 3). iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator indexOf: $d) = 0! ! !CTUnorderedIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:36'! testIndexOfIfAbsent2 | iterator | iterator := self iteratorWithAll: #($a $b $c). self assert: ((iterator indexOf: $a ifAbsent: [ self fail ]) between: 1 and: 3). iterator := self iteratorWithAll: #($a $b $c). self assert: ((iterator indexOf: $b ifAbsent: [ self fail ]) between: 1 and: 3). iterator := self iteratorWithAll: #($a $b $c). self assert: ((iterator indexOf: $c ifAbsent: [ self fail ]) between: 1 and: 3). iterator := self iteratorWithAll: #($a $b $c). self assert: (iterator indexOf: $d ifAbsent: [ true ])! ! !CTUnorderedIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 20:58'! testInjectInto2 | iterator | iterator := self iteratorWithAll: #(3 4). self assert: (iterator inject: 1 into: [ :a :b | a + b ]) = 8. iterator := self iteratorWithAll: #(4 5 6). self assert: (iterator inject: 1 into: [ :a :b | a + b ]) = 16. iterator := self iteratorWithAll: #(5 6 7 8). self assert: (iterator inject: 1 into: [ :a :b | a + b ]) = 27! ! !CTUnorderedIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 21:30'! testLast2 | iterator | iterator := self iteratorWithAll: #($a $b). self assert: (#($a $b) includes: iterator last). iterator := self iteratorWithAll: #($a $b $c). self assert: (#($a $b $c) includes: iterator last)! ! !CTUnorderedIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 21:33'! testNext2 | elements iterator | elements := CTArrayList new. iterator := self iteratorWithAll: #($a $b $c). elements add: iterator next; add: iterator next; add: iterator next. self assertIterable: #($a $b $c) equals: elements. self should: [ iterator next ] raise: CTNoSuchElementError! ! !CTUnorderedIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 21:33'! testNextOr2 | elements iterator | elements := CTArrayList new. iterator := self iteratorWithAll: #($a $b $c). elements add: (iterator nextOr: $x); add: (iterator nextOr: $x); add: (iterator nextOr: $x). self assertIterable: #($a $b $c) equals: elements. self assert: (iterator nextOr: $x) = $x! ! !CTUnorderedIteratorTest methodsFor: 'tests-accessing' stamp: 'lr 4/23/2012 21:33'! testNextOrNil2 | elements iterator | elements := CTArrayList new. iterator := self iteratorWithAll: #($a $b $c). elements add: iterator nextOrNil; add: iterator nextOrNil; add: iterator nextOrNil. self assertIterable: #($a $b $c) equals: elements. self assert: iterator nextOrNil isNil! ! !CTUnorderedIteratorTest methodsFor: 'tests-enumerating' stamp: 'lr 4/23/2012 21:06'! testReduce2 | iterator | iterator := self iteratorWithAll: #(3 4). self assert: (iterator reduce: [ :a :b | a + b ]) = 7. iterator := self iteratorWithAll: #(4 5 6). self assert: (iterator reduce: [ :a :b | a + b ]) = 15. iterator := self iteratorWithAll: #(5 6 7 8). self assert: (iterator reduce: [ :a :b | a + b ]) = 26! ! !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 4/22/2012 17:41'! assertIsEmpty: anIterable self deny: anIterable iterator hasNext! ! !CTContainerTest methodsFor: 'assertions' stamp: 'lr 2/12/2012 15:01'! assertIterable: firstCollection equals: secondCollection self assertIterable: firstCollection equals: secondCollection comparator: CTNaturalComparator new! ! !CTContainerTest methodsFor: 'assertions' stamp: 'lr 2/12/2012 15:02'! assertIterable: firstCollection equals: secondCollection comparator: aComparator | firstIterator secondIterator | firstIterator := firstCollection iterator. secondIterator := secondCollection iterator. [ firstIterator hasNext and: [ secondIterator hasNext ] ] whileTrue: [ self assert: (aComparator equals: firstIterator next to: secondIterator next) ]. self deny: firstIterator hasNext; deny: secondIterator hasNext! ! !CTContainerTest methodsFor: 'assertions' stamp: 'lr 4/23/2012 20:16'! assertIterable: firstCollection equalsIgnoringOrder: secondCollection self assert: firstCollection size = secondCollection size. firstCollection iterator do: [ :each | self assert: (secondCollection includes: each) ]! ! !CTContainerTest methodsFor: 'utilities' stamp: 'lr 4/22/2012 10:37'! randomSequence: anInteger "Answer an array of randomly shuffled numbers from 1 to anInteger: 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: #CTIteratorTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Iterators'! !CTIteratorTest commentStamp: 'lr 4/23/2012 07:44' prior: 0! Tests iterators that generate their output.! !CTIteratorTest methodsFor: 'tests-empty' stamp: 'lr 4/23/2012 07:52'! testEmpty | iterator | iterator := CTEmptyIterator new. self assertIterable: iterator equals: #()! ! !CTIteratorTest methodsFor: 'tests-empty' stamp: 'lr 4/23/2012 08:21'! testEmptyHasNext | iterator | iterator := CTEmptyIterator new. self deny: iterator hasNext! ! !CTIteratorTest methodsFor: 'tests-empty' stamp: 'lr 4/23/2012 07:50'! testEmptyNext | iterator | iterator := CTEmptyIterator new. self should: [ iterator next ] raise: CTNoSuchElementError ! ! CTContainerTest subclass: #CTMapTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core'! CTMapTest subclass: #CTConstructorMapTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Maps'! !CTConstructorMapTest class methodsFor: 'testing' stamp: 'lr 4/22/2012 10:18'! shouldInheritSelectors ^ false! ! !CTConstructorMapTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 10:19'! mapClass ^ CTImmutableMap ! ! !CTConstructorMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/22/2012 10:18'! testAt super testAt! ! !CTConstructorMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/22/2012 10:18'! testAtIfAbsent super testAtIfAbsent! ! !CTConstructorMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/22/2012 10:18'! testAtIfAbsentPut self should: [ super testAtIfAbsentPut ] raise: CTUnsupportedOperationError! ! !CTConstructorMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/22/2012 10:18'! testAtIfPresent super testAtIfPresent! ! !CTConstructorMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/22/2012 10:18'! testAtPut self should: [ super testAtPut ] raise: CTUnsupportedOperationError! ! !CTConstructorMapTest methodsFor: 'tests-copying' stamp: 'lr 4/22/2012 10:18'! testCopy | map immutable | map := self mapClass key: $a value: $b. immutable := map immutable. self assert: immutable copy == immutable! ! !CTConstructorMapTest methodsFor: 'tests-copying' stamp: 'lr 4/22/2012 10:18'! testImmutable | map immutable | map := self mapClass key: $a value: $b. immutable := map immutable. self assert: immutable immutable == immutable! ! !CTConstructorMapTest methodsFor: 'tests-testing' stamp: 'lr 4/22/2012 10:18'! testIncludesAllKeys super testIncludesAllKeys! ! !CTConstructorMapTest methodsFor: 'tests-testing' stamp: 'lr 4/22/2012 10:18'! testIncludesKeys super testIncludesKeys! ! !CTConstructorMapTest methodsFor: 'tests-testing' stamp: 'lr 4/22/2012 10:18'! testIsEmpty super testIsEmpty! ! !CTConstructorMapTest methodsFor: 'tests-iterating' stamp: 'lr 4/22/2012 10:18'! testIterator super testIterator! ! !CTConstructorMapTest methodsFor: 'tests-iterating' stamp: 'lr 4/22/2012 10:18'! testIteratorInjectInto super testIteratorInjectInto! ! !CTConstructorMapTest methodsFor: 'tests-exceptions' stamp: 'lr 4/22/2012 10:18'! testKeyNotFound super testKeyNotFound! ! !CTConstructorMapTest methodsFor: 'tests-instantiation' stamp: 'lr 4/22/2012 10:18'! testKeyValue1 super testKeyValue1! ! !CTConstructorMapTest methodsFor: 'tests-instantiation' stamp: 'lr 4/22/2012 10:18'! testKeyValue2 super testKeyValue2! ! !CTConstructorMapTest methodsFor: 'tests-instantiation' stamp: 'lr 4/22/2012 10:18'! testKeyValue3 super testKeyValue3! ! !CTConstructorMapTest methodsFor: 'tests-instantiation' stamp: 'lr 4/22/2012 10:18'! testKeyValue4 super testKeyValue4! ! !CTConstructorMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 10:18'! testKeysAdd super testKeysAdd! ! !CTConstructorMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 10:18'! testKeysAddAll super testKeysAddAll! ! !CTConstructorMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 10:18'! testKeysIncludes super testKeysIncludes! ! !CTConstructorMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 10:18'! testKeysIterator super testKeysIterator! ! !CTConstructorMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 10:18'! testKeysRemove self should: [ super testKeysRemove ] raise: CTUnsupportedOperationError! ! !CTConstructorMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 10:18'! testKeysRemoveAll self should: [ super testKeysRemoveAll ] raise: CTUnsupportedOperationError! ! !CTConstructorMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 10:18'! testKeysRemoveIfAbsent self should: [ super testKeysRemoveIfAbsent ] raise: CTUnsupportedOperationError! ! !CTConstructorMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 10:18'! testKeysSize super testKeysSize! ! !CTConstructorMapTest methodsFor: 'tests-instantiation' stamp: 'lr 4/22/2012 10:18'! testKeysValues super testKeysValues! ! !CTConstructorMapTest methodsFor: 'tests-instantiation' stamp: 'lr 4/22/2012 10:18'! testNew1 super testNew1! ! !CTConstructorMapTest methodsFor: 'tests-instantiation' stamp: 'lr 4/22/2012 10:18'! testNew2 super testNew2! ! !CTConstructorMapTest methodsFor: 'tests-printing' stamp: 'lr 4/22/2012 10:18'! testPrintEmpty super testPrintEmpty! ! !CTConstructorMapTest methodsFor: 'tests-printing' stamp: 'lr 4/22/2012 10:18'! testPrintFull super testPrintFull! ! !CTConstructorMapTest methodsFor: 'tests-removing' stamp: 'lr 4/22/2012 10:18'! testRemoveAll self should: [ super testRemoveAll ] raise: CTUnsupportedOperationError! ! !CTConstructorMapTest methodsFor: 'tests-removing' stamp: 'lr 4/22/2012 10:18'! testRemoveKey self should: [ super testRemoveKey ] raise: CTUnsupportedOperationError! ! !CTConstructorMapTest methodsFor: 'tests-removing' stamp: 'lr 4/22/2012 10:18'! testRemoveKeyIfAbsent self should: [ super testRemoveKeyIfAbsent ] raise: CTUnsupportedOperationError! ! !CTConstructorMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/22/2012 10:18'! testSize super testSize! ! !CTConstructorMapTest methodsFor: 'tests-copying' stamp: 'lr 4/22/2012 10:18'! testUnmodifiable | map immutable | map := self mapClass key: $a value: $b. immutable := map immutable. self assert: immutable unmodifiable == immutable! ! !CTConstructorMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 10:18'! testValuesAdd super testValuesAdd! ! !CTConstructorMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 10:18'! testValuesAddAll super testValuesAddAll! ! !CTConstructorMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 10:18'! testValuesIncludes super testValuesIncludes! ! !CTConstructorMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 10:18'! testValuesIterator super testValuesIterator! ! !CTConstructorMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 10:18'! testValuesRemove self should: [ super testValuesRemove ] raise: CTUnsupportedOperationError! ! !CTConstructorMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 10:18'! testValuesRemoveAll self should: [ super testValuesRemoveAll ] raise: CTUnsupportedOperationError! ! !CTConstructorMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 10:18'! testValuesRemoveIfAbsent self should: [ super testValuesRemoveIfAbsent ] raise: CTUnsupportedOperationError! ! !CTConstructorMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 10:18'! testValuesSize super testValuesSize! ! !CTConstructorMapTest methodsFor: 'tests-instantiation' stamp: 'lr 4/22/2012 10:18'! testWithAll super testWithAll! ! CTMapTest subclass: #CTDelegateMapTest instanceVariableNames: 'mapClass' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Maps'! !CTDelegateMapTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 09:44'! mapClass ^ mapClass! ! !CTDelegateMapTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 09:45'! mapClasses ^ Array with: CTHashMap with: CTLinkedHashMap with: CTTreeMap! ! !CTDelegateMapTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 09:48'! mapKeys: aKeysCollection values: aValuesCollection ^ CTDelegateMap on: (self mapClass keys: aKeysCollection values: aValuesCollection)! ! !CTDelegateMapTest methodsFor: 'running' stamp: 'lr 4/22/2012 09:46'! runCase self mapClasses do: [ :class | mapClass := class. super runCase ]! ! CTDelegateMapTest subclass: #CTImmutableMapTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Maps'! !CTImmutableMapTest class methodsFor: 'testing' stamp: 'lr 2/18/2012 22:19'! shouldInheritSelectors ^ false! ! !CTImmutableMapTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 09:48'! mapKeys: aKeysCollection values: aValuesCollection ^ (self mapClass keys: aKeysCollection values: aValuesCollection) immutable! ! !CTImmutableMapTest methodsFor: 'tests-accessing' stamp: 'lr 2/18/2012 23:24'! testAt super testAt! ! !CTImmutableMapTest methodsFor: 'tests-accessing' stamp: 'lr 2/18/2012 23:24'! testAtIfAbsent super testAtIfAbsent! ! !CTImmutableMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/5/2012 13:09'! testAtIfAbsentPut self should: [ super testAtIfAbsentPut ] raise: CTUnsupportedOperationError! ! !CTImmutableMapTest methodsFor: 'tests-accessing' stamp: 'lr 2/18/2012 23:25'! testAtIfPresent super testAtIfPresent! ! !CTImmutableMapTest methodsFor: 'tests-accessing' stamp: 'lr 2/18/2012 23:25'! testAtPut self should: [ super testAtPut ] raise: CTUnsupportedOperationError! ! !CTImmutableMapTest methodsFor: 'tests-copying' stamp: 'lr 2/18/2012 22:32'! testCopy | map immutable | map := self mapClass key: $a value: $b. immutable := map immutable. self assert: immutable copy == immutable! ! !CTImmutableMapTest methodsFor: 'tests-copying' stamp: 'lr 2/18/2012 22:32'! testImmutable | map immutable | map := self mapClass key: $a value: $b. immutable := map immutable. self assert: immutable immutable == immutable! ! !CTImmutableMapTest methodsFor: 'tests-testing' stamp: 'lr 2/19/2012 11:01'! testIncludesAllKeys super testIncludesAllKeys! ! !CTImmutableMapTest methodsFor: 'tests-testing' stamp: 'lr 2/19/2012 11:01'! testIncludesKeys super testIncludesKeys! ! !CTImmutableMapTest methodsFor: 'tests-testing' stamp: 'lr 2/19/2012 00:51'! testIsEmpty super testIsEmpty! ! !CTImmutableMapTest methodsFor: 'tests-iterating' stamp: 'lr 4/21/2012 21:01'! testIterator super testIterator! ! !CTImmutableMapTest methodsFor: 'tests-iterating' stamp: 'lr 4/22/2012 00:03'! testIteratorInjectInto super testIteratorInjectInto! ! !CTImmutableMapTest methodsFor: 'tests-exceptions' stamp: 'lr 4/1/2012 16:16'! testKeyNotFound super testKeyNotFound! ! !CTImmutableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:29'! testKeysAdd super testKeysAdd! ! !CTImmutableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:29'! testKeysAddAll super testKeysAddAll! ! !CTImmutableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:29'! testKeysIncludes super testKeysIncludes! ! !CTImmutableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:30'! testKeysIterator super testKeysIterator! ! !CTImmutableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:29'! testKeysRemove self should: [ super testKeysRemove ] raise: CTUnsupportedOperationError! ! !CTImmutableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:30'! testKeysRemoveAll self should: [ super testKeysRemoveAll ] raise: CTUnsupportedOperationError! ! !CTImmutableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:30'! testKeysRemoveIfAbsent self should: [ super testKeysRemoveIfAbsent ] raise: CTUnsupportedOperationError! ! !CTImmutableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:30'! testKeysSize super testKeysSize! ! !CTImmutableMapTest methodsFor: 'tests-printing' stamp: 'lr 2/19/2012 00:49'! testPrintEmpty super testPrintEmpty! ! !CTImmutableMapTest methodsFor: 'tests-printing' stamp: 'lr 2/19/2012 00:49'! testPrintFull super testPrintFull! ! !CTImmutableMapTest methodsFor: 'tests-removing' stamp: 'lr 2/19/2012 00:46'! testRemoveAll self should: [ super testRemoveAll ] raise: CTUnsupportedOperationError! ! !CTImmutableMapTest methodsFor: 'tests-removing' stamp: 'lr 2/19/2012 00:46'! testRemoveKey self should: [ super testRemoveKey ] raise: CTUnsupportedOperationError! ! !CTImmutableMapTest methodsFor: 'tests-removing' stamp: 'lr 2/19/2012 00:46'! testRemoveKeyIfAbsent self should: [ super testRemoveKeyIfAbsent ] raise: CTUnsupportedOperationError! ! !CTImmutableMapTest methodsFor: 'tests-accessing' stamp: 'lr 2/18/2012 23:27'! testSize super testSize! ! !CTImmutableMapTest methodsFor: 'tests-copying' stamp: 'lr 2/18/2012 22:33'! testUnmodifiable | map immutable | map := self mapClass key: $a value: $b. immutable := map immutable. self assert: immutable unmodifiable == immutable! ! !CTImmutableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:31'! testValuesAdd super testValuesAdd! ! !CTImmutableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:31'! testValuesAddAll super testValuesAddAll! ! !CTImmutableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:31'! testValuesIncludes super testValuesIncludes! ! !CTImmutableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:31'! testValuesIterator super testValuesIterator! ! !CTImmutableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:32'! testValuesRemove self should: [ super testValuesRemove ] raise: CTUnsupportedOperationError! ! !CTImmutableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:32'! testValuesRemoveAll self should: [ super testValuesRemoveAll ] raise: CTUnsupportedOperationError! ! !CTImmutableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:32'! testValuesRemoveIfAbsent self should: [ super testValuesRemoveIfAbsent ] raise: CTUnsupportedOperationError! ! !CTImmutableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:32'! testValuesSize super testValuesSize! ! CTDelegateMapTest subclass: #CTUnmodifiableMapTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Container-Tests-Core-Maps'! !CTUnmodifiableMapTest class methodsFor: 'testing' stamp: 'lr 2/18/2012 22:19'! shouldInheritSelectors ^ false! ! !CTUnmodifiableMapTest methodsFor: 'accessing' stamp: 'lr 4/22/2012 09:48'! mapKeys: aKeysCollection values: aValuesCollection ^ (self mapClass keys: aKeysCollection values: aValuesCollection) unmodifiable! ! !CTUnmodifiableMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/1/2012 16:12'! testAt super testAt! ! !CTUnmodifiableMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/1/2012 16:12'! testAtIfAbsent super testAtIfAbsent! ! !CTUnmodifiableMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/5/2012 13:08'! testAtIfAbsentPut self should: [ super testAtIfAbsentPut ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/1/2012 16:12'! testAtIfPresent super testAtIfPresent! ! !CTUnmodifiableMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/1/2012 16:12'! testAtPut self should: [ super testAtPut ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableMapTest methodsFor: 'tests-copying' stamp: 'lr 2/18/2012 22:56'! testCopy | map unmodifiable | map := CTHashMap key: $a value: $b. unmodifiable := map unmodifiable. self assert: unmodifiable copy == unmodifiable! ! !CTUnmodifiableMapTest methodsFor: 'tests-copying' stamp: 'lr 4/1/2012 11:21'! testImmutable | map unmodifiable immutable | map := CTHashMap key: $a value: $b. unmodifiable := map unmodifiable. immutable := unmodifiable immutable. map at: $x put: $y. self assertIterable: immutable keys equals: #($a). self assertIterable: immutable values equals: #($b)! ! !CTUnmodifiableMapTest methodsFor: 'tests-testing' stamp: 'lr 4/1/2012 16:16'! testIncludesAllKeys super testIncludesAllKeys! ! !CTUnmodifiableMapTest methodsFor: 'tests-testing' stamp: 'lr 4/1/2012 16:16'! testIncludesKeys super testIncludesKeys! ! !CTUnmodifiableMapTest methodsFor: 'tests-testing' stamp: 'lr 4/1/2012 16:16'! testIsEmpty super testIsEmpty! ! !CTUnmodifiableMapTest methodsFor: 'tests-iterating' stamp: 'lr 4/22/2012 00:33'! testIterator super testIterator! ! !CTUnmodifiableMapTest methodsFor: 'tests-iterating' stamp: 'lr 4/22/2012 00:03'! testIteratorInjectInto super testIteratorInjectInto! ! !CTUnmodifiableMapTest methodsFor: 'tests-exceptions' stamp: 'lr 4/1/2012 16:15'! testKeyNotFound super testKeyNotFound! ! !CTUnmodifiableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:33'! testKeysAdd super testKeysAdd! ! !CTUnmodifiableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:33'! testKeysAddAll super testKeysAddAll! ! !CTUnmodifiableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:33'! testKeysIncludes super testKeysIncludes! ! !CTUnmodifiableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:33'! testKeysIterator super testKeysIterator! ! !CTUnmodifiableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:33'! testKeysRemove self should: [ super testKeysRemove ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:33'! testKeysRemoveAll self should: [ super testKeysRemoveAll ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:33'! testKeysRemoveIfAbsent self should: [ super testKeysRemoveIfAbsent ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:33'! testKeysSize super testKeysSize! ! !CTUnmodifiableMapTest methodsFor: 'tests-printing' stamp: 'lr 4/1/2012 16:16'! testPrintEmpty super testPrintEmpty! ! !CTUnmodifiableMapTest methodsFor: 'tests-printing' stamp: 'lr 4/1/2012 16:16'! testPrintFull super testPrintFull! ! !CTUnmodifiableMapTest methodsFor: 'tests-removing' stamp: 'lr 4/1/2012 16:16'! testRemoveAll self should: [ super testRemoveAll ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableMapTest methodsFor: 'tests-removing' stamp: 'lr 4/1/2012 16:16'! testRemoveKey self should: [ super testRemoveKey ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableMapTest methodsFor: 'tests-removing' stamp: 'lr 4/1/2012 16:16'! testRemoveKeyIfAbsent self should: [ super testRemoveKeyIfAbsent ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/1/2012 16:10'! testSize super testSize! ! !CTUnmodifiableMapTest methodsFor: 'tests-copying' stamp: 'lr 2/18/2012 23:08'! testUnmodifiable | map unmodifiable | map := (CTHashMap key: $a value: $b) unmodifiable. unmodifiable := map unmodifiable. self assert: unmodifiable unmodifiable == unmodifiable! ! !CTUnmodifiableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:32'! testValuesAdd super testValuesAdd! ! !CTUnmodifiableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:32'! testValuesAddAll super testValuesAddAll! ! !CTUnmodifiableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:32'! testValuesIncludes super testValuesIncludes! ! !CTUnmodifiableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:32'! testValuesIterator super testValuesIterator! ! !CTUnmodifiableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:32'! testValuesRemove self should: [ super testValuesRemove ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:32'! testValuesRemoveAll self should: [ super testValuesRemoveAll ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:32'! testValuesRemoveIfAbsent self should: [ super testValuesRemoveIfAbsent ] raise: CTUnsupportedOperationError! ! !CTUnmodifiableMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:32'! testValuesSize super testValuesSize! ! 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 4/21/2012 09:20'! 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 iterator 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 4/22/2012 09:46'! emptyMap ^ self mapKeys: #() values: #()! ! !CTMapTest methodsFor: 'accessing' stamp: 'lr 2/18/2012 22:46'! mapClass self subclassResponsibility! ! !CTMapTest methodsFor: 'accessing' stamp: 'lr 4/1/2012 16:39'! mapKeys: aKeysCollection values: aValuesCollection ^ self mapClass keys: aKeysCollection values: aValuesCollection! ! !CTMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/1/2012 16:43'! testAt | map | map := self mapKeys: #($a $b $c) values: #($x $y $z). self assert: (map at: $a) = $x. self assert: (map at: $b) = $y. self assert: (map at: $c) = $z. self should: [ map at: $x ] raise: CTKeyNotFoundError! ! !CTMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/1/2012 16:43'! testAtIfAbsent | map | map := self mapKeys: #($a $b $c) values: #($x $y $z). self assert: (map at: $a ifAbsent: [ $0 ]) = $x. self assert: (map at: $b ifAbsent: [ $0 ]) = $y. self assert: (map at: $c ifAbsent: [ $0 ]) = $z. self assert: (map at: $x ifAbsent: [ $0 ]) = $0! ! !CTMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/5/2012 13:07'! testAtIfAbsentPut | map | map := self mapKeys: #($a) values: #($x). self assert: (map at: $a ifAbsentPut: [ $0 ]) = $x. self assert: (map at: $a ifAbsentPut: [ $0 ]) = $x. self assert: (map at: $b ifAbsentPut: [ $y ]) = $y. self assert: (map at: $b ifAbsentPut: [ $0 ]) = $y! ! !CTMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/1/2012 16:44'! testAtIfPresent | map | map := self mapKeys: #($a $b $c) values: #($x $y $z). self assert: (map at: $a ifPresent: [ :v | v asUppercase ]) = $X. self assert: (map at: $b ifPresent: [ :v | v asUppercase ]) = $Y. self assert: (map at: $c ifPresent: [ :v | v asUppercase ]) = $Z. self assert: (map at: $d ifPresent: [ :v | v asUppercase ]) isNil! ! !CTMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/1/2012 16:45'! testAtPut | map | map := self emptyMap. self assert: (map at: $a put: $x) = $x. self assert: (map at: $b put: $y) = $y. self assert: (map at: $c put: $z) = $z. self assert: (map at: $a put: $0) = $0. self assert: (map at: $a) = $0. self assertInvariants: map! ! !CTMapTest methodsFor: 'tests-copying' stamp: 'lr 4/21/2012 22:12'! 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 iterator next = $a. self assert: new keys iterator next = $c. self assert: old values iterator next = $b. self assert: new values iterator 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-testing' stamp: 'lr 4/1/2012 16:53'! testIncludesAllKeys | map | map := self mapKeys: #($a $b) values: #($x $y). self assert: (map includesAllKeys: #($a $b)). self assert: (map includesAllKeys: #($b $a)). self deny: (map includesAllKeys: #($a $x)). self deny: (map includesAllKeys: #($x))! ! !CTMapTest methodsFor: 'tests-testing' stamp: 'lr 4/1/2012 16:54'! testIncludesKeys | map | map := self mapKeys: #($a $b) values: #($x $y). self assert: (map includesKey: $a). self assert: (map includesKey: $b). self deny: (map includesKey: $x). self deny: (map includesKey: $y)! ! !CTMapTest methodsFor: 'tests-testing' stamp: 'lr 4/1/2012 16:52'! testIsEmpty | map | map := self emptyMap. self assert: map isEmpty. map := self mapKeys: #($a) values: #($x). self deny: map isEmpty! ! !CTMapTest methodsFor: 'tests-iterating' stamp: 'lr 4/21/2012 21:01'! testIterator | map keys values | map := self mapKeys: #($a $b $c) values: #($x $y $z). 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: $b). self assert: (keys iterator includes: $c). self assert: values size = 3. self assert: (values iterator includes: $x). self assert: (values iterator includes: $y). self assert: (values iterator includes: $z)! ! !CTMapTest methodsFor: 'tests-iterating' stamp: 'lr 4/22/2012 00:03'! testIteratorInjectInto | map | map := self mapKeys: #(1 2 3) values: #(10 20 30). self assert: (map iterator inject: 0 into: [ :result :key :value | result + key + value ]) = 66! ! !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 4/1/2012 16:47'! testKeyValue1 | map | map := self mapClass key: $a value: $x. self assertInvariants: map. self assert: (map size = 1). self assert: (map at: $a) = $x! ! !CTMapTest methodsFor: 'tests-instantiation' stamp: 'lr 4/1/2012 16:47'! testKeyValue2 | map | map := self mapClass key: $a value: $x key: $b value: $y. self assertInvariants: map. self assert: (map size = 2). self assert: (map at: $a) = $x. self assert: (map at: $b) = $y! ! !CTMapTest methodsFor: 'tests-instantiation' stamp: 'lr 4/1/2012 16:48'! testKeyValue3 | map | map := self mapClass key: $a value: $x key: $b value: $y key: $c value: $z. self assertInvariants: map. self assert: (map size = 3). self assert: (map at: $a) = $x. self assert: (map at: $b) = $y. self assert: (map at: $c) = $z! ! !CTMapTest methodsFor: 'tests-instantiation' stamp: 'lr 4/1/2012 16:48'! testKeyValue4 | map | map := self mapClass key: $a value: $x key: $b value: $y key: $c value: $z key: $d value: $0. self assertInvariants: map. self assert: (map size = 4). self assert: (map at: $a) = $x. self assert: (map at: $b) = $y. self assert: (map at: $c) = $z. self assert: (map at: $d) = $0! ! !CTMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:08'! testKeysAdd self should: [ self emptyMap keys add: $a ] raise: CTUnsupportedOperationError! ! !CTMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:09'! testKeysAddAll self should: [ self emptyMap keys addAll: #($a $b) ] raise: CTUnsupportedOperationError! ! !CTMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:22'! testKeysIncludes | map keys | map := self mapKeys: #($a $b $c) values: #($x $y $z). keys := map keys. self assert: (keys includes: $a). self assert: (keys includes: $b). self assert: (keys includes: $c). self deny: (keys includes: $x). self deny: (keys includes: $y). self deny: (keys includes: $z)! ! !CTMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:16'! testKeysIterator | map keys | map := self mapKeys: #($a $b $c) values: #($x $y $z). keys := map keys iterator as: CTArrayList. self assertIterable: keys equalsIgnoringOrder: #($a $b $c)! ! !CTMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:15'! testKeysRemove | map keys | map := self mapKeys: #($a $b $c) values: #($x $y $z). keys := map keys. self assert: (keys remove: $a) = $x. self should: [ keys remove: $a ] raise: CTElementNotFoundError. self assertIterable: keys equalsIgnoringOrder: #($b $c). self deny: (map includesKey: $a)! ! !CTMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:10'! testKeysRemoveAll | map keys | map := self mapKeys: #($a $b $c) values: #($x $y $z). keys := map keys. keys removeAll. self assert: keys isEmpty. self assert: map isEmpty! ! !CTMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:15'! testKeysRemoveIfAbsent | map keys | map := self mapKeys: #($a $b $c) values: #($x $y $z). keys := map keys. self assert: (keys remove: $c ifAbsent: [ $x ]) = $z. self should: (keys remove: $c ifAbsent: [ $x ]) = $x. self assertIterable: keys equalsIgnoringOrder: #($a $b). self deny: (map includesKey: $c)! ! !CTMapTest methodsFor: 'tests-keys' stamp: 'lr 4/22/2012 00:25'! testKeysSize | map | map := self mapKeys: #($a $b $c) values: #($x $y $z). self assert: map keys size = 3! ! !CTMapTest methodsFor: 'tests-instantiation' stamp: 'lr 4/1/2012 16:37'! testKeysValues | map | map := self mapClass keys: #($a $b $c) values: #($x $y). self assertInvariants: map. self assert: (map size = 3). self assert: (map at: $a) = $x. self assert: (map at: $b) = $y. self assert: (map at: $c) isNil! ! !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-printing' stamp: 'lr 2/19/2012 00:48'! testPrintEmpty | map | map := self emptyMap. self assert: map printString isString! ! !CTMapTest methodsFor: 'tests-printing' stamp: 'lr 4/1/2012 16:51'! testPrintFull | map | map := self mapKeys: #($a $b $c) values: #($x $y $z). self assert: map printString isString! ! !CTMapTest methodsFor: 'tests-removing' stamp: 'lr 4/1/2012 16:51'! testRemoveAll | map | map := self mapKeys: #($a $b $c) values: #($x $y $z). map removeAll. self assert: map isEmpty. self assertInvariants: map! ! !CTMapTest methodsFor: 'tests-removing' stamp: 'lr 4/1/2012 16:51'! testRemoveKey | map | map := self mapKeys: #($a $b $c) values: #($x $y $z). self should: [ map removeKey: $x ] raise: CTKeyNotFoundError. self assert: (map removeKey: $a) = $x. self assert: map size = 2. self assertInvariants: map! ! !CTMapTest methodsFor: 'tests-removing' stamp: 'lr 4/1/2012 16:52'! testRemoveKeyIfAbsent | map | map := self mapKeys: #($a $b $c) values: #($x $y $z). self assert: (map removeKey: $x ifAbsent: [ $0 ]) = $0. self assert: (map removeKey: $a) = $x. self assert: map size = 2. self assertInvariants: map! ! !CTMapTest methodsFor: 'tests-accessing' stamp: 'lr 4/1/2012 16:46'! testSize | map | map := self emptyMap. self assert: map size = 0. map := self mapKeys: #($a) values: #($x). self assert: map size = 1. map := self mapKeys: #($a $b) values: #($x $y). self assert: map size = 2! ! !CTMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:20'! testValuesAdd self should: [ self emptyMap values add: $a ] raise: CTUnsupportedOperationError! ! !CTMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:20'! testValuesAddAll self should: [ self emptyMap values addAll: #($a $b) ] raise: CTUnsupportedOperationError! ! !CTMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:21'! testValuesIncludes | map values | map := self mapKeys: #($a $b $c) values: #($x $y $z). values := map values. self deny: (values includes: $a). self deny: (values includes: $b). self deny: (values includes: $c). self assert: (values includes: $x). self assert: (values includes: $y). self assert: (values includes: $z)! ! !CTMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:20'! testValuesIterator | map values | map := self mapKeys: #($a $b $c) values: #($x $y $z). values := map values iterator as: CTArrayList. self assertIterable: values equalsIgnoringOrder: #($x $y $z)! ! !CTMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:23'! testValuesRemove | map values | map := self mapKeys: #($a $b $c) values: #($x $y $z). values := map values. self assert: (values remove: $x) = $x. self should: [ values remove: $x ] raise: CTElementNotFoundError. self assertIterable: values equalsIgnoringOrder: #($y $z). self deny: (map includesKey: $a)! ! !CTMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:24'! testValuesRemoveAll | map values | map := self mapKeys: #($a $b $c) values: #($x $y $z). values := map values. values removeAll. self assert: values isEmpty. self assert: map isEmpty! ! !CTMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:24'! testValuesRemoveIfAbsent | map values | map := self mapKeys: #($a $b $c) values: #($x $y $z). values := map values. self assert: (values remove: $x ifAbsent: [ $u ]) = $x. self assert: (values remove: $x ifAbsent: [ $u ]) = $u. self assertIterable: values equalsIgnoringOrder: #($y $z). self deny: (map includesKey: $a)! ! !CTMapTest methodsFor: 'tests-values' stamp: 'lr 4/22/2012 00:25'! testValuesSize | map | map := self mapKeys: #($a $b $c) values: #($x $y $z). self assert: map values size = 3! ! !CTMapTest methodsFor: 'tests-instantiation' stamp: 'lr 4/22/2012 10:12'! testWithAll | old new | old := self mapKeys: #($a $b $c $d $e) values: #($s $t $u $v $w). new := self mapClass withAll: old. self deny: old == new. self assertInvariants: old. self assertIterable: old keys equalsIgnoringOrder: #($a $b $c $d $e). self assertIterable: old values equalsIgnoringOrder: #($s $t $u $v $w). self assertInvariants: new. self assertIterable: new keys equalsIgnoringOrder: #($a $b $c $d $e). self assertIterable: new values equalsIgnoringOrder: #($s $t $u $v $w)! ! !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 2/13/2012 07:09'! workflowSize ^ 10000! ! 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 4/21/2012 09:20'! 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 iterator collect: [ :key :value | value ])! ! !CTLinkedHashMap methodsFor: '*container-tests-core' stamp: 'lr 4/21/2012 09:20'! assertInvariants: anAsserter super assertInvariants: anAsserter. root assertInvariants: anAsserter. self assert: table size = root iterator 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 ] ! ! !CTDelegateMap methodsFor: '*container-tests-core' stamp: 'lr 4/22/2012 10:29'! assertInvariants: anAsserter super assertInvariants: anAsserter. delegate assertInvariants: anAsserter! ! !CTHashSet methodsFor: '*container-tests-core' stamp: 'lr 1/13/2012 23:57'! assertInvariants: anAsserter super assertInvariants: anAsserter. table assertInvariants: anAsserter! !