Christoph Thiede uploaded a new version of CollectionsTests to project The Trunk: http://source.squeak.org/trunk/CollectionsTests-ct.373.mcz
==================== Summary ====================
Name: CollectionsTests-ct.373 Author: ct Time: 25 March 2022, 8:08:03.84161 pm UUID: 387ae192-2211-fb4d-9bf1-16b2c2712bf3 Ancestors: CollectionsTests-ct.372
Merges SparseLargeTable enumerate+tests.1.cs:
* Tests instance creation and enumeration for SparseLargeTable/SparseLargeArray
=============== Diff against CollectionsTests-ct.372 ===============
Item was added: + SparseLargeTableTest subclass: #SparseLargeArrayTest + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'CollectionsTests-Arrayed'!
Item was added: + ----- Method: SparseLargeArrayTest>>classUnderTest (in category 'accessing') ----- + classUnderTest + + ^ SparseLargeArray!
Item was added: + ----- Method: SparseLargeArrayTest>>expectedFailures (in category 'accessing') ----- + expectedFailures + + ^ super expectedFailures , + #(testAccessing testSparseElementsAndIndicesDo) "SparseLargeArray(SparseLargeTable)>>zapDefaultOnlyEntries fails for last chunk"!
Item was added: + ----- Method: SparseLargeArrayTest>>testAccessingWithoutZapping (in category 'testing - accessing') ----- + testAccessingWithoutZapping + + | size chunkSize indices table | + size := 60. + chunkSize := 8. + indices := #(20 22 23 27 28 29 54 56 57 58). + table := self classUnderTest new: size chunkSize: chunkSize arrayClass: DoubleByteArray base: 11 defaultValue: 0. + indices do: [:index | + table at: index put: index squared]. + self shouldRaiseError: [table at: 40 put: 2 << 15]. + + self assert: size equals: table size. + self assert: chunkSize equals: table chunkSize. + + indices do: [:index | + self assert: index squared equals: ((table at: index))].!
Item was added: + ----- Method: SparseLargeArrayTest>>testSparseElementsAndIndicesDoWithoutZapping (in category 'testing - accessing') ----- + testSparseElementsAndIndicesDoWithoutZapping + + | defaultValue indices table sparse | + defaultValue := 0. + indices := #(20 22 23 27 28 29 54 56 57 58). + table := self classUnderTest new: 60 chunkSize: 8 arrayClass: DoubleByteArray base: 11 defaultValue: defaultValue. + indices do: [:index | + table at: index put: index squared]. + + sparse := Dictionary new. + table sparseElementsAndIndicesDo: [:element :index | + self deny: (sparse includesKey: index). + sparse at: index put: element]. + + table withIndexDo: [:element :index | + self assert: element equals: (sparse at: index ifAbsent: [0])].!
Item was added: + TestCase subclass: #SparseLargeTableTest + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'CollectionsTests-Arrayed'!
Item was added: + ----- Method: SparseLargeTableTest>>classUnderTest (in category 'accessing') ----- + classUnderTest + + ^ SparseLargeTable!
Item was added: + ----- Method: SparseLargeTableTest>>testAccessing (in category 'tests - accessing') ----- + testAccessing + + | size chunkSize indices table | + size := 60. + chunkSize := 8. + indices := #(20 22 23 27 28 29 54 56 57 58). + table := self classUnderTest new: size chunkSize: chunkSize arrayClass: DoubleByteArray base: 11 defaultValue: 0. + indices do: [:index | + table at: index put: index squared]. + self shouldRaiseError: [table at: 40 put: 2 << 15]. + table zapDefaultOnlyEntries. + + self assert: size equals: table size. + self assert: chunkSize equals: table chunkSize. + + indices do: [:index | + self assert: index squared equals: (table at: index)].!
Item was added: + ----- Method: SparseLargeTableTest>>testNew (in category 'tests - instance creation') ----- + testNew + + | table | + table := self classUnderTest new. + self assert: 0 equals: table size.!
Item was added: + ----- Method: SparseLargeTableTest>>testNewFrom (in category 'tests - instance creation') ----- + testNewFrom + + | array table | + array := Array streamContents: [:stream | + 15 timesRepeat: [stream nextPutAll: #($a $b $b $b $b $c $c $a)]]. "must be longer than defaultChunkSize" + table := self classUnderTest newFrom: array. + self assert: array size equals: table size. + self assert: array equals: table asArray.!
Item was added: + ----- Method: SparseLargeTableTest>>testNewWithAll (in category 'tests - instance creation') ----- + testNewWithAll + + | size table | + size := 150. "must be longer than defaultChunkSize" + table := self classUnderTest new: size withAll: 2. + self assert: size equals: table size. + self assert: (Array new: size withAll: 2) equals: table asArray.!
Item was added: + ----- Method: SparseLargeTableTest>>testNewWithSize (in category 'tests - instance creation') ----- + testNewWithSize + + | size table | + size := 14. + table := self classUnderTest new: size chunkSize: 5. + self assert: size equals: table size. + 1 to: size do: [:index | self assert: (table at: index) isNil]. + self shouldRaiseError: [table at: 0]. + self shouldRaiseError: [table at: size + 1].!
Item was added: + ----- Method: SparseLargeTableTest>>testSparseElementsAndIndicesDo (in category 'tests - accessing') ----- + testSparseElementsAndIndicesDo + + | defaultValue indices table sparse | + defaultValue := 0. + indices := #(20 22 23 27 28 29 54 56 57 58). + table := self classUnderTest new: 60 chunkSize: 8 arrayClass: DoubleByteArray base: 11 defaultValue: defaultValue. + indices do: [:index | + table at: index put: index squared]. + table zapDefaultOnlyEntries. + + sparse := Dictionary new. + table sparseElementsAndIndicesDo: [:element :index | + self deny: (sparse includesKey: index). + sparse at: index put: element]. + + table withIndexDo: [:element :index | + self assert: element equals: (sparse at: index ifAbsent: [0])].!
packages@lists.squeakfoundation.org