smalltalk
/
osmo-st-all
Archived
1
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
osmo-st-all/grease/Tests/Core/GRAbstractDictionaryTest.st

86 lines
1.7 KiB
Smalltalk

GRCollectionTest subclass: GRAbstractDictionaryTest [
| associations |
<comment: nil>
<category: 'Grease-Tests-Core'>
GRAbstractDictionaryTest class >> isAbstract [
<category: 'testing'>
^self name = #GRAbstractDictionaryTest
]
allowsDuplicateValues [
<category: 'configuration'>
^true
]
arbitraryAssociations [
<category: 'configuration'>
^associations ifNil: [associations := self createArbitraryAssociations]
]
arbitraryCollection [
<category: 'configuration'>
| dict |
dict := self emptyCollection.
self arbitraryAssociations do: [:each | dict at: each key put: each value].
^dict
]
createArbitraryAssociations [
<category: 'configuration'>
self subclassResponsibility
]
isKey: anObject equivalentTo: anotherObject [
<category: 'configuration'>
self subclassResponsibility
]
isExtensible [
<category: 'testing-ansi'>
^false
]
isInitializable [
<category: 'testing-ansi'>
^false
]
isSequenced [
<category: 'testing-ansi'>
^false
]
isSequencedReadable [
<category: 'testing-ansi'>
^false
]
testAssociationsDo [
<category: 'tests'>
| collection assocs count |
collection := self arbitraryCollection.
assocs := self arbitraryAssociations copy.
count := 0.
collection associationsDo:
[:assoc |
| size |
count := count + 1.
size := assocs size.
assocs := assocs reject:
[:each |
(self isKey: each key equivalentTo: assoc key)
and: [each value = assoc value]].
self assert: size - 1 = assocs size].
self assert: assocs isEmpty.
self assert: count = self arbitraryAssociations size
]
valuesOf: aCollection [
<category: 'private'>
^aCollection values
]
]