Skip to content

Commit

Permalink
Merge pull request #103 from OpenSmock/dev-99
Browse files Browse the repository at this point in the history
Update test to check if the "dirty type" is realy dirty + works after Pharo 11 patch
  • Loading branch information
labordep authored Oct 3, 2023
2 parents 51229e9 + 3ae754b commit 46b2565
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Molecule-Tests/MolDirtyComponentTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,41 @@ MolDirtyComponentTest >> tearDown [
self cleanGeneratedClassesAndTraits.
MolComponentManager cleanUp.
]

{ #category : #tests }
MolDirtyComponentTest >> testDirtyTypeWithInstanceVariableInsteadOfComponentTraits [

"Create a component using a dirty Type"
| component |
MolComponentFactory createComponentForType: MolDirtyType named: self generatedDirtyTypeImplementationSymbol in: self generationTag.
component := self class environment at: self generatedDirtyTypeImplementationSymbol.

"Check if the ComponentType is dirty"
self assert: MolDirtyType producedComponentEvents size equals: 1.
self assert: MolDirtyType producedComponentEvents first equals: nil.
self assert: MolDirtyType consumedComponentEvents size equals: 1.
self assert: MolDirtyType consumedComponentEvents first equals: nil.
self assert: MolDirtyType providedComponentParameters size equals: 1.
self assert: MolDirtyType providedComponentParameters first equals: nil.
self assert: MolDirtyType providedComponentServices size equals: 1.
self assert: MolDirtyType providedComponentServices first equals: nil.
self assert: MolDirtyType usedComponentParameters size equals: 1.
self assert: MolDirtyType usedComponentParameters first equals: nil.
self assert: MolDirtyType usedComponentServices size equals: 1.
self assert: MolDirtyType usedComponentServices first equals: nil.
self assert: (MolDirtyType class slotNames first) equals: #anInstanceVariable.

"Check no generation of non necessary methods"
self deny: (component methodDictionary includesKey: #getnilSubscriber).
self deny: (component methodDictionary includesKey: #getnilNotifier).
self deny: (component methodDictionary includesKey: #getnilProvider).

"Check that the contract is empty despite class side var in the all contract interfaces"
self assert: component allConsumedEvents isEmpty.
self assert: component allProducedEvents isEmpty.
self assert: component allProvidedServices isEmpty.
self assert: component allUsedServices isEmpty.
self assert: component allProvidedParameters isEmpty.
self assert: component allUsedParameters isEmpty.

]
49 changes: 49 additions & 0 deletions Molecule-Tests/MolDirtyType.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"
This Type have a wrong writted contract with variables instead of Traits
"
Trait {
#name : #MolDirtyType,
#classInstVars : [
'anInstanceVariable'
],
#traits : 'MolComponentType',
#classTraits : 'MolComponentType classTrait',
#category : #'Molecule-Tests-Resources - Contracts'
}

{ #category : #'accessing - events' }
MolDirtyType classSide >> consumedComponentEvents [

<componentContract>
^ { anInstanceVariable }
]

{ #category : #'accessing - events' }
MolDirtyType classSide >> producedComponentEvents [
<componentContract>
^ {anInstanceVariable}
]

{ #category : #'accessing - parameters' }
MolDirtyType classSide >> providedComponentParameters [
<componentContract>
^ {anInstanceVariable}
]

{ #category : #'accessing - services' }
MolDirtyType classSide >> providedComponentServices [
<componentContract>
^ {anInstanceVariable}
]

{ #category : #'accessing - parameters' }
MolDirtyType classSide >> usedComponentParameters [
<componentContract>
^ {anInstanceVariable}
]

{ #category : #'accessing - services' }
MolDirtyType classSide >> usedComponentServices [
<componentContract>
^ {anInstanceVariable}
]

0 comments on commit 46b2565

Please sign in to comment.