Skip to content

Commit

Permalink
Fix some bugs on references + add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Dec 5, 2024
1 parent 49eaae8 commit ccad143
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Famix-Python-Entities/FamixPythonModule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
|---|
| `accesses` | `FamixTWithAccesses` | `accessor` | `FamixTAccess` | Accesses to variables made by this behaviour.|
| `outgoingInvocations` | `FamixTWithInvocations` | `sender` | `FamixTInvocation` | Outgoing invocations sent by this behaviour.|
| `outgoingReferences` | `FamixTWithReferences` | `referencer` | `FamixTReference` | References from this entity to other entities.|
### Incoming dependencies
| Relation | Origin | Opposite | Type | Comment |
Expand All @@ -33,8 +34,8 @@
Class {
#name : 'FamixPythonModule',
#superclass : 'FamixPythonContainerEntity',
#traits : 'FamixTImportable + FamixTModule + FamixTPackageable + FamixTWithAccesses + FamixTWithComments + FamixTWithFunctions + FamixTWithGlobalVariables + FamixTWithInvocations + FamixTWithLambdas',
#classTraits : 'FamixTImportable classTrait + FamixTModule classTrait + FamixTPackageable classTrait + FamixTWithAccesses classTrait + FamixTWithComments classTrait + FamixTWithFunctions classTrait + FamixTWithGlobalVariables classTrait + FamixTWithInvocations classTrait + FamixTWithLambdas classTrait',
#traits : 'FamixTImportable + FamixTModule + FamixTPackageable + FamixTWithAccesses + FamixTWithComments + FamixTWithFunctions + FamixTWithGlobalVariables + FamixTWithInvocations + FamixTWithLambdas + FamixTWithReferences',
#classTraits : 'FamixTImportable classTrait + FamixTModule classTrait + FamixTPackageable classTrait + FamixTWithAccesses classTrait + FamixTWithComments classTrait + FamixTWithFunctions classTrait + FamixTWithGlobalVariables classTrait + FamixTWithInvocations classTrait + FamixTWithLambdas classTrait + FamixTWithReferences classTrait',
#category : 'Famix-Python-Entities-Entities',
#package : 'Famix-Python-Entities',
#tag : 'Entities'
Expand Down
1 change: 1 addition & 0 deletions src/Famix-Python-Generator/FamixPythonGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ FamixPythonGenerator >> defineHierarchy [
module --|> #TWithGlobalVariables.
module --|> #TWithLambdas.
module --|> #TWithAccesses.
module --|> #TWithReferences.

namedEntity --|> sourcedEntity.
namedEntity --|> #TInvocationsReceiver.
Expand Down
34 changes: 34 additions & 0 deletions src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2193,6 +2193,40 @@ FamixPythonProject1Test >> testReadAccessToParameter [
self assert: (function accesses anySatisfy: [ :anAccess | anAccess variable = parameter ])
]

{ #category : 'tests - references' }
FamixPythonProject1Test >> testReferenceFromModule [

| class module reference |
class := self classNamed: 'Student'.
module := self moduleNamed: 'moduleAtRoot2'.

reference := (class incomingReferences select: [ :aReference | aReference referencer = module ]) detectMax: [ :aReference | aReference sourceAnchor startPos ].

self assert: reference class equals: FamixPythonReference.
self assert: reference source equals: module.
self assert: reference referencer equals: module.
self assert: reference target equals: class.
self assert: reference referredType equals: class.
self assert: (module outgoingReferences anySatisfy: [ :aReference | aReference referredType = class ])
]

{ #category : 'tests - references' }
FamixPythonProject1Test >> testReferenceFromPackage [

| class package reference |
class := self classNamed: 'Room'.
package := self packageNamed: 'subsubpackage1'.

reference := (class incomingReferences select: [ :aReference | aReference referencer = package ]) detectMax: [ :aReference | aReference sourceAnchor startPos ].

self assert: reference class equals: FamixPythonReference.
self assert: reference source equals: package.
self assert: reference referencer equals: package.
self assert: reference target equals: class.
self assert: reference referredType equals: class.
self assert: (package outgoingReferences anySatisfy: [ :aReference | aReference referredType = class ])
]

{ #category : 'tests - modules' }
FamixPythonProject1Test >> testRootModule [

Expand Down

0 comments on commit ccad143

Please sign in to comment.