Skip to content

Commit

Permalink
Merge pull request #797 from moosetechnology/redo-467-with-test
Browse files Browse the repository at this point in the history
redo #467
  • Loading branch information
ClotildeToullec authored Aug 27, 2024
2 parents af8d774 + c59827a commit 33924be
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
21 changes: 21 additions & 0 deletions src/Moose-Core-Tests/MooseGroupStorageTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"
A MooseGroupStorageTest is a test class for testing the behavior of MooseGroupStorage
"
Class {
#name : #MooseGroupStorageTest,
#superclass : #TestCase,
#category : #'Moose-Core-Tests'
}

{ #category : #test }
MooseGroupStorageTest >> testSpecies [

| groupA anEntity |
groupA := MooseModel new.
anEntity := MooseEntity new.
groupA add: anEntity.
groupA add: anEntity.
self assert: groupA size equals: 2.
groupA entityStorage species: Set.
self assert: groupA size equals: 1.
]
12 changes: 10 additions & 2 deletions src/Moose-Core/MooseGroupStorage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ Class {
#instVars : [
'byName',
'elements',
'byType'
'byType',
'species'
],
#category : #'Moose-Core'
}
Expand Down Expand Up @@ -125,6 +126,7 @@ MooseGroupStorage >> initialize: capacity [

byType := IdentityDictionary new: 24.
byName := IdentityHashTable new: capacity.
species := OrderedCollection.
elements := self species new: capacity
]

Expand Down Expand Up @@ -204,7 +206,13 @@ MooseGroupStorage >> sort: aBlock [
{ #category : #private }
MooseGroupStorage >> species [

^ OrderedCollection
^ species
]

{ #category : #private }
MooseGroupStorage >> species: aCollectionClass [
species := aCollectionClass.
^ elements := self species withAll: elements
]

{ #category : #private }
Expand Down

0 comments on commit 33924be

Please sign in to comment.