Skip to content

Commit

Permalink
Add more tests on edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Nov 21, 2024
1 parent 9b7adc6 commit 2aabde4
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,18 @@ FamixPythonProject1Test >> testGlobalVariablesAssignedWithATuple [
self assert: global parentScope equals: (self moduleNamed: 'moduleAtRoot')
]

{ #category : 'tests - global variables' }
FamixPythonProject1Test >> testGlobalVariablesShadowedThenRedefined [

| globals |
globals := self model allGlobalVariables select: [ :variable | variable name = 'global_then_function_then_global_then_class' ].

self assert: globals size equals: 2.
globals do: [ :global |
self assert: global name equals: 'global_then_function_then_global_then_class'.
self assert: global parentScope equals: (self moduleNamed: 'moduleWithShadowing') ]
]

{ #category : 'tests - global variables' }
FamixPythonProject1Test >> testGlobalVariablesWithTheSameNameButDifferentParents [

Expand Down Expand Up @@ -2246,6 +2258,23 @@ FamixPythonProject1Test >> testWriteAccessFromPackage [
self assert: (p accesses anySatisfy: [ :anAccess | anAccess variable = a ])
]

{ #category : 'tests - accesses' }
FamixPythonProject1Test >> testWriteAccessOfGlobalThatGotShadowedAndRedefined [
"This test ensure that if we declare a global, shadow it and redefine it again, the accesses are going to the right global."

| global1 global2 module accesses |
global1 := (self model allGlobalVariables select: [ :entity | entity name = 'global_then_function_then_global_then_class' ]) asOrderedCollection detectMin: [
:entity | entity sourceAnchor startPos ].
global2 := (self model allGlobalVariables select: [ :entity | entity name = 'global_then_function_then_global_then_class' ]) asOrderedCollection detectMax: [
:entity | entity sourceAnchor startPos ].
module := self moduleNamed: 'moduleWithShadowing'.

accesses := module accesses select: [ :anAccess | anAccess variable name = 'global_then_function_then_global_then_class' ].

self assert: (accesses detectMin: [ :entity | entity sourceAnchor startPos ]) variable equals: global1.
self assert: (accesses detectMax: [ :entity | entity sourceAnchor startPos ]) variable equals: global2
]

{ #category : 'tests - accesses' }
FamixPythonProject1Test >> testWriteAccessSourceAnchor [

Expand Down

0 comments on commit 2aabde4

Please sign in to comment.