Skip to content

Commit

Permalink
Add tests on classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Nov 5, 2024
1 parent 966f474 commit 9d344c9
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ FamixPythonProject1Test >> testClassImportsModule [
self assert: import sourceText equals: 'import moduleAtRoot3'
]

{ #category : 'tests - classes' }
FamixPythonProject1Test >> testClassInPackage [

| class |

class := self classNamed: 'ClassInSubpackage'.

self assert: class class equals: FamixPythonClass.
self assert: class name equals: 'ClassInSubpackage'.
self assert: class typeContainer equals: (self packageNamed: 'subpackage1')
]

{ #category : 'tests - attributes' }
FamixPythonProject1Test >> testClassVariableAreDefinedOnlyOnce [
"We should have only one ivar even if it is assigned multiple times."
Expand Down Expand Up @@ -1720,6 +1732,35 @@ FamixPythonProject1Test >> testSubPackage [
self assert: subSubPackage parentPackage equals: subPackage
]

{ #category : 'tests - classes' }
FamixPythonProject1Test >> testSuperclass [

| class |
class := self classNamed: 'Student'.

self assert: class class equals: FamixPythonClass.
self assert: class name equals: 'Student'.
self assert: class typeContainer equals: (self moduleNamed: 'moduleAtRoot2').
self assert: class superclass equals: (self classNamed: 'Person').
self deny: class isStub.
self deny: class superclass isStub
]

{ #category : 'tests - classes' }
FamixPythonProject1Test >> testSuperclass2 [
"Compared to the first test on superclasses, the order of parsing make it important that symbol resolution works in this case."

| class |
class := self classNamed: 'Fish'.

self assert: class class equals: FamixPythonClass.
self assert: class name equals: 'Fish'.
self assert: class typeContainer equals: (self moduleNamed: 'moduleAtRoot2').
self assert: class superclass equals: (self classNamed: 'Animal').
self deny: class isStub.
self deny: class superclass isStub
]

{ #category : 'tests - local variables' }
FamixPythonProject1Test >> testlocalVariableInFunctionAreDefinedOnlyOnce [
"We should have only one global even if it is assigned multiple times."
Expand Down

0 comments on commit 9d344c9

Please sign in to comment.