Skip to content

Commit

Permalink
Add test on stub creation of constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Jan 22, 2025
1 parent b900cd3 commit 6b7e94d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,21 @@ FamixPythonProject1Test >> testInstantiationFromPackage [
self assert: (package outgoingInvocations anySatisfy: [ :aReference | aReference invokedEntity = constructor ])
]

{ #category : 'tests - instantiation' }
FamixPythonProject1Test >> testInstantiationOfClassWithoutExplicitConstructorCreatesStubs [
"It was decided that if we instantiate a class without a constructor, we create a stub one to create an invocation on it."

| class package constructor |
class := self classNamed: 'Animal'.
package := self packageNamed: 'root'.

self shouldnt: [ constructor := class methods detect: #isConstructor ] raise: Error.

self assert: constructor isStub.
self assert: constructor name equals: '__init__'.
self assert: constructor parentType equals: class
]

{ #category : 'tests - instantiation' }
FamixPythonProject1Test >> testInstantiationSourceAnchor [

Expand Down

0 comments on commit 6b7e94d

Please sign in to comment.