Skip to content

Commit

Permalink
correcting errors in FASTCopyVisitorCodeGeneratorTest (+ adding tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
anquetil committed Nov 10, 2024
1 parent 246c458 commit 768bece
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 14 deletions.
62 changes: 49 additions & 13 deletions src/FAST-Core-Tools-Tests/FASTCopyVisitorCodeGeneratorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,21 @@ FASTCopyVisitorCodeGeneratorTest >> setUp [
generator := FASTCopyVisitorCodeGenerator new.

visitorClass := Mock named: 'visitor'.
visitorMethods := OrderedCollection new.

visitorClass stub package willReturn: (self class package).

visitorMethods := OrderedCollection new.
(visitorClass stub compile: Any classified: Any) will: [ :method :category |
visitorMethods add: method -> category ]
]

{ #category : 'running' }
FASTCopyVisitorCodeGeneratorTest >> tearDown [
super tearDown.

self class package extensionMethods do: #removeFromSystem
]

{ #category : 'tests' }
FASTCopyVisitorCodeGeneratorTest >> testGenerateCopyMethod [

Expand All @@ -45,39 +54,66 @@ FASTCopyVisitorCodeGeneratorTest >> testGenerateCopyMethod [
]

{ #category : 'tests' }
FASTCopyVisitorCodeGeneratorTest >> testShouldCopyPropertyFor [
FASTCopyVisitorCodeGeneratorTest >> testShouldCopyMultiValuedDerivedProperty [

| property |

property := FmxTraitsTestGenerateAccessorBClassB asMooseDescription
allProperties detect: [ :prop | prop name = 'relationToA' ].

self assert: property isDerived.
self assert: (generator shouldCopyProperty: property)
]

{ #category : 'tests' }
FASTCopyVisitorCodeGeneratorTest >> testShouldCopyNotMultiValuedProperty [

| property |

property := FmxTraitsTestGenerateAccessorBClassB asMooseDescription
allProperties detect: [ :prop | prop name = 'relationToA' ].

self deny: property isMultivalued.
self assert: (generator shouldCopyProperty: property)
]

{ #category : 'tests' }
FASTCopyVisitorCodeGeneratorTest >> testShouldCopyPropertyToOtherEntity [

| property |

property := FmxTraitsTestGenerateAccessorBClassA asMooseDescription
allProperties detect: [ :prop | prop name = 'relationToB' ].

generator package: (FmxTraitsTestGenerateAccessorBClassA metamodel packages detect: [ :p | p name = 'Famix-MetamodelBuilder-TestsTraitsResources-A' ]).
self assert: (generator shouldCopyProperty: property).


]

{ #category : 'tests' }
FASTCopyVisitorCodeGeneratorTest >> testShouldNotCopyDerivedProperty [
FASTCopyVisitorCodeGeneratorTest >> testShouldNotCopyMultivaluedDerivedProperty [

| property |

property := FmxTraitsTestGenerateAccessorBClassB asMooseDescription
allProperties detect: [ :prop | prop name = 'relationToA' ].

self assert: property isDerived.

"focing it to be multivalued"
property isMultivalued: true.
self assert: property isMultivalued.
self deny: (generator shouldCopyProperty: property)
]

{ #category : 'tests' }
FASTCopyVisitorCodeGeneratorTest >> testShouldNotCopyPropertyFromOtherPackage [

FASTCopyVisitorCodeGeneratorTest >> testShouldNotCopyPropertyParent [
"property pointing to parent should not be copied"
| property |

property := FmxTraitsTestGenerateAccessorBClassB asMooseDescription
allProperties detect: [ :prop | prop name = 'relationToA' ].

generator package: (FmxTraitsTestGenerateAccessorBClassA metamodel packages detect: [ :p | p name = 'Famix-MetamodelBuilder-TestsTraitsResources-B' ]).
self assert: (generator shouldCopyProperty: property)
property := FmxTraitsTestGenerateAccessorBClassA asMooseDescription
allProperties detect: [ :prop | prop name = 'relationToB' ].

"forcing it to be to parent"
property isContainer: true.
self assert: property isContainer.
self deny: (generator shouldCopyProperty: property)
]
4 changes: 3 additions & 1 deletion src/FAST-Core-Tools/FASTVisitorCodeGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ FASTVisitorCodeGenerator >> generateAccept: modelClass [
{ #category : 'code generation' }
FASTVisitorCodeGenerator >> generateAcceptSelectorOn: stream [

stream << 'accept: aVisitor'
stream
<< 'accept: aVisitor' ;
cr
]

{ #category : 'code generation' }
Expand Down

0 comments on commit 768bece

Please sign in to comment.