Skip to content

Commit

Permalink
fix #185
Browse files Browse the repository at this point in the history
  • Loading branch information
LabordePierre committed Sep 13, 2024
1 parent f41b50f commit 320ecf1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
9 changes: 9 additions & 0 deletions src/Molecule-Tests/MolCompleteComponentTypeUser.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"
This type use another type to extend it.
"
Trait {
#name : #MolCompleteComponentTypeUser,
#traits : 'MolCompleteComponent',
#classTraits : 'MolCompleteComponent classTrait',
#category : #'Molecule-Tests-Resources - Contracts'
}
18 changes: 12 additions & 6 deletions src/Molecule-Tests/MolUtilsTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -250,21 +250,24 @@ MolUtilsTest >> testOfferedTypes [

"Type used services"
types := MolUtils offeredTypes: MolUsedServices.
self assert: types size equals: 2.
self assert: types size equals: 3.
self assert: (types includes: MolCompleteComponent).
self assert: (types includes: MolCompleteComponent2).
self assert: (types includes: MolCompleteComponentTypeUser).

"Type provide events"
types := MolUtils offeredTypes: MolUsedEvents.
self assert: types size equals: 2.
self assert: types size equals: 3.
self assert: (types includes: MolCompleteComponent).
self assert: (types includes: MolCompleteComponent2).
self assert: (types includes: MolCompleteComponentTypeUser).

"Type used parameters"
types := MolUtils offeredTypes: MolUsedParameters.
self assert: types size equals: 2.
self assert: types size equals: 3.
self assert: (types includes: MolCompleteComponent).
self assert: (types includes: MolCompleteComponent2).
self assert: (types includes: MolCompleteComponentTypeUser).
]

{ #category : #tests }
Expand Down Expand Up @@ -434,21 +437,24 @@ MolUtilsTest >> testRequiredTypes [

"Type used services"
types := MolUtils requiredTypes: MolUsedServices.
self assert: types size equals: 2.
self assert: types size equals: 3.
self assert: (types includes: MolCompleteComponent).
self assert: (types includes: MolCompleteComponent2).
self assert: (types includes: MolCompleteComponentTypeUser).

"Type provide events"
types := MolUtils requiredTypes: MolUsedEvents.
self assert: types size equals: 2.
self assert: types size equals: 3.
self assert: (types includes: MolCompleteComponent).
self assert: (types includes: MolCompleteComponent2).
self assert: (types includes: MolCompleteComponentTypeUser).

"Type used parameters"
types := MolUtils requiredTypes: MolUsedParameters.
self assert: types size equals: 2.
self assert: types size equals: 3.
self assert: (types includes: MolCompleteComponent).
self assert: (types includes: MolCompleteComponent2).
self assert: (types includes: MolCompleteComponentTypeUser).
]

{ #category : #tests }
Expand Down
11 changes: 9 additions & 2 deletions src/Molecule/MolUtils.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ MolUtils class >> allComponentInstancesOfType: aComponentType [
^oc
]

{ #category : #private }
MolUtils class >> allComponentTypes [
"Return all ComponentTypes traits"

^ self environment allTraits select: [ :t | t isComponentType ]
]

{ #category : #'component contract' }
MolUtils class >> componentType: aComponentOrComponentClass [
"Get component type of a component or a component class, return nil if no type was found"
Expand Down Expand Up @@ -211,7 +218,7 @@ MolUtils class >> offeredTypes: aComponentContractInterface [
(aComponentContractInterface isComponentServices not and:[aComponentContractInterface isComponentEvents not and:[aComponentContractInterface isComponentParameters not]]) ifTrue:[ ^ list asOrderedCollection ].

"Collect all required"
MolComponentType users do:[ :type |
self allComponentTypes do:[ :type |
aComponentContractInterface isComponentServices ifTrue:[
(type isProvideServices: aComponentContractInterface) ifTrue:[ list add: type ].
] ifFalse:[
Expand Down Expand Up @@ -311,7 +318,7 @@ MolUtils class >> requiredTypes: aComponentContractInterface [
(aComponentContractInterface isComponentServices not and:[aComponentContractInterface isComponentEvents not and:[aComponentContractInterface isComponentParameters not]]) ifTrue:[ ^ list asOrderedCollection ].

"Collect all required"
MolComponentType users do:[ :type |
self allComponentTypes do:[ :type |
aComponentContractInterface isComponentServices ifTrue:[
(type isUseServices: aComponentContractInterface) ifTrue:[ list add: type ].
] ifFalse:[
Expand Down

0 comments on commit 320ecf1

Please sign in to comment.