Skip to content

Commit

Permalink
2 more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anquetil committed Nov 17, 2024
1 parent a0071cd commit 3b709fc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/MooseIDE-Dependency/FamixTMethod.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,17 @@ Extension { #name : #FamixTMethod }
FamixTMethod >> addNonAssociationDependenciesTo: dependencies [

self children do: [ :c | c addNonAssociationDependenciesTo: dependencies ].
self declaredType ifNotNil: [ dependencies add: self declaredType ]

declaredType ifNotNil: [
dependencies add: declaredType.

( (declaredType usesFamixTrait: FamixTParametricEntity) and:
[ declaredType genericization isNotNil ])
ifTrue: [
declaredType concreteParameters do: [ :param |
param children ifNotEmpty: [ dependencies add: param ]
]
]

]
]
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,33 @@ MiDependencyStructuralMatrixBrowserTest >> testOutgoingDependencyFromMethodDecla

]

{ #category : #tests }
MiDependencyStructuralMatrixBrowserTest >> testOutgoingDependencyFromVMethodDeclaredTypeParametric [
"code:
Class2
ParametricClass<Class1> mth2
Note: FamixJavaConcretization is an association and we are not interested in its genericEntity here
Note: hueristic to detect a concreteParameter being a genuine class is to check it has children
That's why we use Class1 and not Class3 as concreteParameter"

| mth2 parametricClass dependencies |
parametricClass := model newParametricClass
name: 'ParametricClass' ;
genericization: model newConcretization ;
addConcreteParameter: class1 ;
yourself.

mth2 := class2 methods anyOne.
mth2 declaredType: parametricClass.

dependencies := mth2 queryAllOutgoingForDSM.

self assert: dependencies size equals: 2.
dependencies do: [ :dep |
{ 'ParametricClass' . 'Class1' } includes: dep name
]
]

{ #category : #tests }
MiDependencyStructuralMatrixBrowserTest >> testOutgoingDependencyFromVariableDeclaredType [

Expand All @@ -161,7 +188,7 @@ MiDependencyStructuralMatrixBrowserTest >> testOutgoingDependencyFromVariableDec
"code:
Class2
mth2
ParametricClass<Class3> local2
ParametricClass<Class1> local2
Note: FamixJavaConcretization is an association and we are not interested in its genericEntity here
Note: hueristic to detect a concreteParameter being a genuine class is to check it has children
That's why we use Class1 and not Class3 as concreteParameter"
Expand Down

0 comments on commit 3b709fc

Please sign in to comment.