Skip to content

Commit

Permalink
Merge pull request #746 from moosetechnology/745-add-withoutStubs-to-…
Browse files Browse the repository at this point in the history
…MooseModel

Fix #745: Add #withoutStubs to MooseAbstractGroup
  • Loading branch information
ClotildeToullec authored Mar 29, 2024
2 parents f4794eb + 8e5a254 commit eec9d16
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Moose-Core-Tests/MooseAbstractGroupTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,29 @@ MooseAbstractGroupTest >> testWithIndexDo [
self assertCollection: t hasSameElements: {{el1 . 1} . {el2 . 2} . {el3 . 3}}
]

{ #category : #tests }
MooseAbstractGroupTest >> testWithoutStubs [

| stubEntity1 stubEntity2 |

stubEntity1 := MooseEntity new
isStub: true;
yourself.
stubEntity2 := MooseEntity new
isStub: true;
yourself.
group
add: MooseEntity new;
add: MooseEntity new;
add: stubEntity1;
add: stubEntity2.

self assert: group size equals: 4.
self assert: group withoutStubs isMooseObject.
self assert: group withoutStubs size equals: 2.
group withoutStubs do: [ :entity | self deny: entity isStub ]
]

{ #category : #utilities }
MooseAbstractGroupTest >> twoClasses [
| classA classB |
Expand Down
6 changes: 6 additions & 0 deletions src/Moose-Core/MooseAbstractGroup.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,12 @@ MooseAbstractGroup >> withIndexDo: aBlockClosure [
self entities withIndexDo: aBlockClosure
]

{ #category : #accessing }
MooseAbstractGroup >> withoutStubs [

^ (self reject: #isStub) asMooseGroup
]

{ #category : #'set operations' }
MooseAbstractGroup >> | aCollection [
^ self union: aCollection
Expand Down
5 changes: 5 additions & 0 deletions src/Moose-Core/MooseObject.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ MooseObject >> isMooseModel [
^ false
]

{ #category : #testing }
MooseObject >> isMooseObject [
^ true
]

{ #category : #testing }
MooseObject >> isOfType: aClassFAMIX [
^ self class isOfType: aClassFAMIX
Expand Down
5 changes: 5 additions & 0 deletions src/Moose-Core/Object.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ Object >> isMooseEntity [
^ false
]

{ #category : #'*Moose-Core' }
Object >> isMooseObject [
^ false
]

{ #category : #'*Moose-Core' }
Object class >> isOfType: aClassFAMIX [
^ false
Expand Down

0 comments on commit eec9d16

Please sign in to comment.